[Bug 640734] Re: crtbeginT.o needs to be recompiled with -fPIC
Doug Royer
640734 at bugs.launchpad.net
Fri Mar 1 19:11:44 UTC 2019
You CAN link ARCHIVE libraries when building dynamic libraries.
As long as the archive (.a) was compiled with -fPIC/-fpic.
I do it all the time when building shared libraries for embedded
devices, where you do not want to distribute a massive shared library,
or multiple shared libraries. By building the embedded archive libraries
with -fPIC/-fpic, you can link them and build one new shared library. In
fact many open source project build multiple archive libs, then link at
the final step into the final dynamic library.
The problem is not -shared which is misleading. The issue is was the
archive library built with -fPIC/-fpic or not?
The bug exists, because when building a -fPIC/fpic archive library
(linked with -Bstatic libName -Bdynamc, where libName WAS compiled
dynamic, you get the error.
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-4.4 in Ubuntu.
https://bugs.launchpad.net/bugs/640734
Title:
crtbeginT.o needs to be recompiled with -fPIC
Status in gcc-4.4 package in Ubuntu:
Invalid
Status in gcc-5 package in Ubuntu:
Invalid
Bug description:
Binary package hint: gcc-4.4
I'm trying to compile a very simple C library to examine how JNI
functions. The code in question comes from
http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jniexamp.html
. I will attach the file nativelib.c, taken from that site.
When running the command:
gcc -o libnativelib.so -shared -Wl,-soname,libnative.so
-I/usr/lib/jvm/java-6-openjdk/include
-I/usr/lib/jvm/java-6-openjdk/include/linux nativelib.c -static -lc
gcc says:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.4.3/crtbeginT.o: relocation R_X86_64_32 against `__DTOR_END__' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.4.3/crtbeginT.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
It looks like crtbeginT.o needs to be recompiled with -fPIC.
ProblemType: Bug
DistroRelease: Ubuntu 10.04
Package: gcc-4.4-base 4.4.3-4ubuntu5
ProcVersionSignature: Ubuntu 2.6.32-24.41-server 2.6.32.15+drm33.5
Uname: Linux 2.6.32-24-server x86_64
Architecture: amd64
Date: Thu Sep 16 12:27:58 2010
Dependencies:
InstallationMedia: Ubuntu-Server 10.04 LTS "Lucid Lynx" - Release amd64 (20100427)
ProcEnviron:
PATH=(custom, user)
LANG=en_US.utf8
SHELL=/bin/bash
SourcePackage: gcc-4.4
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.4/+bug/640734/+subscriptions
More information about the foundations-bugs
mailing list