Bug 104055

Summary: Failed to create/link with shared objects
Product: Red Hat Enterprise Linux 3 Reporter: Rob Kirkbride <rob.kirkbride>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 3.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-09-09 14:47:39 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Rob Kirkbride 2003-09-09 14:32:20 UTC
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 14:47:39 UTC
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 17:16:42 UTC
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