7

It has been over 4 hours since I made any progress at all, and searched documentation and links and frankly I'm out of ideas. So here goes.

Background

  • I am compiling a C++ program in command prompt
  • I am new to command prompt and fairly new to c++
  • I am writing this program in Notepad++ (not VS) but have VS installed so I can compile
  • I am trying to utilize ImageMagick through Magick++, a C++ API wrapper for it.
  • Main program directory
    • C:/Program Files (x86)/CameraSoftware/myCameraProgram.cpp
  • Magick++ directory
    • C:/Program Files (x86)/ImageSoftware/Magick++/lib/Magick.h

Issues

  • I am trying to use the Magick++ API and so I want to include it
  • I am just using this in the .cpp file #include <Magick++.h>
  • I've messed around with numerous solutions that has worked for others but to no avail
    • fatal error C1083: Cannot open include file: 'Magick++.h': No such file or directory

Problem

  • How do I correctly compile and link to 'Magick++.h' correctly through command prompt?
  • Currently it is compiled as such
    • cl myCameraProgram.cpp /EHsc /link DSLRRemoteLib.lib
    • DSLRRemoteLib is a lib file located in the same directory and /EHsc and /link is required for it to function

Other solutions

  • For visual studio projects, I believe you can add external directory paths to the project with some play around with the configurations, but I do not have that luxury using notepad++, so I really need to know how to compile this properly
  • I have tried hard coding in myCameraProgram.cpp #include "COMPLETE_DIR_PATH/Magick++.h" and it will compile, but Magick++.h has more includes within it(eg #include <Magick++/Include.h>), and it will bring up C1083 error for each of the header files.
    • I've also tried hard coding the filepaths within Magick++.h and same problems with the next level of header files. So this not a solution.
    • I've also tried to tack on an additional argument to the /link the file in the compile line
    • cl myCameraProgram.cpp /EHsc /link DSLRRemote "COMPLETE_DIR_PATH/Magick++.h" but doesnt work
    • Also tried cl myCameraProgram.cpp /EHsc /link DSLRRemote /l "COMPLETE_DIR_PATH/Magick++.h"
    • Along with multiple failed attempts.

Any help or advice or direction will be vastly appreciated, thanks!

======== EDIT ========

Thanks for the tips everyone.

  • Using /I "C:\Users\ME\Documents\ImageMagick-6.8.1-10\Magick++\lib" I could link the #include "Magick++.h" successfully, but it doesn't look anywhere else for other files.
  • It cant find #include which is in a subdirectory path "C:\Users\ME\Documents\ImageMagick-6.8.1-10\Magick++\lib\Magic++\Include.h".
  • "Magick++/Include.h" also makes a reference to another subdirectory in the parent directory.

Progress

  • My current command prompt compile line is:
  • cl "C:\Users\ME\Documents\ImageMagick-6.8.1-10\Magick++\lib"
  • Finds "Magick++.h"

Issue

  • "Magick++.h" is a header file that includes 4 headers
  • Upon compiling, it cannot find the other files which is in a subdirectory
  • Is there a way to link ALL subdirectories and files under the path
  • "C:\Users\ME\Documents\ImageMagick-6.8.1-10" in a compile by any chance?
Andrea
  • 11,801
  • 17
  • 65
  • 72
Luffy
  • 401
  • 5
  • 10
  • 4
    You need to use the [`/I` option](http://msdn.microsoft.com/en-us/library/73f9s62w.aspx) to tell the compiler where the header files are located. The argument is the _directory_ where the header files are located. – Some programmer dude Mar 20 '13 at 07:23
  • Also, Program Files is probably not the best place to put files you're editing. Consider using something under your user directory. – Peter Huene Mar 20 '13 at 07:25
  • Hi I have tried moving my directory and also compiling now with - cl myCameraProgram.cpp /EHsc /link DSLRRemoteLib.lib /I "C:\Users\ME\Documents\ImageMagick-6.8.1-10\Magick++\lib" (copied and pasted, shouldnt be wrong) - But no avail – Luffy Mar 20 '13 at 07:30
  • @Luffy: put the `/I` option before the `/link` option, otherwise it gets passed to the linker (as the docs say, "The /link option and its linker options must appear after any file names and CL options"). – Michael Burr Mar 20 '13 at 07:33
  • So try `cl /I "C:\Users\ME\Documents\ImageMagick-6.8.1-10\Magick++\lib" myCameraProgram.cpp /EHsc DSLRRemoteLib.lib` (note: you don't need the `/link` option to pass a .lib file to the linker - the `cl` command knows that a .lib file is an input to the linker) – Michael Burr Mar 20 '13 at 07:36
  • Hi @Michael, thanks for the tip. Using /I "C:\Users\ME\Documents\ImageMagick-6.8.1-10\Magick++\lib" I could link the #include successfully, but it doesn't look anywhere else for other files, and it cant find #include which is in a subdirectory path "C:\Users\ME\Documents\ImageMagick-6.8.1-10\Magick++\lib\Magic++\Include.h". also makes a reference to another subdirectory in the parent directory. Is there a way to link ALL subdirectories and files under the path "C:\Users\ME\Documents\ImageMagick-6.8.1-10" in a compile by any chance? – Luffy Mar 20 '13 at 22:28

1 Answers1

-4
sudo apt-get install libmagickwand-dev imagemagick
sudo apt-get install libmagick++-dev libmagick++4
Smern
  • 18,746
  • 21
  • 72
  • 90
YBLin
  • 16