我已經成功編譯了一個由GCC在Mac上編譯的C程序,其中GD2庫直接從源代碼安裝。現在我要做的是通過使用MacPorts安裝GD2庫,並有以下錯誤信息:GCC編譯C程序問題,通過MacPorts安裝GD2庫
plotgeometry.c:5:16: error: gd.h: No such file or directory
plotgeometry.c: In function 'PlotGeometry':
plotgeometry.c:28: error: 'gdImagePtr' undeclared (first use in this function)
plotgeometry.c:28: error: (Each undeclared identifier is reported only once
plotgeometry.c:28: error: for each function it appears in.)
plotgeometry.c:28: error: expected ';' before 'im'
plotgeometry.c:29: warning: ISO C90 forbids mixed declarations and code
plotgeometry.c:748: error: 'im' undeclared (first use in this function)
plotgeometry.c:748: warning: implicit declaration of function 'gdImageCreate'
plotgeometry.c:752: warning: implicit declaration of function 'gdImageColorAllocate'
plotgeometry.c:780: warning: implicit declaration of function 'gdImageSetPixel'
plotgeometry.c:801: warning: implicit declaration of function 'gdImagePng'
plotgeometry.c:809: warning: implicit declaration of function 'gdImageDestroy'
我想,我需要提供路徑GD2庫GCC。該gd.h
在以下迪爾斯
$ find /opt/local/ -name 'gd.h'
/opt/local//include/gd.h
/opt/local//var/macports/software/gd2/2.0.35_7/opt/local/include/gd.h
我已經加入/opt/local/include
我$PATH
變量中找到,但我以前不幫助。我是否需要將具有該路徑的其他參數傳遞給GCC? 你能幫我解決嗎?
謝謝,馬塞洛!如果我將'CFLAGS + ='-I/opt/local/include''添加到'Makefile',然後編譯'plotgeometry.c'。但是在收集過程中有一個問題:'ld:library找不到-lgd' – Andrei 2010-07-21 13:13:48
'/ opt/local/lib'中是否有一系列'libgd *'文件?你還添加了'LDFLAGS'前綴嗎? (根據錯誤信息,你可能不需要'LDLIBS'。) – 2010-07-21 13:16:29
好吧,對不起,它在我閱讀所有答案後有效! – Andrei 2010-07-21 13:17:11