[solved]successful build/compile using GCC/Ubuntu and Windows VS2015 CMD Prompt. but cant get IDE to build. Code::BLocks

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
josephaaroncampbell
Posts: 40
Joined: 2015-07-14T19:18:45-07:00
Authentication code: 1151
Location: Chicago, IL

[solved]successful build/compile using GCC/Ubuntu and Windows VS2015 CMD Prompt. but cant get IDE to build. Code::BLocks

Post by josephaaroncampbell » 2016-07-04T22:45:02-07:00

Hello,

So i can say I was successful in building/compiling a MagickWand script with VisualStudio 2015 Native Tools x64 Command Prompt as well as through the terminal in Ubuntu using gcc.

The GCC code from the MagickWand example page :http://www.imagemagick.org/script/magick-wand.php

Code: Select all

cc -o wand wand.c `pkg-config --cflags --libs MagickWand`
Can be converted to windows command line syntax as : (*must be entered into the VS2015 Native Tools CMD Prompt. Not the normal CMD.exe)

Code: Select all

cl -Fo:WandConvert /I C:\ImageMagick-7.0.2-2\ImageMagick wandTest.c /Link C:\ImageMagick-7.0.2-2\VisualMagick\lib\CORE_DB_MagickWand_.lib 
Maybe someone knows a better way to do it using this method but this works with out any errors.

However, what i will continue to try to figure out is that I cant get a basic MagickWand script to build in an IDE. I am using Code::Blocks because it is cross platform windows/ubuntu and on both OS's I get the same errors. I believe it has to do with properly linking the header and lib files.

Does anyone have any sources for properly setting up your environment when using MagickWand and an IDE ?

Thank You for your time.




My MagickWand code in file "wandTest.c":

Code: Select all

#include "MagickWand/MagickWand.h"

int main(int argc, char *argv[])
{
    MagickWand *newWand;

    MagickWandGenesis();

    newWand = NewMagickWand();

	MagickReadImage(newWand, "target.tif" );

	MagickWriteImage(newWand, "target.jpg" );

	if(newWand) DestroyMagickWand(newWand);

	void MagickWandTerminus(void);

	return 0;
}
In Code::Blocks I have the directory paths for the MagickWand headers and the 'Lib' directory defined in the 'Project -> Build Options -> Search Directories -> Compiler and Link options (respectively) so the compiler will search for the files in those locations. but I get these errors:
-------------- Build: Debug in wandTest (compiler: GNU GCC Compiler)---------------

gcc -Wall -g -I/usr/local/include/ImageMagick-7/ -I/usr/local/include/ImageMagick-7/ -c /home/joseph/Desktop/Magick/cBlocks/wandTest/main.c -o obj/Debug/main.o
In file included from /usr/local/include/ImageMagick-7/MagickWand/MagickWand.h:29:0,
from /home/joseph/Desktop/Magick/cBlocks/wandTest/main.c:1:
/usr/local/include/ImageMagick-7/MagickCore/magick-config.h:29:3: warning: #warning "you should set MAGICKCORE_QUANTUM_DEPTH to sensible default set it to configure time default" [-Wcpp]
# warning "you should set MAGICKCORE_QUANTUM_DEPTH to sensible default set it to configure time default"
^
/usr/local/include/ImageMagick-7/MagickCore/magick-config.h:30:3: warning: #warning "this is an obsolete behavior please fix your makefile" [-Wcpp]
# warning "this is an obsolete behavior please fix your makefile"
^
/usr/local/include/ImageMagick-7/MagickCore/magick-config.h:52:3: warning: #warning "you should set MAGICKCORE_HDRI_ENABLE to sensible default set it to configure time default" [-Wcpp]
# warning "you should set MAGICKCORE_HDRI_ENABLE to sensible default set it to configure time default"
^
/usr/local/include/ImageMagick-7/MagickCore/magick-config.h:53:3: warning: #warning "this is an obsolete behavior please fix yours makefile" [-Wcpp]
# warning "this is an obsolete behavior please fix yours makefile"
^
g++ -L/usr/local/lib -L/usr/local/lib -o bin/Debug/wandTest obj/Debug/main.o
obj/Debug/main.o: In function `main':
/home/joseph/Desktop/Magick/cBlocks/wandTest/main.c:7: undefined reference to `MagickWandGenesis'
/home/joseph/Desktop/Magick/cBlocks/wandTest/main.c:9: undefined reference to `NewMagickWand'
/home/joseph/Desktop/Magick/cBlocks/wandTest/main.c:11: undefined reference to `MagickReadImage'
/home/joseph/Desktop/Magick/cBlocks/wandTest/main.c:13: undefined reference to `MagickWriteImage'
/home/joseph/Desktop/Magick/cBlocks/wandTest/main.c:15: undefined reference to `DestroyMagickWand'
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
5 error(s), 4 warning(s) (0 minute(s), 0 second(s))
I stalled from source on both Windows 10 x64 and Ubuntu 14.04 x64

Version: ImageMagick 7.0.2-2 Q16 x64 2016-07-03 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Visual C++: 190023918
Features: Debug Cipher DPC HDRI Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib
Last edited by josephaaroncampbell on 2016-07-04T22:59:14-07:00, edited 1 time in total.

josephaaroncampbell
Posts: 40
Joined: 2015-07-14T19:18:45-07:00
Authentication code: 1151
Location: Chicago, IL

Re: successful build/compile using GCC/Ubuntu and Windows VS2015 CMD Prompt. but cant get IDE to build. Code::BLocks

Post by josephaaroncampbell » 2016-07-04T22:58:47-07:00

So I randomly tried something I tried earlier today from this resource on the code::blocks wiki that gave details about third party #include files:
http://wiki.codeblocks.org/index.php/FA ... ty_libs.3F

I needed to also goto Project -> Build Options -> Linker Settings : and then add BOTH the '.so' library files for MagickWand and MagickCore. Doing this the program compiles with no errors. Earlier I only added the MagickWand '.so' library and it didnt work.

If anyone knows of any explanations or other resources for setting up the best environment for MagickWand I am still learning and could use that info.

Thank You.

Post Reply