LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-06-2015, 03:17 PM   #1
MichelleL
LQ Newbie
 
Registered: Oct 2012
Posts: 7

Rep: Reputation: Disabled
Link a Dynamic library built from a higher version gcc?


Hi,

I have a third-party .so library and want to link it from my own program. However the .so library is built on a higher version of gcc and higher version of SLES (the library is written in C++ by the way) than my program. How do I find out whether the two compilation suites are compatible or not?

Thanks in advance!
 
Old 08-07-2015, 03:00 AM   #2
Keruskerfuerst
Senior Member
 
Registered: Oct 2005
Location: Horgau, Germany
Distribution: Manjaro KDE, Win 10
Posts: 2,199

Rep: Reputation: 164Reputation: 164
I dont think that will work.
 
Old 08-07-2015, 10:10 AM   #3
MichelleL
LQ Newbie
 
Registered: Oct 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thanks Keruskerfuerst,

Are there any particular reasons, or is it a general rule of thumb? It would be appreciated if you could point me to some information.
 
Old 08-07-2015, 01:14 PM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Quote:
How do I find out whether the two compilation suites are compatible or not ?
Very simple : $ ldd <third-party>.so


... A `library.so' built on a later OS will usually depend on a later libc.so.6 .



-
 
Old 08-07-2015, 01:31 PM   #5
MichelleL
LQ Newbie
 
Registered: Oct 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thanks knudfl,

I tried running 'ldd <third-party>.so' on both build environments and the list of shared libraries are printed in both cases. In the lower gcc environment, libc.so.6 is linked to libc-2.4.so; while on the higher environment, libc.so.6 is linked to libc-2.17.so. My follow-up question is how to determine the compatibility between the libc.so.6 libraries? I am not an expert on gcc so please bare with me.
 
Old 08-07-2015, 09:02 PM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Re #5.

If nothing is missing by $ ldd <third-party>.so
... then you should be able to use the library with no issues.
 
Old 08-10-2015, 12:51 PM   #7
MichelleL
LQ Newbie
 
Registered: Oct 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
Nothing is missing by 'ldd <third-party>.so' in both environment. However when I tried to link the library in the lower version gcc environment, g++ issues the following error:

'<third-party>.so' file not recognized: File format not recognized
collect2: ld returned 1 exit status

The same linking command works in the higher version gcc environment.
Something else is still missing?
 
Old 08-10-2015, 02:27 PM   #8
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
Re #7.

? May be one of the OS`s has a different architecture ?
The deciding command is : $ uname -m

And this command decides the file architecture : $ file <third-party>.so
 
Old 08-10-2015, 02:39 PM   #9
MichelleL
LQ Newbie
 
Registered: Oct 2012
Posts: 7

Original Poster
Rep: Reputation: Disabled
No. Both OS are x86_64. One is SLES 10 and the other is SLES 11. The $ file <third-party>.so output is this:

ELF 64-bit LSB shared object, AMD x86-64, version 1 (SYSV), stripped
 
  


Reply

Tags
gcc, linking



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use gcc package version 4.6 or higher in RHEL6? newbielinuxuser Red Hat 1 09-04-2013 05:27 PM
LFS version check gcc version higher than recommended EDDY1 Linux From Scratch 1 12-27-2012 06:39 PM
Path of dynamic link library rosek Programming 2 04-28-2010 07:17 PM
gcc dynamic link switches jungle Linux - Software 3 05-29-2009 05:38 PM
Know compiler version of an already built library azazel11998 Programming 1 11-12-2006 05:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration