|Re: How to create class from shared library project? [message #1778212 is a reply to message #1778086]
||Tue, 12 December 2017 01:59
Registered: October 2012
This isn't a CDT problem so it's OT for this forum.|
'class' is a compile time construct.
You are getting a linker error.
Error was: /bin/ld: ./ext.o: relocation R_X86_64_32S against `_ZTV3ext' can not be used when making a shared object; recompile with -fPIC
How did you compile ext.cpp?
Did you recompile it with -fPIC?
GNU documentation of -fpic and -fPIC
Latest command line options (GCC-7.2): https://gcc.gnu.org/onlinedocs/gcc-7.2.0/gcc/#toc-GCC-Command-Options
Generate position-independent code (PIC) suitable for use in a shared library, if supported for the target machine. Such code accesses all constant addresses through a global offset table (GOT). The dynamic loader resolves the GOT entries when the program starts (the dynamic loader is not part of GCC; it is part of the operating system). If the GOT size for the linked executable exceeds a machine-specific maximum size, you get an error message from the linker indicating that -fpic does not work; in that case, recompile with -fPIC instead. (These maximums are 8k on the SPARC, 28k on AArch64 and 32k on the m68k and RS/6000. The x86 has no such limit.)
Position-independent code requires special support, and therefore works only on certain machines. For the x86, GCC supports PIC for System V but not for the Sun 386i. Code generated for the IBM RS/6000 is always position-independent.
When this flag is set, the macros __pic__ and __PIC__ are defined to 1.
If supported for the target machine, emit position-independent code, suitable for dynamic linking and avoiding any limit on the size of the global offset table. This option makes a difference on AArch64, m68k, PowerPC and SPARC.
Position-independent code requires special support, and therefore works only on certain machines.
When this flag is set, the macros __pic__ and __PIC__ are defined to 2.
General info for building .so files: http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html
EDIT: originally quoted from GCC-3.0. Hasn't changed much.
[Updated on: Tue, 12 December 2017 02:11]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.02026 seconds