简体   繁体   中英

app with magick++ returns Magick++/Functions.h:14:10: fatal error: 'string' file not found

I'm trying to build a simple C++ app in MacOS (Big Sur) using ImageMagick

This is my CMakeLists.txt:

cmake_minimum_required(VERSION 3.7)
project(HelloWorld)
add_definitions(-std=c++17)

set(CXX_FLAGS "-Wall")
set(CMAKE_CXX_FLAGS, "${CXX_FLAGS}")

add_executable(HelloWorld src/main.cpp)

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(HelloWorld ${ImageMagick_LIBRARIES})

and on my main.cpp, I just have #include <Magick++.h> at the top of the file

When I run the build I get the

/usr/local/Cellar/imagemagick/7.0.10-48/include/ImageMagick-7/Magick++/Functions.h:14:10: fatal error: 'string' file not found

any ideas what's the issue here? I reinstalled imagemagick but I still get the same error.

CMake version is 3.19

EDIT:

Seems that the issue is with my macOS setup, I tried just compiling a simple hello world, and I get the same error with #include <iostream>

Any idea on how to fix/reset the c++/gcc setup on mac?

I presume that you used homebrew to install your GCC , ie "GNU Compiler Collection" which includes g++ the C++ compiler. So, in order to get the version number, you can run:

ls /usr/local/bin/g++*

Sample Output

/usr/local/bin/g++-10

Now you need to tell cmake to use that compiler, so you would use:

CXX=/usr/local/bin/g++-10 cmake ..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM