Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2259
  • Last Modified:

gSOAP g++ building error

I have gsoap installed, I am trying to to build one of the exmaples:

I do the following which builds a pure c version and this works fine:

g++  -c soapC.cpp

Open in new window


But when I try to build the c++ version like so:

g++ soapC.cpp
soapC.cpp:(.text+0x7645): undefined reference to `soap_element_begin_in'
soapC.cpp:(.text+0x7670): undefined reference to `soap_malloc'
soapC.cpp:(.text+0x76c0): undefined reference to `soap_revert'
soapC.cpp:(.text+0x76ce): undefined reference to `soap_malloc'
soapC.cpp:(.text+0x7752): undefined reference to `soap_id_lookup'
soapC.cpp:(.text+0x7773): undefined reference to `soap_element_end_in'
/tmp/ccMtcp0m.o: In function `soap_in_SOAP_ENV__Detail(soap*, char const*, SOAP_ENV__Detail*, char const*)':
soapC.cpp:(.text+0x77e5): undefined reference to `soap_element_begin_in'
soapC.cpp:(.text+0x783e): undefined reference to `soap_id_enter'
soapC.cpp:(.text+0x7926): undefined reference to `soap_inliteral'
soapC.cpp:(.text+0x799d): undefined reference to `soap_element_end_in'
soapC.cpp:(.text+0x79fd): undefined reference to `soap_id_forward'

Open in new window


How do I solve this???
I think I need to include a header file or library in my g++ path somehow.
0
Wanting2LearnMan
Asked:
Wanting2LearnMan
1 Solution
 
Wanting2LearnManAuthor Commented:
I have tried the following:

g++ soapC.cpp -I /home/gsoap-2.8/gsoap/ -l libgsoap++.a

Open in new window

home/gsoap-2.8/gsoap includes header files and libgsoap++.s is a link as follows:
libgsoap++.a -> /usr/local/lib/libgsoap++.a

Open in new window

But I now get the error:

/usr/lib64/gcc/x86_64-suse-linux/4.3/../../../../x86_64-suse-linux/bin/ld: cannot find -llibgsoap++.a
collect2: ld returned 1 exit status

Open in new window

Any ideas??
0
 
farzanjCommented:
Is there any shared object?

/sbin/ldconfig -p | grep -i soap

Open in new window


Also, did you make any change in your includes or anything?

Do you still have
#include<stdio.h>
?


Another problem is in:
-l libgsoap++.a

You need to drop lib

So it should be
-l gsoap++.a

But I would normally look for shared objects .so instead of .a
I will have to look for .a, I forgot but if it was libz.so, I would do
-lz

Open in new window

0
 
ahoffmannCommented:
please try:

 g++ soapC.cpp -I /home/gsoap-2.8/gsoap/ -l gsoap++

or use a full path like  /path/to/libgsoap++.a
(also see farzanj's comments on .a vs .so; better you make a decision if want to compile *and* link staticaly or with dynamic shared objects
0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 
Duncan RoeSoftware DeveloperCommented:
Since g++  -c soapC.cpp worked, there is no need to add -I /home/gsoap-2.8/gsoap/. You are done with the source and you now have the object file soapC.o.
Your problem is to link soapC.o with the necessary libraries to make an executable program.
Some systems don't by default look for libraries in /usr/local /lib, so here's what I would try
g++  -c soapC.cpp
g++ soapC.o -L/usr/local/lib -lgsoap++ -o soapC

Open in new window

Notice for the library you miss out the leading lib and the trailing .a. The above command will link to the shared library libgsoap++.so if it can find it, otherwise it will link to libgsoap++.a. Either way, the built program will be called soapC.
0
 
masheikCommented:
hi
    duncan_roe has already given pointers on this .. i tried to write a make file to build this..

1) make sure you have copied the .a lib in the usr/local/lib directory (For another library i got the same problem but after manually copied the .so files it was worked fine)
2) export LD_LIBRARY_PATH (if you have the gSoap lib on other dir ..ie not in gcc library search path)

Here is the example Makefile to compile the stuff

# Makefile (EE QID:27852210)

# Target Name
TARGET = soapC

# Compiler options
CC     = g++
CFLAGS = -c
LFLAGS = -o


# Library Directories
# modify this path as per requirement
SOAP_LIB_PATH = -I/usr/local/soap_libs

# Include Directories
#modify this path for your requirement
SOAP_INC_PATH = -I/usr/local/soap_inc

# Static/Shared libraries
GSOAP_LIBS = -lgsoap++
ADDITIONAL_LIBS =

# Source files
SRCS = test.c#soapC.cpp

# Compilation and Build
build:
        @echo "Compiling " $(SRCS)
        @#@$(CC) $(LFLAGS) test $(SRCS)
        @$(CC) $(LFLAGS) $(TARGET) $(SRCS) $(SOAP_LIB_PATH) $(SOAP_INC_PATH) $(GSOAP_LIBS)
        @echo "Build successful"

Open in new window

Use the following command to run the Makefile
linux$make build
0
 
Duncan RoeSoftware DeveloperCommented:
Rather than exporting LD_LIBRARY_PATH you might prefer to add /usr/local/lib or whatever to /etc/ld.so.conf. That's what I do
0
 
masheikCommented:
---->Rather than exporting LD_LIBRARY_PATH you might prefer to add /usr/local/lib or whatever to /etc/ld.so.conf. That's what I do
      Better ..no need to configure again the LD_LIBRARY_PATH when you restart..
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now