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

5
  • If you are using the C++ binding to ImageMagick, you should use the magick++ tag to attract the correct people. Commented Mar 25, 2020 at 9:11
  • This may be the solution...stackoverflow.com/a/18068069/2836621 Commented Mar 25, 2020 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. Commented Mar 25, 2020 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. Commented Mar 25, 2020 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. Commented Mar 26, 2020 at 17:14

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

You get today's "Eagle-eyed Viewer Award"!
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 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.
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.