Bug 104055 - Failed to create/link with shared objects
Failed to create/link with shared objects
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: gcc (Show other bugs)
3.0
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-09-09 10:32 EDT by Rob Kirkbride
Modified: 2007-11-30 17:06 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-09-09 10:47:39 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Rob Kirkbride 2003-09-09 10:32:20 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624

Description of problem:
If I create a simple shared object and then attempt to link with this I get :
/usr/bin/ld: main: hidden symbol `__dso_handle' in
/usr/lib/gcc-lib/i386-redhat-linux/3.2.3/crtbegin.o is referenced by DSO

gcc -c -fPIC libtest.cpp (simple class with just constructor)
ld -shared -soname libtest.so.1 -o libtest.so.1.0 -lc libtest.o
/sbin/ldconfig -v -n .
ln -s libtest.so.1.0 libtest.so
g++ -o main main.cpp -L. -ltest

produces the error above.

main.cpp is just :-
#include "libtest.h"

int main() {
  libtest mylib;
}


Version-Release number of selected component (if applicable):
gcc-c++-3.2.3-18

How reproducible:
Always

Steps to Reproduce:
1. See description above

    

Actual Results:  Give the following error 
/usr/bin/ld: main: hidden symbol `__dso_handle' in
/usr/lib/gcc-lib/i386-redhat-linux/3.2.3/crtbegin.o is referenced by DSO

Expected Results:  No errors and the main excecutable should have been produced.

Additional info:

No special information. Reproduced on two different machines.
Fully up2date as of 14:30 GMT 09/09/2003
Comment 1 Jakub Jelinek 2003-09-09 10:47:39 EDT
The bug is in the way you're linking the shared library.
Never ever invoke ld by hand unless you know exactly what consequences it has.
gcc/g++ driver knows better what is needed.
The shared library should have been linked with:
g++ -shared -Wl,-soname,libtest.so.1 -o libtest.so.1.0 libtest.o
Comment 2 Jay Turner 2004-01-16 12:16:42 EST
An errata has been issued which should help the problem described in this bug report. 
This report is therefore being closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files, please follow the link below. You may reopen 
this bug report if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2003-344.html

Note You need to log in before you can comment on or make changes to this bug.