Makefile如下:
.PHONY: all clean
all : backtrace.dll test.exe
backtrace.dll : backtrace.c
gcc -O2 -shared -Wall -o $@ $^ -lbfd -liberty -limagehlp --verbose
test.exe : test.c
gcc -g -Wall -o $@ $^
clean :
-del -f backtrace.dll test.exe
源代码backtrace.c
是一个允许您在C中获取堆栈跟踪的库。详细信息在谷歌代码上:http://code.google.com/p/backtrace-mingw/
当我使用命令时:
mingw32-make
我收到错误消息:
gcc -O2 -shared -Wall -o backtrace.dll backtrace.c -lbfd -liberty -limagehlp
C:/MinGW/lib/libbfd.a(libbfd.o):libbfd.c:(.text+0x6ee)锛氬鈥榣ibintl_dgettext
鈥欐湭瀹氫箟鐨勫紩鐢
C:/MinGW/lib/libbfd.a(libbfd.o):libbfd.c:(.text+0x740)锛氬鈥榣ibintl_dgettext
鈥欐湭瀹氫箟鐨勫紩鐢
C:/MinGW/lib/libbfd.a(libbfd.o):libbfd.c:(.text+0x79b)锛氬鈥榣ibintl_dgettext
鈥欐湭瀹氫箟鐨勫紩鐢
C:/MinGW/lib/libbfd.a(libbfd.o):libbfd.c:(.text+0x7d0)锛氬鈥榣ibintl_dgettext
鈥欐湭瀹氫箟鐨勫紩鐢
C:/MinGW/lib/libbfd.a(bfd.o):bfd.c:(.text+0x8fd)锛氬鈥榣ibintl_dgettext鈥欐湭
瀹氫箟鐨勫紩鐢
C:/MinGW/lib/libbfd.a(bfd.o):bfd.c:(.text+0x964): more undefined references to `
libintl_dgettext' follow
collect2: ld returned 1 exit status
mingw32-make: *** [backtrace.dll] Error 1
如何解决此错误?
答案 0 :(得分:1)
您必须添加对libintl库的引用,以便您的链接行变为:
gcc -O2 -shared -Wall -o $@ $^ -lbfd -liberty -limagehlp -lintl --verbose