3

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?

James
  • 523
  • 4
  • 19
  • I didn't write it. It was generated by gsoap. I removed it. But now I have another error – James Jan 02 '13 at 07:09
  • 1
    If that is what was generated then you shouldn't have removed it. Are you sure you should link with **all** those libraries? I use gsoap at work (so I know how crap it is) and I'm sure we don't link with all of those libraries... – trojanfoe Jan 02 '13 at 08:13
  • I have similar issue with gsoap. I'm tring to compile using gcc but got linker error "Undefined symbols for architecture x86_64:" Command I used: gcc -o tdc_send_sms tdc_send_sms.c -L/usr/local/lib/ -lgsoap – Pritesh Acharya Apr 16 '13 at 06:04

3 Answers3

2

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.

James
  • 523
  • 4
  • 19
1

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.

FreeNickname
  • 7,398
  • 2
  • 30
  • 60
  • 1
    This is absolutely the correct answer; don't forget to `#include "whatever.nsmap"` in your source! – nutjob Oct 10 '22 at 21:25
0

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
Anton K
  • 4,658
  • 2
  • 47
  • 60