Hard time with VSCode and Magick++: Header File not found when compiling

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Locked
LeFish
Posts: 5
Joined: 2020-03-25T11:33:11-07:00
Authentication code: 1152

Hard time with VSCode and Magick++: Header File not found when compiling

Post by LeFish »

Hi there,

I am trying to compile my first ImageMagick project in VSCode http://code.visualstudio.com.
I am using the MinGW compiler and added all the necessary folders in c_cpp_properties.json

c_cpp_properties.json:

Code: Select all

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:\\MinGW\\lib\\gcc\\mingw32\\9.2.0\\include\\c++",
                "C:\\Program Files\\ImageMagick-7.0.9-Q8\\include\\**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:\\MinGW\\bin\\gcc.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x86"
        }
    ],
    "version": 4
}
The funny thing is, that it finds the library in the editor (->Intellisense) like seen in the picture. If not found it would not display the content...

Image

But when compiling I get the error

Code: Select all

c:\Users\jfi\Desktop\Hints_Scripts\InsortAP_Toolbox\VSCode\IMhelloworld\main.cpp:2:10: fatal error: Magick++.h: No such file or directory
    2 | #include <Magick++.h>
      |          ^~~~~~~~~~~~
compilation terminated.
The terminal process terminated with exit code: 1
What am I doing wrong for it to not compile correctly?

Thank you for your help!

Best regards
LeFish

LeFish
Posts: 5
Joined: 2020-03-25T11:33:11-07:00
Authentication code: 1152

Re: Hard time with VSCode and Magick++: Header File not found when compiling

Post by LeFish »

Ok, I resolved this issue by using cmake and cmake extension for vscode.

I have the following CMakeLists.txt File:

Code: Select all

cmake_minimum_required(VERSION 3.0)
project(IMHelloWorld VERSION 1.0.0)


set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

add_executable(IMHelloWorld 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(IMHelloWorld ${ImageMagick_LIBRARIES})
Now it compiles perfectly.

Locked