Bug 118592 - Compiler throws errors with shared libraries
Compiler throws errors with shared libraries
Status: CLOSED NOTABUG
Product: Fedora
Classification: Fedora
Component: gcc (Show other bugs)
rawhide
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-03-17 18:49 EST by thewade
Modified: 2007-11-30 17:10 EST (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-03-18 05:18:11 EST
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 thewade 2004-03-17 18:49:50 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040217

Description of problem:
When Im compiling a small GL program as a part of a configure script I
get errors that crash the configure, though GL configures work for
other packages, including shared libraries like fltk. When I remove
the -Wl,-shared flag the code compiles. I have all the newest gcc and
compat-gcc related libraries.
When I run:

gcc -o conftest -g -O2   -L/usr/X11R6/lib conftest.c -lGL  -Wl,-shared
-Wl,-export-dynamic -lXxf86vm -lXext -lX11

aginst:

//conftest.c
#line 2678 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error.  */
/* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
char glInitNames();

int main() {
glInitNames()
; return 0; }

and:

//confdefs.h
#define HAVE_MMX 1
#define HAVE_LIBX11 1
#define HAVE_LIBXEXT 1
#define HAVE_LIBXXF86VM 1

I get:

/usr/lib/libc_nonshared.a(elf-init.oS)(.text+0x1c): In function
`__libc_csu_init':
: undefined reference to `__init_array_end'
/usr/lib/libc_nonshared.a(elf-init.oS)(.text+0x22): In function
`__libc_csu_init':
: undefined reference to `__init_array_start'
/usr/lib/libc_nonshared.a(elf-init.oS)(.text+0x37): In function
`__libc_csu_init':
: undefined reference to `__init_array_start'
/usr/lib/libc_nonshared.a(elf-init.oS)(.text+0x5b): In function
`__libc_csu_fini':
: undefined reference to `__fini_array_end'
/usr/lib/libc_nonshared.a(elf-init.oS)(.text+0x61): In function
`__libc_csu_fini':
: undefined reference to `__fini_array_start'
/usr/lib/libc_nonshared.a(elf-init.oS)(.text+0x7f): In function
`__libc_csu_fini':
: undefined reference to `__fini_array_start'
/usr/bin/ld: conftest: hidden symbol `__fini_array_end' isn't defined
collect2: ld returned 1 exit status

But when I remove the -Wl,-shared portion of the compile command, it
compiles. Whats going on?

Thank you for your time,
-thewade

Version-Release number of selected component (if applicable):
gcc-3.3.3-3, libstdc++-3.3.3-3, kernel-2.6.3

How reproducible:
Always

Steps to Reproduce:
1.Create conftest.c and confdefs.h as above
2.run 
gcc -o conftest -g -O2   -L/usr/X11R6/lib conftest.c -lGL  -Wl,-shared
-Wl,-export-dynamic -lXxf86vm -lXext -lX11
3. See errors
4. run gcc -o conftest -g -O2   -L/usr/X11R6/lib conftest.c -lGL 
-Wl,-export-dynamic -lXxf86vm -lXext -lX11
5. See no errors
    

Actual Results:  usr/lib/libc_nonshared.a(elf-init.oS)(.text+0x1c): In
function `__libc_csu_init':
: undefined reference to `__init_array_end'
/usr/lib/libc_nonshared.a(elf-init.oS)(.text+0x22): In function
`__libc_csu_init':
: undefined reference to `__init_array_start'
/usr/lib/libc_nonshared.a(elf-init.oS)(.text+0x37): In function
`__libc_csu_init':
: undefined reference to `__init_array_start'
/usr/lib/libc_nonshared.a(elf-init.oS)(.text+0x5b): In function
`__libc_csu_fini':
: undefined reference to `__fini_array_end'
/usr/lib/libc_nonshared.a(elf-init.oS)(.text+0x61): In function
`__libc_csu_fini':
: undefined reference to `__fini_array_start'
/usr/lib/libc_nonshared.a(elf-init.oS)(.text+0x7f): In function
`__libc_csu_fini':
: undefined reference to `__fini_array_start'
/usr/bin/ld: conftest: hidden symbol `__fini_array_end' isn't defined
collect2: ld returned 1 exit status

Expected Results:  no response

Additional info:

The configure script is from Gem cvs, a graphics external for PD.
gem.iem.at
Comment 1 Jakub Jelinek 2004-03-18 05:18:11 EST
That is to be expected.  Never use -Wl,-shared, but -shared.
With -Wl,-shared, you don't tell the gcc driver that you are trying
to build a shared library, so it throws in crt objects for executable
etc., but you tell the linker to create a shared library with that.
With -shared, you tell the gcc driver that you are linking a shared
library and it will take care of the details (putting in correct crt
files, libraries etc. and of course also passing -shared to ld).

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