2014-02-11 56 views
0

我想编译一个名为Contrafold的程序,我需要两个库(libgd和libpng),问题是链接库,但它通过我一个未定义的引用错误,我不知道为什么....我的代码编译为后续:未定义的引用gdImageString

g++ -O3 -DNDEBUG -W -pipe -Wundef -Winline --param large-function-growth=100000 -Wall EncapsulatedPostScript.o PlotRNA.o SStruct.o Utilities.o -o plot_rna -lm -L/path-to-library/libgd.a -L/path-to-library/libpng16.a 

,并且错误是:

PlotRNA.cpp:(.text+0x189e): undefined reference to `gdImageString' 
PlotRNA.cpp:(.text+0x1a34): undefined reference to `gdImageFilledArc' 
PlotRNA.cpp:(.text+0x1a79): undefined reference to `gdImageSetAntiAliased' 
PlotRNA.cpp:(.text+0x1ad6): undefined reference to `gdImageChar' 
PlotRNA.cpp:(.text+0x1c76): undefined reference to `gdImageLine' 
PlotRNA.cpp:(.text+0x1fce): undefined reference to `gdImageString' 
PlotRNA.cpp:(.text+0x2036): undefined reference to `gdImageCreateTrueColor' 
PlotRNA.cpp:(.text+0x2079): undefined reference to `gdImageColorAllocate' 
PlotRNA.cpp:(.text+0x2093): undefined reference to `gdImageColorAllocate' 
PlotRNA.cpp:(.text+0x213a): undefined reference to `gdImageColorAllocate' 
PlotRNA.cpp:(.text+0x217d): undefined reference to `gdImageFilledRectangle' 
PlotRNA.cpp:(.text+0x2182): undefined reference to `gdFontGetMediumBold' 
PlotRNA.cpp:(.text+0x218f): undefined reference to `gdFontGetSmall' 
PlotRNA.cpp:(.text+0x223b): undefined reference to `gdImagePng' 
PlotRNA.cpp:(.text+0x2250): undefined reference to `gdImageDestroy' 

任何选项?

回答

0

也许你忘了添加含GD *函数库链接:-lgd

+0

如果我运行 G ++ -O3 -DNDEBUG -W -pipe -Wundef -Winline --param大函数增长= 100000 - Wall EncapsulatedPostScript.o Plot RNA.o SStruct.o Utilities.o -o plot_rna -lm -lgd -L/path-to-library/libgd.a -L/path-to-library/libpng16.a 错误是: 在/ usr /斌/劳工处:找不到-lgd – user3191692

+0

-l参数不应包含库的名称 - 唯一的目录名 - 刚刚从好的-L参数 – user2699113

+0

删除libgd.a,现在我把这个 G ++ -O3 - DNDEBUG -W -pipe -Wundef -Winline - 参数ge-function-growth = 100000 -Wall EncapsulatedPostScript.o Plot RNA.o SStruct.o Utilities.o -o plot_rna -lm -lgd -L/path-to-library/libgd/-lpng -L/path-to-library /的libpng/ 和错误是 的/ usr /斌/劳工处:找不到-lpng 但在我的libpng有libpng.a – user3191692