문제

I have here a simple image converter code using Magick++(ImageMagick interface) library.(Eclipse IDE)

#include <Magick++.h>
#include <string>
#include <iostream>

using namespace std;

using namespace Magick;

int main(int argc,char **argv) 
{ 
    Image image; 
    image.read("/home/usr1/test.tiff");
    image.write( "/home/usr1/test.bmp" ); 
    return 0;
}

I'am doing a cross compilation with arm-linux target. The code compiles successfully but on the linking part, I got undefined reference errors.

/usr/local/lib/libMagick++/libMagickCore.a(dlopen.o)(.text+0x144): In function `vm_open':
ltdl/loaders/dlopen.c:194: undefined reference to `dlopen'
/usr/local/lib/libMagick++/libMagickCore.a(dlopen.o)(.text+0x158):ltdl/loaders/dlopen.c:198: undefined reference to `dlerror'
/usr/local/lib/libMagick++/libMagickCore.a(dlopen.o)(.text+0x16c): In function `vm_close':
ltdl/loaders/dlopen.c:212: undefined reference to `dlclose'
/usr/local/lib/libMagick++/libMagickCore.a(dlopen.o)(.text+0x17c):ltdl/loaders/dlopen.c:214: undefined reference to `dlerror'
/usr/local/lib/libMagick++/libMagickCore.a(dlopen.o)(.text+0x198): In function `vm_sym':
ltdl/loaders/dlopen.c:227: undefined reference to `dlsym'
/usr/local/lib/libMagick++/libMagickCore.a(dlopen.o)(.text+0x1ac):ltdl/loaders/dlopen.c:231: undefined reference to `dlerror'

I used the following command to compile the code:

/opt/Mx800SDK/vfitc/cross/bin/arm-linux-g++ -DMx870 -I/opt/Mx800SDK/vfitc/cross/arm-linux/include -I/usr/local/include/ImageMagick -I/opt/Mx800SDK/include -O2 -Wall -c -fmessage-length=0 -fno-strict-aliasing -o'main.o' '../main.cpp'

and to link:

/opt/Mx800SDK/vfitc/cross/bin/arm-linux-g++ -L/opt/Mx800SDK/lib -L/usr/local/lib/libMagick++ -o'imgConverter' ./main.o -lpthread -lMagick++ -lMagickWand -lMagickCore -ltiff -lz

Is there any other library I need to link it successfully? Am I linking it right? Thanks in advance.

도움이 되었습니까?

해결책

Try inverting the Magick libraries, add the MagickWand library (and put libz and other base image libraries at the end, and the dynamic linker library while you're at it):

... -lpthread -lMagick++ -lMagickWand -lMagickCore -lz -ldl

See Linker Order - GCC for why the order of static libraries matters.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top