Page 1 of 1

Not able to compile with Microsoft Visual Studio C++ 2008

Posted: 2008-07-25T08:22:41-07:00
by imagetester
Hi i'm not able to compile any single code you've written using #include "wand/MagickWand.h"
How can i fix this status

Re: Not able to compile with Microsoft Visual Studio C++ 2008

Posted: 2008-07-25T22:43:38-07:00
by mkoppanen
Please post the error messages you get. It is impossible to help you without knowing what goes wrong.

Re: Not able to compile with Microsoft Visual Studio C++ 2008

Posted: 2008-07-26T00:46:15-07:00
by imagetester
Here's a code from :

#include <stdio.h>
#include <stdlib.h>
#include <wand/MagickWand.h>

int main(int argc,char **argv)
{
#define ThrowWandException(wand) \
{ \
char \
*description; \
\
ExceptionType \
severity; \
\
description=MagickGetException(wand,&severity); \
(void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); \
description=(char *) MagickRelinquishMemory(description); \
exit(-1); \
}

MagickBooleanType
status;

MagickWand
*magick_wand;

if (argc != 3)
{
(void) fprintf(stdout,"Usage: %s image thumbnail\n",argv[0]);
exit(0);
}
/*
Read an image.
*/
MagickWandGenesis();
magick_wand=NewMagickWand();
status=MagickReadImage(magick_wand,argv[1]);
if (status == MagickFalse)
ThrowWandException(magick_wand);
/*
Turn the images into a thumbnail sequence.
*/
MagickResetIterator(magick_wand);
while (MagickNextImage(magick_wand) != MagickFalse)
MagickResizeImage(magick_wand,106,80,LanczosFilter,1.0);
/*
Write the image then destroy it.
*/
status=MagickWriteImages(magick_wand,argv[2],MagickTrue);
if (status == MagickFalse)
ThrowWandException(magick_wand);
magick_wand=DestroyMagickWand(magick_wand);
MagickWandTerminus();
return(0);
}


I've compiled this code and got:
1>------ Build started: Project: button, Configuration: Release Win32 ------
1>Compiling...
1>seg.cpp
1>MagickWand lib DLL import interface
1>MagickWand module DLL export interface
1>Magick lib DLL import interface
1>Magick module DLL export interface
1>Linking...
1>seg.obj : error LNK2019: unresolved external symbol __imp__MagickWandTerminus referenced in function _main
1>seg.obj : error LNK2019: unresolved external symbol __imp__DestroyMagickWand referenced in function _main
1>seg.obj : error LNK2019: unresolved external symbol __imp__MagickWriteImages referenced in function _main
1>seg.obj : error LNK2019: unresolved external symbol __imp__MagickResizeImage referenced in function _main
1>seg.obj : error LNK2019: unresolved external symbol __imp__MagickNextImage referenced in function _main
1>seg.obj : error LNK2019: unresolved external symbol __imp__MagickResetIterator referenced in function _main
1>seg.obj : error LNK2019: unresolved external symbol __imp__MagickRelinquishMemory referenced in function _main
1>seg.obj : error LNK2019: unresolved external symbol __imp__MagickGetException referenced in function _main
1>seg.obj : error LNK2019: unresolved external symbol __imp__MagickReadImage referenced in function _main
1>seg.obj : error LNK2019: unresolved external symbol __imp__NewMagickWand referenced in function _main
1>seg.obj : error LNK2019: unresolved external symbol __imp__MagickWandGenesis referenced in function _main
1>./button.exe : fatal error LNK1120: 11 unresolved externals
1>Build log was saved at "file://c:\Program Files\ImageMagick-6.4.2-Q16\Magick++_Demo\Release\button\BuildLog.htm"
1>button - 12 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 7 up-to-date, 0 skipped ==========

I'm using 'ImageMagick-6.4.2-3-Q16-windows-dll.exe' do I need anything else?!

Re: Not able to compile with Microsoft Visual Studio C++ 2008

Posted: 2008-07-26T08:05:28-07:00
by el_supremo
You need to modify the project so that the compiler finds the include files and the linker finds the library files.

In Visual Studio, right click on the project name and select Properties and then modify the following options:
- In C/C++|General: In "Additional Include Directories" add the path to your include directory - something like "C:\Program Files\ImageMagick-6.4.2-Q8\include"
- In Linker|General: Add the additional library directory C:\Program Files\ImageMagick-6.4.2-Q8\lib
- In Linker|Input: Add the Additional Dependencies CORE_RL_magick_.lib CORE_RL_wand_.lib
and if you're using C++ also add CORE_RL_Magick++_.lib

Pete

Re: Not able to compile with Microsoft Visual Studio C++ 2008

Posted: 2008-07-27T04:35:14-07:00
by imagetester
Thanks Pete that helped!

But is there a way to make it general instead of repeating this action on every project?!
I tried to modify the environment variables under "My computer Properties" but i t was unsuccessful !

I 've added to the system vars: Include, lib and even path

Re: Not able to compile with Microsoft Visual Studio C++ 2008

Posted: 2008-07-27T12:13:37-07:00
by el_supremo
But is there a way to make it general instead of repeating this action on every project?!
I'd like to know that too. I tried setting the include path in the INCLUDE environment variable, made sure it had changed by opening a command window and typing "echo %INCLUDE%" and verifying that it was indeed the new value. Then I opened MSVC again and rebuilt the project and it can't find wand/magick_wand.h - there's no problem if I set the path in Additional Include Directories.
I would also like to know how you initially set values which are shown in the project as inherited values. For example, if you open Linker|input|Additional Dependencies there is a tickbox labelled "Inherit from Project Defaults". I've never been able to find out how you put something in that list of inherited lib files. I have one project where that list contains "winspool.lib" so I used Ultraedit to search for the string "winspool" in the project directory's parent and everything below it. The only file that contains that string is vc70.idb. If I delete that file and reopen msvc, it still knows about winspool, so that file isn't where it's getting it from.

Is there an MSVC guru who can explain these mysteries?

Pete