2013-10-10 53 views
0

我試圖建立一種依靠GraphicsMagick工具C++庫中的小工具程序,但鏈接到庫時,我得到了以下錯誤:無法鏈接到GraphicsMagik

make all-recursive 
make[1]: Entering directory `/home/ale/sample' 
Making all in src 
make[2]: Entering directory `/home/ale/sample/src' 
g++ -g -O2 -o mysample mysample-a.o -L/usr/local/lib -lexiv2 -L/usr/local/lib -lGraphicsMagick++ -lGraphicsMagick  
/usr/local/lib/libGraphicsMagick.a(magick_libGraphicsMagick_la-png.o): In function `png_put_data': 
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:1171: undefined reference to `png_get_io_ptr' 
/usr/local/lib/libGraphicsMagick.a(magick_libGraphicsMagick_la-png.o): In function `PNGWarningHandler': 
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:1357: undefined reference to `png_error' 
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:1361: undefined reference to `png_get_error_ptr' 
/usr/local/lib/libGraphicsMagick.a(magick_libGraphicsMagick_la-png.o): In function `PNGErrorHandler': 
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:1338: undefined reference to `png_get_error_ptr' 
/usr/local/lib/libGraphicsMagick.a(magick_libGraphicsMagick_la-png.o): In function `png_get_data': 
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:1060: undefined reference to `png_get_io_ptr' 
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:1076: undefined reference to `png_warning' 
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:1077: undefined reference to `png_error' 
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:1067: undefined reference to `png_warning' 
/usr/local/lib/libGraphicsMagick.a(magick_libGraphicsMagick_la-png.o): In function `png_write_raw_profile': 
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:6243: undefined reference to `png_malloc' 
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:6253: undefined reference to `png_malloc' 
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:6254: undefined reference to `png_malloc' 
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:6281: undefined reference to `png_set_text' 
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:6282: undefined reference to `png_free' 
/home/ale/Downloads/GraphicsMagick-1.3.18/coders/png.c:6283: undefined reference to `png_free' 

爲什麼在/ usr庫/ local/lib是指GraphicsMagick源代碼(我已經構建並安裝)?

回答

0

錯誤說你也需要和libpng鏈接。

由於您已經使用調試符號構建了graphicsmagick,因此您的源代碼相關的錯誤非常具有描述性。在發佈版本中(或者如果您將調試符號從調試版本中剝離出來),您只會看到未定義的函數名稱,而沒有源代碼引用它們的使用位置。