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'
任何選項?
如果我運行 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
-l參數不應包含庫的名稱 - 唯一的目錄名 - 剛剛從好的-L參數 – user2699113
刪除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