现在我正在编写一个程序来调用网络服务。我编写testMain.c。其他由 wsdl2h
和 soapcpp2
生成。
我的编译命令是这样的:
gcc -Wall -g -c -L. soapC.c soapClient.c stdsoap2.c testMain.c
gcc -o testMain -L/usr/lib -lgsoap -lgsoapck -lgsoapssl soapC.o soapClient.o stdsoap2.o testMain.o
我收到这些错误。请帮我。
stdsoap2.o: In function `soap_print_fault':
/test/stdsoap2.c:16279: undefined reference to `soap_check_faultsubcode'
/test/stdsoap2.c:16281: undefined reference to `soap_check_faultdetail'
stdsoap2.o: In function `soap_sprint_fault':
/test/stdsoap2.c:16341: undefined reference to `soap_check_faultdetail'
collect2: ld returned 1 exit status
最佳答案
最新版本的 GCC/ld/GNU 工具链要求以一定的顺序指定对象和库文件,以便链接器可以按照它们相互依赖的相同顺序找到符号。这意味着库应该位于命令行的末尾;你的第二行(当你链接时)应该是
gcc -o testMain -L/usr/lib soapC.o soapClient.o stdsoap2.o testMain.o -lgsoap -lgsoapck -lgsoapssl
相反。
关于c - gsoap 客户端编译/链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14097603/