Hello there! This is my first post to the cygwin mailing list. Hence, I hope, this is the right place to post my problem. It seems to be a mixture of packaging / compiling / linking / porting problem. However, I was thinking that starting in this list is more appropriate than in e.g. the packagers list. I would like to compile gsoap as a shared library to use it in another project (kopano-core). Please note that static linking works fine. However, I would like to achieve a shared library of gsoap. gsoap itself provides only static compilation. However, the major distributions deliver it as shared library. That's where I have started: gSoap: https://sourceforge.net/projects/gsoap2/ OpenSuse Patches for shared library: https://build.opensuse.org/package/show/home:mrbadguy/gsoap Please find my respective patches plus cygport package attached to this mail. Unfortunately, the package does not build. In fact, it fails at linking the shared library due to undefined references. Please not that I have updated the OpenSuse patches by adding '-no-undefined' to the libtool chain. Further, I have added 'mcmodel=large' to the CFLAGS to work around relocation problems. Still, undefined references are found: make all-recursive make[1]: Entering directory '/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/build' Making all in . make[2]: Entering directory '/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/build' make[2]: Leaving directory '/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/build' Making all in gsoap make[2]: Entering directory '/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/build/gsoap' ln -s -f /home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8/gsoap/stdsoap2.cpp stdsoap2_cpp.cpp ln -s -f /home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8/gsoap/dom.cpp dom_cpp.cpp ln -s -f /home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8/gsoap/stdsoap2.cpp stdsoap2_ck.c ln -s -f /home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8/gsoap/stdsoap2.cpp stdsoap2_ck_cpp.cpp ln -s -f /home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8/gsoap/stdsoap2.cpp stdsoap2_ssl.c ln -s -f /home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8/gsoap/stdsoap2.cpp stdsoap2_ssl_cpp.cpp make all-recursive make[3]: Entering directory '/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/build/gsoap' Making all in . make[4]: Entering directory '/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/build/gsoap' /bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8/gsoap -I.. -D_GNU_SOURCE -Wno-attributes -mcmodel=large -DCYGWIN -ggdb -O2 -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -D_GNU_SOURCE -Wno-attributes -fdebug-prefix-map=/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/build=/usr/src/debug/gsoap-2.8.84-1 -fdebug-prefix-map=/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8=/usr/src/debug/gsoap-2.8.84-1 -MT libgsoap_la-stdsoap2.lo -MD -MP -MF .deps/libgsoap_la-stdsoap2.Tpo -c -o libgsoap_la-stdsoap2.lo `test -f 'stdsoap2.c' || echo '/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8/gsoap/'`stdsoap2.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8/gsoap -I.. -D_GNU_SOURCE -Wno-attributes -mcmodel=large -DCYGWIN -ggdb -O2 -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -D_GNU_SOURCE -Wno-attributes -fdebug-prefix-map=/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/build=/usr/src/debug/gsoap-2.8.84-1 -fdebug-prefix-map=/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8=/usr/src/debug/gsoap-2.8.84-1 -MT libgsoap_la-stdsoap2.lo -MD -MP -MF .deps/libgsoap_la-stdsoap2.Tpo -c /home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8/gsoap/stdsoap2.c -DDLL_EXPORT -DPIC -o .libs/libgsoap_la-stdsoap2.o /home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8/gsoap/stdsoap2.c: In function 'tcp_gethostbyname': /home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8/gsoap/stdsoap2.c:5074:10: warning: unused variable 'tmplen' [-Wunused-variable] size_t tmplen = sizeof(soap->tmpbuf); ^~~~~~ /home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8/gsoap/stdsoap2.c:5073:9: warning: unused variable 'tmpbuf' [-Wunused-variable] char *tmpbuf = soap->tmpbuf; ^~~~~~ /home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8/gsoap/stdsoap2.c:5072:7: warning: unused variable 'r' [-Wunused-variable] int r; ^ /home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8/gsoap/stdsoap2.c: In function 'soap_strerror': /home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8/gsoap/stdsoap2.c:22334:9: warning: assignment makes integer from pointer without a cast [-Wint-conversion] err = strerror_r(err, soap->msgbuf, sizeof(soap->msgbuf)); /* XSI-compliant */ ^ mv -f .deps/libgsoap_la-stdsoap2.Tpo .deps/libgsoap_la-stdsoap2.Plo /bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8/gsoap -I.. -D_GNU_SOURCE -Wno-attributes -mcmodel=large -DCYGWIN -ggdb -O2 -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -D_GNU_SOURCE -Wno-attributes -fdebug-prefix-map=/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/build=/usr/src/debug/gsoap-2.8.84-1 -fdebug-prefix-map=/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8=/usr/src/debug/gsoap-2.8.84-1 -MT libgsoap_la-dom.lo -MD -MP -MF .deps/libgsoap_la-dom.Tpo -c -o libgsoap_la-dom.lo `test -f 'dom.c' || echo '/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8/gsoap/'`dom.c libtool: compile: gcc -DHAVE_CONFIG_H -I. -I/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8/gsoap -I.. -D_GNU_SOURCE -Wno-attributes -mcmodel=large -DCYGWIN -ggdb -O2 -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -D_GNU_SOURCE -Wno-attributes -fdebug-prefix-map=/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/build=/usr/src/debug/gsoap-2.8.84-1 -fdebug-prefix-map=/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8=/usr/src/debug/gsoap-2.8.84-1 -MT libgsoap_la-dom.lo -MD -MP -MF .deps/libgsoap_la-dom.Tpo -c /home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8/gsoap/dom.c -DDLL_EXPORT -DPIC -o .libs/libgsoap_la-dom.o mv -f .deps/libgsoap_la-dom.Tpo .deps/libgsoap_la-dom.Plo /bin/sh ../libtool --tag=CC --mode=link gcc -mcmodel=large -DCYGWIN -ggdb -O2 -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -D_GNU_SOURCE -Wno-attributes -fdebug-prefix-map=/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/build=/usr/src/debug/gsoap-2.8.84-1 -fdebug-prefix-map=/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/src/gsoap-2.8=/usr/src/debug/gsoap-2.8.84-1 -release 2.8.84 -Wl,--version-script=gsoap.sym -no-undefined -o libgsoap.la -rpath /usr/lib libgsoap_la-stdsoap2.lo libgsoap_la-dom.lo libtool: link: gcc -shared .libs/libgsoap_la-stdsoap2.o .libs/libgsoap_la-dom.o -mcmodel=large -ggdb -O2 -fstack-protector-strong -Wl,--version-script=gsoap.sym -o .libs/cyggsoap-2-8-84.dll -Wl,--enable-auto-image-base -Xlinker --out-implib -Xlinker .libs/libgsoap.dll.a .libs/libgsoap_la-stdsoap2.o:stdsoap2.c:(.rdata$.refptr.soap_fault_detail[.refptr.soap_fault_detail]+0x0): undefined reference to `soap_fault_detail' .libs/libgsoap_la-stdsoap2.o:stdsoap2.c:(.rdata$.refptr.soap_fault_string[.refptr.soap_fault_string]+0x0): undefined reference to `soap_fault_string' .libs/libgsoap_la-stdsoap2.o:stdsoap2.c:(.rdata$.refptr.soap_fault_subcode[.refptr.soap_fault_subcode]+0x0): undefined reference to `soap_fault_subcode' .libs/libgsoap_la-stdsoap2.o:stdsoap2.c:(.rdata$.refptr.soap_putfault[.refptr.soap_putfault]+0x0): undefined reference to `soap_putfault' .libs/libgsoap_la-stdsoap2.o:stdsoap2.c:(.rdata$.refptr.soap_putheader[.refptr.soap_putheader]+0x0): undefined reference to `soap_putheader' .libs/libgsoap_la-stdsoap2.o:stdsoap2.c:(.rdata$.refptr.soap_serializefault[.refptr.soap_serializefault]+0x0): undefined reference to `soap_serializefault' .libs/libgsoap_la-stdsoap2.o:stdsoap2.c:(.rdata$.refptr.soap_serializeheader[.refptr.soap_serializeheader]+0x0): undefined reference to `soap_serializeheader' .libs/libgsoap_la-stdsoap2.o:stdsoap2.c:(.rdata$.refptr.soap_getfault[.refptr.soap_getfault]+0x0): undefined reference to `soap_getfault' .libs/libgsoap_la-stdsoap2.o:stdsoap2.c:(.rdata$.refptr.soap_getheader[.refptr.soap_getheader]+0x0): undefined reference to `soap_getheader' .libs/libgsoap_la-stdsoap2.o:stdsoap2.c:(.rdata$.refptr.namespaces[.refptr.namespaces]+0x0): undefined reference to `namespaces' .libs/libgsoap_la-stdsoap2.o:stdsoap2.c:(.rdata$.refptr.soap_faultdetail[.refptr.soap_faultdetail]+0x0): undefined reference to `soap_faultdetail' .libs/libgsoap_la-stdsoap2.o:stdsoap2.c:(.rdata$.refptr.soap_faultstring[.refptr.soap_faultstring]+0x0): undefined reference to `soap_faultstring' .libs/libgsoap_la-stdsoap2.o:stdsoap2.c:(.rdata$.refptr.soap_faultsubcode[.refptr.soap_faultsubcode]+0x0): undefined reference to `soap_faultsubcode' .libs/libgsoap_la-stdsoap2.o:stdsoap2.c:(.rdata$.refptr.soap_faultcode[.refptr.soap_faultcode]+0x0): undefined reference to `soap_faultcode' .libs/libgsoap_la-dom.o:dom.c:(.rdata$.refptr.soap_delelement[.refptr.soap_delelement]+0x0): undefined reference to `soap_delelement' .libs/libgsoap_la-dom.o:dom.c:(.rdata$.refptr.soap_dupelement[.refptr.soap_dupelement]+0x0): undefined reference to `soap_dupelement' .libs/libgsoap_la-dom.o:dom.c:(.rdata$.refptr.soap_getelement[.refptr.soap_getelement]+0x0): undefined reference to `soap_getelement' .libs/libgsoap_la-dom.o:dom.c:(.rdata$.refptr.soap_putelement[.refptr.soap_putelement]+0x0): undefined reference to `soap_putelement' .libs/libgsoap_la-dom.o:dom.c:(.rdata$.refptr.soap_markelement[.refptr.soap_markelement]+0x0): undefined reference to `soap_markelement' collect2: error: ld returned 1 exit status make[4]: *** [Makefile:574: libgsoap.la] Error 1 make[4]: Leaving directory '/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/build/gsoap' make[3]: *** [Makefile:797: all-recursive] Error 1 make[3]: Leaving directory '/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/build/gsoap' make[2]: *** [Makefile:501: all] Error 2 make[2]: Leaving directory '/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/build/gsoap' make[1]: *** [Makefile:503: all-recursive] Error 1 make[1]: Leaving directory '/home/eger/gsoap-shared/gsoap-2.8.84-1.x86_64/build' make: *** [Makefile:402: all] Error 2 It seems to be a problem with exporting/importing of symbols. There is already a passage for ___dllexport in the stdsoap.h file, which looks like: #ifdef _WIN32 # ifndef WIN32 # define WIN32 # endif #endif /* for legacy purposes we use WIN32 macro, even when WIN64 is supported */ #ifdef _WIN64 # ifndef WIN32 # define WIN32 # endif #endif #ifdef WIN32 # ifdef SOAP_STD_EXPORTS /* dllexport the API functions and classes */ # ifndef SOAP_STD_API # define SOAP_STD_API __declspec(dllexport) # endif # ifndef SOAP_CMAC # define SOAP_CMAC SOAP_STD_API /* export soap struct and generated classes */ # endif # ifndef SOAP_FMAC1 # define SOAP_FMAC1 SOAP_STD_API /* export stdsoap2.cpp API */ # endif # ifndef SOAP_FMAC3 # define SOAP_FMAC3 SOAP_STD_API /* export soapC.cpp serializers API */ # endif # ifndef SOAP_FMAC5 # define SOAP_FMAC5 SOAP_STD_API /* export soapClient.cpp and soapServer.cpp API */ # endif # endif #endif I have played with this code adding defs for CYGWIN, but it did not help. I have even removed the whole block, but that did not help either. I have tried adding -Wl,--export-all-symbols to the gcc -shared command - no luck. Then I started looking in the code. The respectively undefined references are to be found at the end of the stdsoap.h file: SOAP_FMAC3 void SOAP_FMAC4 soap_header(struct soap*); SOAP_FMAC3 void SOAP_FMAC4 soap_fault(struct soap*); SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultcode(struct soap*); SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultsubcode(struct soap*); SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultstring(struct soap*); SOAP_FMAC3 const char ** SOAP_FMAC4 soap_faultdetail(struct soap*); SOAP_FMAC3 const char * SOAP_FMAC4 soap_fault_subcode(struct soap*); SOAP_FMAC3 const char * SOAP_FMAC4 soap_fault_string(struct soap*); SOAP_FMAC3 const char * SOAP_FMAC4 soap_fault_detail(struct soap*); SOAP_FMAC3 void SOAP_FMAC4 soap_serializefault(struct soap*); SOAP_FMAC3 void SOAP_FMAC4 soap_serializeheader(struct soap*); SOAP_FMAC3 int SOAP_FMAC4 soap_getheader(struct soap*); SOAP_FMAC3 int SOAP_FMAC4 soap_putheader(struct soap*); SOAP_FMAC3 int SOAP_FMAC4 soap_getfault(struct soap*); SOAP_FMAC3 int SOAP_FMAC4 soap_putfault(struct soap*); If the definition as given further up works, SOAP_FMAC3 is __declspec(dllexport). Hence, they should be exported. I have tried by adding explicitly 'extern' in front of these definitions (and also in front of the general definition higher up), even more error messages. I have tried to remove them, but they are referred to in stdsoap.c However, unluckily, they are referred to without being defined. This seems to be the major problem to me right now. nm also reports them as being undefined (besides others): nm --undefined libgsoap_la-stdsoap2.o U ___chkstk_ms U __chk_fail U __errno U __imp_h_errno U __locale_mb_cur_max U __stack_chk_fail U __stack_chk_guard U accept U bind U close U connect U difftime U fcntl U fprintf U free U freelocale U fwrite U gethostbyname U getsockopt U gettimeofday U gmtime_r U inet_addr U inet_pton U listen U malloc U mbtowc U memcpy U memmove U mktime U namespaces U newlocale U poll U random U read U recv U recvfrom U select U send U sendto U setsockopt U shutdown U snprintf U soap_fault_detail U soap_fault_string U soap_fault_subcode U soap_faultcode U soap_faultdetail U soap_faultstring U soap_faultsubcode U soap_getfault U soap_getheader U soap_putfault U soap_putheader U soap_serializefault U soap_serializeheader U socket U strchr U strcmp U strerror_r U strftime U strlcat U strlcpy U strlen U strncmp U strncpy U strrchr U strstr U strtod U strtol U strtoll U strtoul U strtoull U time U timegm U uselocale U wctomb U write nm --undefined libgsoap_la-dom.o U __stack_chk_fail U __stack_chk_guard U free U malloc U snprintf U soap_attribute U soap_begin_count U soap_begin_recv U soap_closesock U soap_connect_command U soap_current_namespace_att U soap_current_namespace_tag U soap_delelement U soap_double_nan U soap_double2s U soap_dupelement U soap_element U soap_element_begin_in U soap_element_end_in U soap_element_end_out U soap_element_start_end_out U soap_end_count U soap_end_recv U soap_end_send U soap_getelement U soap_http_get_body U soap_LONG642s U soap_lookup_ns U soap_malloc U soap_markelement U soap_peek_element U soap_push_namespace U soap_putelement U soap_s2double U soap_s2int U soap_s2long U soap_s2LONG64 U soap_send U soap_set_attr U soap_strdup U soap_string_in U soap_string_out U soap_strtrim U soap_wchar2s U strchr U strcmp U strlen U strncmp U strncpy However, they are not to be found. Hence, I am currently stuck on this problem (since a few days already now). I have opened a ticket on the respective sourceforge site (without no reaction yet): https://sourceforge.net/p/gsoap2/bugs/1249/ I have also asked on stackoverflow: https://stackoverflow.com/questions/56811125/compiling-gsoap-on-cygwin-as-shared-library-undefined-reference-relocation-tr There was already one reaction letting me know: The soap_faultcode and other functions are not defined in stdsoap2.c but are referenced in stdsoap2.c and should be linked with the soapcpp2-generated code e.g. soapC.c that define these functions. These functions depend on the way SOAP_ENV__Fault struct is declared (in the .h file for soapcpp2) and therefore these functions cannot be integrated and fixed in the stdsoap2.c library since the struct may change per application (e.g. SOAP_ENV_Detail may have additional struct members). Hence, I appreciated very much any intput in this matter. Maybe we even get so far that we can implement gsoap as a shared library package! Thanks in advance! Wilhelm