autoconf check for building shared library

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

autoconf check for building shared library

Will Parsons
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.


_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: autoconf check for building shared library

Bob Friesenhahn
On Sat, 2 Apr 2016, Will Parsons wrote:
>
> 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
[hidden email], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

_______________________________________________
Autoconf mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/autoconf
Loading...