Dragonfly
Dragonfly

Reputation: 193

libstdc++.so.6: version not found - NO admin rights

I am trying to run an executable file - SaTScanBatch, executable of the SaTScan software - on a remote machine from the terminal.

Here is the error I get

/usr/lib64/libstdc++.so.6: version 'GLIBCXX_3.4.15' not found

The problem is similar to these: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found or How to fix: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.15' not found or /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found

What is different in my case is that I do not have admin rights, so I cannot add libraries in usr/lib file. I downloaded libstdc++.6.0.15 in my remote repository, and I want to use it to execute my file.

Here are the possibilities I tried

i) Modify environment variable LD_LIBRARY_PATH or LD_RUN_PATH or LD_PRELOAD to the path of libstdc++.so.6.0.15. --> Did not change anything

ii) Include the library in a static way

gcc SaTScanBatch -static-libstdc++

--> -static option is not recognized, I guess the remote machine's GCC version is too old.

iii) Try to link the file to the additional library:

gcc SaTScanBatch -L /path/library -l stdc++

or similarly

gcc SaTScanBatch -Wl,-rpath,path/to/library

--> Error

/usr/bin/ld: warning: Cannot create .eh_frame_hdr section, --eh-frame-hdr ignored.
/usr/bin/ld: error in SaTScanBatch64(.eh_frame); no .eh_frame_hdr table will be created.
/usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../lib64/crt1.o: In function _start:
(.text+0x20): undefined reference to "main"
collect2: ld returned 1 exit status

iv) Use PatchElf to link the file and the library --> I cannot install PatchElf because no admin rights

Thank you for any suggestion !

Upvotes: 1

Views: 1341

Answers (1)

Jonathan Wakely
Jonathan Wakely

Reputation: 171413

Modify environment variable LD_LIBRARY_PATH or LD_RUN_PATH or LD_PRELOAD to the path of libstdc++.so.6.0.15. --> Did not change anything

What exactly did you try?

LD_LIBRARY_PATH should be set to the directory containing the new libstdc++.so.6 not the the file itself, and you need to export the environment variable so it's available to child processes, not just to your shell. And you need a symlink from libstdc++.so.6 to libstdc++.so.6.0.15 because the dynamic loader is going to look for that name, not libstdc++.so.6.0.15

LD_RUN_PATH is used during linking to bake a path into the executable. It does nothing at run-time when trying to run the executable. If you use it you need to set it to the directory that will contain the libstdc++.so.6 file on the remote machine. Again, it needs to be set to a directory, not the path of the file.

LD_PRELOAD is something different again, and almost certainly not what you want. You would use it to force a particular shared library to be loaded before anything else when the executable runs. That can be used to pre-load a newer libstdc++ but it's usually better to use LD_LIBRARY_PATH to set a path at run-time or LD_RUN_PATH to set a path at link-time.

Try to link the file to the additional library:

The commands you showed are nonsense, they don't include any objects in the link, so you're trying to create an executable out of nothing. That's why you get the error undefined reference to "main"

For your scenario I would recommend using LD_LIBRARY_PATH.

Upvotes: 0

Related Questions