我尝试使用gcc在Mac OS X上编译C程序。但是,我收到了错误消息: clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)。
尽管我已经阅读了一些类似的问题,但仍然找不到解决方案。任何帮助将不胜感激。
ncl-kaist:intro vietan$ make -n
gcc -I../lib -g -O2 -D_REENTRANT -Wall -o daytimetcpcli daytimetcpcli.o ../libunp.a -lresolv -lpthread
gcc -I../lib -g -O2 -D_REENTRANT -Wall -c -o daytimetcpcli1.o daytimetcpcli1.c
gcc -I../lib -g -O2 -D_REENTRANT -Wall -o daytimetcpcli1 daytimetcpcli1.o ../libunp.a -lresolv -lpthread
gcc -I../lib -g -O2 -D_REENTRANT -Wall -c -o daytimetcpcli2.o daytimetcpcli2.c
gcc -I../lib -g -O2 -D_REENTRANT -Wall -o daytimetcpcli2 daytimetcpcli2.o ../libunp.a -lresolv -lpthread
gcc -I../lib -g -O2 -D_REENTRANT -Wall -c -o daytimetcpcli3.o daytimetcpcli3.c
gcc -I../lib -g -O2 -D_REENTRANT -Wall -o daytimetcpcli3 daytimetcpcli3.o ../libunp.a -lresolv -lpthread
gcc -I../lib -g -O2 -D_REENTRANT -Wall -c -o daytimetcpsrv.o daytimetcpsrv.c
gcc -I../lib -g -O2 -D_REENTRANT -Wall -o daytimetcpsrv daytimetcpsrv.o ../libunp.a -lresolv -lpthread
gcc -I../lib -g -O2 -D_REENTRANT -Wall -c -o daytimetcpsrv1.o daytimetcpsrv1.c
gcc -I../lib -g -O2 -D_REENTRANT -Wall -o daytimetcpsrv1 daytimetcpsrv1.o ../libunp.a -lresolv -lpthread
gcc -I../lib -g -O2 -D_REENTRANT -Wall -c -o daytimetcpsrv2.o daytimetcpsrv2.c
gcc -I../lib -g -O2 -D_REENTRANT -Wall -o daytimetcpsrv2 daytimetcpsrv2.o ../libunp.a -lresolv -lpthread
gcc -I../lib -g -O2 -D_REENTRANT -Wall -c -o daytimetcpsrv3.o daytimetcpsrv3.c
gcc -I../lib -g -O2 -D_REENTRANT -Wall -o daytimetcpsrv3 daytimetcpsrv3.o ../libunp.a -lresolv -lpthread
gcc -I../lib -g -O2 -D_REENTRANT -Wall -c -o daytimetcpcliv6.o daytimetcpcliv6.c
gcc -I../lib -g -O2 -D_REENTRANT -Wall -o daytimetcpcliv6 daytimetcpcliv6.o ../libunp.a -lresolv -lpthread
gcc -I../lib -g -O2 -D_REENTRANT -Wall -c -o daytimetcpsrvv6.o daytimetcpsrvv6.c
gcc -I../lib -g -O2 -D_REENTRANT -Wall -o daytimetcpsrvv6 daytimetcpsrvv6.o ../libunp.a -lresolv -lpthread
gcc -I../lib -g -O2 -D_REENTRANT -Wall -c -o byteorder.o byteorder.c
gcc -I../lib -g -O2 -D_REENTRANT -Wall -o byteorder byteorder.o ../libunp.a -lresolv -lpthread
ncl-kaist:intro vietan$ make
gcc -I../lib -g -O2 -D_REENTRANT -Wall -o daytimetcpcli daytimetcpcli.o ../libunp.a -lresolv -lpthread
ld: warning: ignoring file ../libunp.a, file was built for archive which is not the architecture being linked (x86_64): ../libunp.a
Undefined symbols for architecture x86_64:
"_err_quit", referenced from:
_main in daytimetcpcli.o
"_err_sys", referenced from:
_main in daytimetcpcli.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [daytimetcpcli] Error 1