James
James

Reputation: 553

Linking error gsoap in mac in c

I try to add gsoap in my application. I built gsoap for i386. Created c code with under commands:

wsdl2h -c -s -o soap.h soap.wsdl 
soapcpp2 -c -C soap.h

I got files. After this I tried to include these to my app. I added to my project in xCode. Also I added 6 libraries(libgsoap.a,libgsoap++.a,libgsoapck.a, libgsoapck++.a, libgsoapssl.a, libgsoapssl++.a). I added libraries in Target => Build phases => Link binary with libraries. But I got error....

ld: duplicate symbol .....

I thought it happened cause in file soapClientLib.c was it:

#ifndef WITH_NOGLOBAL
#define WITH_NOGLOBAL
#endif
#define SOAP_FMAC3 static
#include "soapC.c"
#include "soapClient.c"

Comments for these was:

Use this file in your project build instead of the two files soapC.c and soapClient.c. This hides the serializer functions and avoids linking problems when linking multiple clients and servers

I removed it content. But after this I got next error...

Undefined symbols for architecture i386:
  "_namespaces", referenced from:
      _soap_init_LIBRARY_VERSION_REQUIRED_20812 in libgsoap.a(libgsoap_a-stdsoap2.o)
     (maybe you meant: _soap_set_namespaces, _soap_set_local_namespaces )
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

And Now I have no idea... I used gsoap in windows and I added it to my project for 5 minutes. But I wasted much time to add it in mac os. Can you help me?

Upvotes: 3

Views: 2085

Answers (3)

FreeNickname
FreeNickname

Reputation: 7764

I know, that this is an old question, but I've just spent an entire evening figuring this out.

Here is a quote from this conversation (another link):

The soapcpp2-generated xyz.nsmap file should be #include'd in your code. It contains a global XML namespace mapping (or binding) table.

The reason for including this separately is that there are scenarios where the namespace mapping table is customized or shared.

For instance, I used a C++ classes, generated with soapcpp2 -i <my_header.h>. One of generated files is a <my_service_name>Service.cpp. To get rid of the _namespaces issue I had to #include "<my_service_name>.nsmap" in it.

As for the soapClientLib.c, I's like to quote that conversation again:

Please do not use soapClientLib.c in your build unless you want to combine multiple separately-generated clients/server codes. This means that the soapClientLib.c do not include the shared serializers for SOAP headers and faults.

Upvotes: 1

Anton K
Anton K

Reputation: 4798

This problem can be solved with changing compiler filename from gcc to g++.

GCC:

gcc calcmain.cpp soapC.cpp soapcalcProxy.cpp  -I/opt/local/include -lgsoap++ -L/opt/local/lib
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

G++:

g++ calcmain.cpp soapC.cpp soapcalcProxy.cpp  -I/opt/local/include -lgsoap++ -L/opt/local/lib
All OK

Yet you can make it compilable under gcc, with adding an gcc option -lstdc++:

gcc calcmain.cpp soapC.cpp soapcalcProxy.cpp  -I/opt/local/include -lgsoap++ -L/opt/local/lib -lstdc++
All OK

Upvotes: 0

James
James

Reputation: 553

I resolved my problem! I had to do ./configure with keys --disable-namespaces. Thank you. But I steal don't understand sense of the file soapClientLib.c.

Upvotes: 2

Related Questions