"undefined reference to symbol" and "is defined in DSO"

Asked by Paul Conrady on 2013-04-15

I am trying to build an application (GnuCash) from source on Ubuntu 12.04. The ./configure and make complete without an error. During 'make check' , the linker gives the following output:

../../../../src/core-utils/.libs/libgnc-core-utils.so ../../../../src/libqof/qof/.libs/libgnc-qof.so ../../../../src/backend/dbi/test/.libs/libgncmod-test-dbi.a ../../../../src/backend/sql/.libs/libgnc-backend-sql.so ../../../../lib/libc/.libs/libc-missing.a -lpthread -lm -pthread -Wl,-rpath -Wl,/opt/gnucash/lib -Wl,-rpath -Wl,/opt/gnucash/lib/gnucash
/usr/bin/ld: ../../../../src/backend/dbi/test/.libs/libgncmod-test-dbi.a(test-dbi-stuff.o): undefined reference to symbol 'gnc_get_long_version'
/usr/bin/ld: note: 'gnc_get_long_version' is defined in DSO /home/paul/development/gnucash-2.4.11/src/core-utils/.libs/libgnc-core-utils.so so try adding it to the linker command line
/home/paul/development/gnucash-2.4.11/src/core-utils/.libs/libgnc-core-utils.so: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
make[6]: *** [test-dbi-basic] Error 1
make[6]: Leaving directory `/home/paul/development/gnucash-2.4.11/src/backend/dbi/test'
make[5]: *** [check-am] Error 2
make[5]: Leaving directory `/home/paul/development/gnucash-2.4.11/src/backend/dbi/test'
make[4]: *** [check-recursive] Error 1
make[4]: Leaving directory `/home/paul/development/gnucash-2.4.11/src/backend/dbi/test'
make[3]: *** [check-recursive] Error 1
make[3]: Leaving directory `/home/paul/development/gnucash-2.4.11/src/backend/dbi'
make[2]: *** [check-recursive] Error 1
make[2]: Leaving directory `/home/paul/development/gnucash-2.4.11/src/backend'
make[1]: *** [check-recursive] Error 1
make[1]: Leaving directory `/home/paul/development/gnucash-2.4.11/src'
make: *** [check-recursive] Error 1

I expect the make check to complete without errors. Instead there is an undefined reference to symbol 'gnc_get_long_version'.
I understand that the linker is telling me to explicitly link to the required DSO but I do not know how to do this. Can someone help me out?

Question information

English Edit question
Ubuntu gnucash Edit question
No assignee Edit question
Solved by:
Manfred Hampl
Last query:
Last reply:


wget http://archive.getdeb.net/install_deb/getdeb-repository_0.1-1~getdeb1_all.deb
sudo dpkg -i ./getdeb-repository_0.1-1~getdeb1_all.deb
rm ./getdeb-repository_0.1-1~getdeb1_all.deb
sudo apt-get update
sudo apt-get install gnucash

You will then get the 2.4.11 version. Is that all you need?

Paul Conrady (audio1953) said : #2

Thanks, actionparsnip, but I already have the source code. I am trying to build GnuCash 2.4.11 from source and get the above error, which involves an " undefined reference to symbol 'gnc_get_long_version' " - whatever that means.

You could contact the maintainer of that PPA to ask, they may be able to shed light.

Manfred Hampl (m-hampl) said : #4

When I look at the error messages I see:

(1) /usr/bin/ld: note: 'gnc_get_long_version' is defined in DSO /home/paul/development/gnucash-2.4.11/src/core-utils/.libs/libgnc-core-utils.so so try adding it to the linker command line

(2)/home/paul/development/gnucash-2.4.11/src/core-utils/.libs/libgnc-core-utils.so: could not read symbols: Invalid operation

For me that looks as if the linker identifies, that 'gnc_get_long_version' should be available in libgnc-core-utils.so (1), but when trying to resolve the symbol, it cannot be found in libgnc-core-utils.so (2).

Googling for similar error messages shows that this is a known problem that has been introduced with changes of binutils (--copy-dt-needed-entries is no longer enabled by default, instead --no-copy-dt-needed-entries is the default.) see http://fedoraproject.org/wiki/UnderstandingDSOLinkChange

The solution should be to modify the linker command (most probably by changing the makefile) to add -lgnc-core-utils for the executable that is currently built at the moment of the error (I guess test-dbi-basic).

Paul Conrady (audio1953) said : #5

Hi Manfred,

Thanks for the advice and the link. You are right on target, I believe. My problem is I do not know how to add "-lgnc-core-utils" to the linker command line. Adding it to the ./configure command as a switch does not work. Looking through the Makefile.am and Makefile.in files in the build directory does not give me a clue either.

I have tried editing the Makefile with "-lgnc-core-utils" as shown below to no avail:

LD = /usr/bin/ld
LIBDBI_LIBS = -ldbi -lgnc-core-utils
LIBOBJS_SEDSCRIPT = s,\.[^.]* ,&,g;s,\.[^.]*$$,&,
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>NO GO<<<<<<<<<<<<<<<<<<<<<<<<<<<
LD = /usr/bin/ld
LDFLAGS = -lgnc-core-utils
LIBOBJS_SEDSCRIPT = s,\.[^.]* ,&,g;s,\.[^.]*$$,&,
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>NO GO<<<<<<<<<<<<<<<<<<<<<<<<<<<

Also tried adding the switch "--copy-dt-needed-entries" to ./configure command. This is not an option in Ubuntu; possibly in Fedora flavor???

Still have the original problem.

Manfred Hampl (m-hampl) said : #6

I do not know how to correctly change the config files for that modification either.
Maybe in ...src\backend\dbi\test\Makefile.in you have to change
test_dbi_basic_LDADD = $(LDADD)
test_dbi_basic_LDADD = "$(LDADD) -lgnc-core-utils"
or add a line
test_dbi_basic_LDADD = -lgnc-core-utils
to ...src\backend\dbi\test\Makefile.am

If that error shows up only for "make check" and not for "make install" or "make" ior "make all", I guess you could even ignore it. A comparison of your log snipped with the buildlog of a successful build indicates that the test-dbi-basic program is not contained in the final package, but apparently only created for testing purposes when you do "make check".

The commands
sudo apt-get build-dep gnucash
sudo apt-get source --compile gnucash
should download the source of the version defined for your Ubuntu release and compile it (might be an older version), most probably not doing "make check". You could check if the version for your Ubuntu release builds successfully with the apt-get --compile command, and then try building a package for the newer version with a similar set of commands as done during apt-get (not sure which commands are executed, though).

Paul Conrady (audio1953) said : #7

I am out of ideas and time. The program is superceded by a later version so I built GnuCash 2.4.11, which no longer has the above problem. Thanks to all.

Paul Conrady (audio1953) said : #8

Correction - so I built GnuCash 2.4.12, which no longer has the above problem.

Best Manfred Hampl (m-hampl) said : #9

As you have found a workaround, please mark this question as 'solved'

Paul Conrady (audio1953) said : #10

Thanks Manfred Hampl, that solved my question.