cmake - About Magick++, how to write the CMakeLists? -


everyone.

there cmakelists.

cmake_minimum_required(version 3.5) project(blah)  set(cmake_cxx_flags "${cmake_cxx_flags} -std=c++11")  set(source_files main.cpp) add_executable(blah ${source_files})  find_package(imagemagick) find_package(imagemagick components magick++) find_package(imagemagick components convert) find_package(imagemagick components magick++ convert)  include_directories(${imagemagick_include_dirs}) target_link_libraries(blah ${imagemagick_libraries}) 

and code looks this.

#include <iostream> #include <magick++.h> using namespace std;  int main(int argc, char **argv) {     magick::image image("640*480", "white"); } 

it reports errors undefined reference 'magick::color::color(char const*)'. , solution seems should write g++ 'magick++-config --cxxflags --cppflags' -o example example.cxx 'magick++-config --ldflags --libs'.

sadly, don't know how write correct cmakelists' items it, or, whole magick++. (i learned basics cmake. yet useless, sadly.)

many if me!

imagemagick ships magick++-config utility. since you're setting cmake_cxx_flags directly, might ask magick++-config cxx & lib flags.

cmake_minimum_required(version 3.5) project(blah)  # find magick++-config lives find_program(magick_config "magick++-config") # ask cxx , lib flags/locations execute_process(command "${magick_config}" "--cxxflags" output_variable magick_cxx_flags) execute_process(command "${magick_config}" "--libs" output_variable magick_ld_flags) # remove trailing whitespace (cmake warns this) string(strip "${magick_cxx_flags}" magick_cxx_flags) string(strip "${magick_ld_flags}" magick_ld_flags) # append flags cmake_cxx_flags set(cmake_cxx_flags "${cmake_cxx_flags} -std=c++11 ${magick_cxx_flags} ${magick_ld_flags}")  set(source_files main.cpp)  add_executable(blah ${source_files}) 

but! cmake handling libraries & dependancies. should work.

cmake_minimum_required(version 3.5) project(blah)  set(cmake_cxx_flags "${cmake_cxx_flags} -std=c++11")  set(source_files main.cpp)  add_executable(blah ${source_files}) add_definitions( -dmagickcore_quantum_depth=16 ) add_definitions( -dmagickcore_hdri_enable=0 ) find_package(imagemagick components magick++) include_directories(${imagemagick_include_dirs}) target_link_libraries(blah ${imagemagick_libraries}) 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -