Bug 104055 - Failed to create/link with shared objects
Summary: Failed to create/link with shared objects
Alias: None
Product: Red Hat Enterprise Linux 3
Classification: Red Hat
Component: gcc
Version: 3.0
Hardware: i686
OS: Linux
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2003-09-09 14:32 UTC by Rob Kirkbride
Modified: 2007-11-30 22:06 UTC (History)
0 users

Clone Of:
Last Closed: 2003-09-09 14:47:39 UTC

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2003:344 normal SHIPPED_LIVE Miscellaneous bugfixes available for anaconda installation program 2003-11-11 05:00:00 UTC

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):

How reproducible:

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.


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