代码来源:
http://www.cppblog.com/qiujian5628/archive/2008/06/19/54019.aspx
出现的几个问题的解决:
问题1:
fatal error C1010: unexpected end of file while looking for precompiled header directive
解决: (http://www.china-askpro.com/msg24/qa08.shtml)
方法一:肯定是一个新添加的类的.cpp文件开头没包含stdafx.h,在该文件最前面加上即可。(这里是项目中新添加进来的借个文件)
方法二:有时可以使用右键点击项目工程中的该cpp文件,选择setting,在c/c++栏,选择PreCompiled headers,然后设置第一选项,选择不使用预编译头,解决这个问题。(还是这个方法好)
问题2:
error LNK2005: "int __cdecl soap_serve(struct soap *)" (?soap_serve@@$$FYAHPAUsoap@@@Z) already defined in soapServer.obj
error LNK2005: "int __cdecl soap_serve(struct soap *)" (?soap_serve@@YAHPAUsoap@@@Z) already defined in soapServer.obj
error LNK2005: "int __cdecl soap_serve_ns__add(struct soap *)" (?soap_serve_ns__add@@$$FYAHPAUsoap@@@Z) already defined in soapServer.obj
error LNK2005: "int __cdecl soap_serve_ns__add(struct soap *)" (?soap_serve_ns__add@@YAHPAUsoap@@@Z) already defined in soapServer.obj
error LNK2005: "int __cdecl soap_serve_request(struct soap *)" (?soap_serve_request@@$$FYAHPAUsoap@@@Z) already defined in soapServer.obj
error LNK2005: "int __cdecl soap_serve_request(struct soap *)" (?soap_serve_request@@YAHPAUsoap@@@Z) already defined in soapServer.obj
fatal error LNK1169: one or more multiply defined symbols found
解决:
把soapServerLib.cpp等文件也添加到了工程中,产生重复定义的错误。你用gsoap生成服务器端 客户端的文件后 并不是把生成的所有文件都拷到工程中,而只是拷贝你所需要的文件到工程目录里,
问题3:
error LNK2001: unresolved external symbol "int __cdecl ns__add(struct soap *,int,int,int *)" (?ns__add@@YAHPAUsoap@@HHPAH@Z)
解决:
这是在clinet编译的时候遇到的问题,做法是将server的整个工程文件夹复制成一个新的文件夹,将原来server 中main函数那个文件的代码,换成client代码,编译时候出来了这个问题
//分析发现是, add.h这个文件应该被从项目中移除。
//分析发现是, soapServer.cpp这个文件应该被从项目中移除。
http://www.cppblog.com/qiujian5628/archive/2008/06/19/54019.aspx
内容复制到下面了: