1

in my first C++ project in Visual Studio Code I have troubles in including the external library Imagemagick (imagemagick.org) Magick++.h Pic1

I installed the library files and linked the installation folder in c_cpp_properties.json Pic3

Therefore, when I include the library I do not have any "wavy line", which marks a non found library Pic2

Anyhow, whenever I try to compile with

C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.25.28610/bin/Hostx64/x64/cl.exe

I get:

IMhelloworld.cpp

c:\Users\jfi\Desktop\Hints_Scripts\InsortAP_Toolbox\VSCode\IMHelloWorld\IMhelloworld.cpp(1): fatal error C1083: Datei (Include) kann nicht geöffnet werden: "Magick++.h": No such file or directory

Please help! What am I missing?

Thank you so much!

Best regards LeFish

enter image description here

LeFish
  • 25
  • 4
  • If you are using the C++ binding to ImageMagick, you should use the [tag:magick++] tag to attract the correct people. – Mark Setchell Mar 25 '20 at 09:11
  • This may be the solution...https://stackoverflow.com/a/18068069/2836621 – Mark Setchell Mar 25 '20 at 16:31
  • Thanks! I am on VSCode and therefore do not have these menus. I also tried with an other compiler (MINGW). Same result. I can add the mingw-standard-libraries (like iostream etc) and the compiler finds it. But whenever I add the magick++.h it is only found by IntelliSense but not by the compiler. – LeFish Mar 25 '20 at 17:54
  • Could you describe in detail exactly how you are compiling. I.e. what buttons you press, or menu options you choose or commands you type. – john Mar 25 '20 at 19:33
  • I think I have found a completely different approach: Conan Package Manager The only problem is, I don't know how to start. Would you guys kindly give me some boost please? I am a total beginner with this using MinGW g++ compiler right now. – LeFish Mar 26 '20 at 17:14

2 Answers2

1

Post was:

Your includePath says "C:\\Program Files\\ImageMagick-7.0.9-Q8\\include"

But the header files are in "C:\\Programme\\ImageMagick-7.0.9-Q8\\include"

Thanks, corrected that.

LeFish
  • 25
  • 4
john
  • 85,011
  • 4
  • 57
  • 81
  • You get today's *"Eagle-eyed Viewer Award"*! – Mark Setchell Mar 25 '20 at 09:13
  • Thank you for the suggestion. But even after fixing this, there is the same error on compiling. When I right-click on the #include line and hit "Go to definition" it atually opens the content of Magick++.h So Virtual Studio Code sees the library files. Just the compiler does not. – LeFish Mar 25 '20 at 15:12
  • @LeFish I'm not sure what to suggest as I don't know Visual Studio Code. Maybe you need to refresh the project somehow after correcting c_cpp_properties.json? You could always try recreating the project from scratch. – john Mar 25 '20 at 16:42
0

I finally have a solution.

I installed CMake and the CMake extension for VSCode.

According to this tutorial on youtube I got a functioning development environment.

To add an external library to the project I copied all the necessary files to an "include" folder within my project workspace. I made Cmake aware of this folder by the following CMakeLists.txt

cmake_minimum_required(VERSION 3.0)
project(IMHelloWorld VERSION 1.0.0)

add_executable(IMHelloWorld main.cpp)

include_directories(${PROJECT_SOURCE_DIR}/include)
LINK_DIRECTORIES(${PROJECT_SOURCE_DIR}/include)

After this I was able to compile the project with

cmake ..

and

cmake --build .

as described in the linked videos.

LeFish
  • 25
  • 4