I'm looking to compile both a static and shared version of a library. I've created two targets that include all the same source files.
The static target includes:
'target_name': 'haywire',
'product_name': 'haywire',
'type': 'static_library',
'dependencies': [
'./lib/libuv/uv.gyp:libuv',
],
The shared target includes:
'target_name': 'haywire_shared',
'product_name': 'haywire',
'type': 'shared_library',
'dependencies': [
'./lib/libuv/uv.gyp:libuv',
],
When compiling the shared library I get the following error:
/usr/bin/ld: ./builds/unix/debug/obj.target/haywire_shared/src/haywire/http_parser.o: relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
./builds/unix/debug/obj.target/haywire_shared/src/haywire/http_parser.o: could not read symbols: Bad value
So I added the "-fPIC" to the haywire_shared target as suggested:
'cflags': [
'-std=c99',
'-fPIC',
],
But the same linker error seems to happen. Any ideas what I've done wrong? Here's the link to the full gyp file.
Thanks for the help in advance!