Discussion:
autoconf check for building shared library
Will Parsons
2016-04-02 03:23:03 UTC
Permalink
During the course of attempting to develop a ruby gem C extension, I
came upon the following error trying to build a simple C library on a
FreeBSD system:

linking shared-object gdi.so
/usr/bin/ld: /home/william/lib/libWinspool.a(winspool.o): relocation R_X86_64_PC32 against `memset@@FBSD_1.0' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value

From googling, what I *think* that what this means is that I have to
use -fPIC flag to the compiler when building the shared library using
GCC. Presumably, -fPIC is a GCC-only flag, so if I want to maintain
portability I need to build that into my configure.ac somehow. I have
so far been unable to discover a means to do so in autoconf. Ideally,
I'd like a macro that would translate "I'm building shared library" to
"CFLAGS += -fPIC", or something similar if GCC is being used. Failing
that, can I test for whether GCC is being used and add "-fPIC" to the
compile flags if it is?

I amm interested in an autoconf solution, not involving e.g., automake
or libtool.
Bob Friesenhahn
2016-04-02 18:48:01 UTC
Permalink
Post by Will Parsons
I amm interested in an autoconf solution, not involving e.g., automake
or libtool.
You should be able to take advantage of macros from libtool without
actually using libtool itself.

Bob
--
Bob Friesenhahn
***@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
Loading...