Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug error "Symbol lookup error: undefined symbol"

I created an app (api_tests) that uses a library (libstorage.so) that linked to oracle occi library (libocci.so.12.1) and compiled it. When I run this app, I get an error:

api_tests
api_tests: symbol lookup error: ./libstorage.so: undefined symbol: _ZN6oracle4occi11Environment17createEnvironmentENS1_4ModeEPvPFS3_S3_mEPFS3_S3_S3_mEPFvS3_S3_E

However this library with this symbol exists in the current directory:

ls | grep libocci
libocci.so*
libocci.so.11.1*
libocci.so.12.1*

nm libocci.so.12.1 | grep _ZN6oracle4occi11Environment17createEnvironmentENS1_4ModeEPvPFS3_S3_mEPFS3_S3_S3_mEPFvS3_S3_E
0000000000097e70 T _ZN6oracle4occi11Environment17createEnvironmentENS1_4ModeEPvPFS3_S3_mEPFS3_S3_S3_mEPFvS3_S3_E
0000000000125014 r _ZN6oracle4occi11Environment17createEnvironmentENS1_4ModeEPvPFS3_S3_mEPFS3_S3_S3_mEPFvS3_S3_E$$LSDA

The current path is added to LD_LABRARY_PATH:

echo $LD_LIBRARY_PATH
./:/usr/vacpp/bin/../lib:/lib

I'm wondering what can be wrong with my library and how I can debug the issue?

Update: It looks like this library was not linked (at least ldd doesn't show this dependency). I guess it was mistake in makefile and it was compiled but failes in runtime.

like image 555
Oleksii Shyshkov Avatar asked Aug 05 '16 23:08

Oleksii Shyshkov


People also ask

How do you fix undefined symbol in C++?

You need to pass the values to the function Calculate. Variables x, y, z and function are not accessible outside the class and also u need a return type to the function so that you can get the output from the function Calculate.

What is undefined symbol error?

When generating an executable output file, the link-editor's default behavior is to terminate with an appropriate error message should any symbols remain undefined. A symbol remains undefined when a symbol reference in a relocatable object is never matched to a symbol definition.

What does symbol lookup error mean?

The error message above occurs when you have an incorrect LD_LIBRARY_PATH setting. When a Platform MPI application starts, it will search for a dynamic library called libmpi.so. Note that this is a common library name and that many MPI distributions use this name.


1 Answers

nm libocci.so.12.1

There are two problems with above command:

  1. You don't know whether libocci.so.12.1 is actually getting loaded into your process. To answer the "which libocci is getting loaded", run with LD_DEBUG=libs.
  2. Just because the symbol is present in the symbol table of libocci.so.12.1 doesn't mean that it's available for dynamic linking. It must be available in the dynamic symbol table, which you can examine with nm -D libocci.so.12.1
like image 182
Employed Russian Avatar answered Sep 27 '22 17:09

Employed Russian