Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't compile as shared object #114

Open
donbarthel opened this issue Mar 1, 2018 · 5 comments
Open

Can't compile as shared object #114

donbarthel opened this issue Mar 1, 2018 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@donbarthel
Copy link

make build-all-dynamic
gives error:
/usr/bin/ld: /home/user/Code/nginx_upstream_module/third_party/yajl/build/yajl-2.1.0/lib/libyajl_s.a(yajl.c.o): relocation R_X86_64_32 against '.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC

It appears to me that the yajl library is statically linked into our dynamic library but the Makefile for yajl compiles without the needed -fPIC flag. The -fPIC flag is used only when the yajl library is dynamically linked.

My work around is to specify the -fPIC flag for all compiles of yajl.

Change in ./third_party/yajl/CMakeLists.txt:
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
to:
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")

@dedok dedok self-assigned this Mar 23, 2018
@dedok dedok added the bug Something isn't working label Mar 23, 2018
@dedok
Copy link
Contributor

dedok commented Mar 23, 2018

Sorry for long the answer, was offline. Thank you for the report!

Yep, this looks like a bug. Which operating system did you use? And did you use GCC and CLang?

@donbarthel
Copy link
Author

I'm using Ubuntu 16.04 compiling with GCC.

@dedok
Copy link
Contributor

dedok commented Apr 15, 2019

Not sure how it could be fixed. Probably patch for Yajl? Or PR into yajl repo?
What do you think?

@Totktonada
Copy link
Member

We can conditionally set -fPIC flag: enable it only for dynamic build.

@Totktonada
Copy link
Member

The question here is about yajl in the submodule. Everything work with system-wide yajl (at least for me).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants