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

How can I compile dlib external dependency zlib with -fPIC flag? #1427

Closed
posutsai opened this issue Jul 25, 2018 · 1 comment
Closed

How can I compile dlib external dependency zlib with -fPIC flag? #1427

posutsai opened this issue Jul 25, 2018 · 1 comment

Comments

@posutsai
Copy link

I am using dlib with pybind11 to build a python extension and compiler is gcc in c++11. When I try to compile my code it always shows following error message, I think it may be that I didn't add -fPIC flag in zlib compilation.

//usr/local/lib/libdlib.a(zutil.c.o): relocation R_X86_64_PC32 against symbol z_errmsg' can not be used when making a shared object; recompile with -fPIC

I try to compile the same code without pybind11 too. And it works perfectly. Following is my command in my Makefile.

pybind11 version:
g++ -O3 -Wall -shared -std=c++11 -fPIC pkg-config --cflags --libs glib-2.0 python3 -m pybind11 --includes $^ -lpthread -lX11 -ldlib -lglib-2.0 -lz /usr/local/lib/libz.a -l
jpeg -o wsi_readerpython3-config --extension-suffix

without pybind11 version:
g++ -O3 -std=c++11 pkg-config --cflags --libs glib-2.0 -I/usr/include/boost $^ -ldlib -ljpeg -lglib-2.0 -lpthread -o out

@posutsai
Copy link
Author

I follow the solution in this issue and solve it already.
pybind/pybind11#466
I manually add set_target_properties(dlib PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
before add_subdirectory in CMakeLists.txt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants