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

Linking problem: relocation R_X86_64_PC32 against symbol `_ZN5QJson13ParserPrivateC1Ev' #24

Closed
vsapronov opened this issue May 6, 2013 · 13 comments

Comments

@vsapronov
Copy link

HI,

I'm trying to build your library with ubuntu-sdk package on Ubuntu 13.04 x64
I'm doing in qjson folder:

    cmake -G "Unix Makefiles"
    make

I'm getting this error:

    Linking CXX shared library ../lib/libqjson.so
    /usr/bin/ld: CMakeFiles/qjson.dir/parser.cpp.o: relocation R_X86_64_PC32 against symbol `_ZN5QJson13ParserPrivateC1Ev' can not be used when making a shared object; recompile with -fPIC
@flavio
Copy link
Owner

flavio commented May 6, 2013

Please try again following these instructions.

@vsapronov
Copy link
Author

What exactly I'm missing from instructions? Do you mean these lines?

    mkdir build
    cd build
    cmake -DCMAKE_INSTALL_PREFIX=...

@flavio
Copy link
Owner

flavio commented May 7, 2013

Just the

mkdir build; cd build
cmake ..
make

part

@vsapronov
Copy link
Author

I tried this - got the same error. Here's full output:

vsapronov@vsapronov-HP-Z620:~/Projects/own/qjson$ git status
# On branch master
nothing to commit, working directory clean
vsapronov@vsapronov-HP-Z620:~/Projects/own/qjson$ mkdir build
vsapronov@vsapronov-HP-Z620:~/Projects/own/qjson$ cd build
vsapronov@vsapronov-HP-Z620:~/Projects/own/qjson/build$ cmake ..
-- The C compiler identification is GNU 4.7.3
-- The CXX compiler identification is GNU 4.7.3
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
Qt5 found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/vsapronov/Projects/own/qjson/build
vsapronov@vsapronov-HP-Z620:~/Projects/own/qjson/build$ make
Scanning dependencies of target qjson_automoc
[ 11%] Automoc for target qjson
Generating moc_parserrunnable.cpp
Generating moc_qobjecthelper.cpp
/home/vsapronov/Projects/own/qjson/src/qobjecthelper.h:0: Note: No relevant classes found. No output generated.
Generating moc_serializerrunnable.cpp
[ 11%] Built target qjson_automoc
Scanning dependencies of target qjson
[ 22%] Building CXX object src/CMakeFiles/qjson.dir/parser.cpp.o
[ 33%] Building CXX object src/CMakeFiles/qjson.dir/qobjecthelper.cpp.o
[ 44%] Building CXX object src/CMakeFiles/qjson.dir/json_scanner.cpp.o
[ 55%] Building CXX object src/CMakeFiles/qjson.dir/json_parser.cc.o
[ 66%] Building CXX object src/CMakeFiles/qjson.dir/parserrunnable.cpp.o
[ 77%] Building CXX object src/CMakeFiles/qjson.dir/serializer.cpp.o
[ 88%] Building CXX object src/CMakeFiles/qjson.dir/serializerrunnable.cpp.o
[100%] Building CXX object src/CMakeFiles/qjson.dir/qjson_automoc.cpp.o
Linking CXX shared library ../lib/libqjson.so
/usr/bin/ld: CMakeFiles/qjson.dir/parser.cpp.o: relocation R_X86_64_PC32 against symbol `_ZN5QJson13ParserPrivateC1Ev' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [lib/libqjson.so.0.8.1] Error 1
make[1]: *** [src/CMakeFiles/qjson.dir/all] Error 2
make: *** [all] Error 2

@flavio
Copy link
Owner

flavio commented May 7, 2013

Ok, I see you are using Qt5.

Please provide the following details:

  • which version of Qt5 have you installed?
  • How did you install Qt5 (deb package from ppa)?
  • Which version of Ubuntu are you running?
  • What is your architecture?

@vsapronov
Copy link
Author

I'm running Ubuntu 13.04 x64. Qt is 5.0.1. As I mentioned I installed Qt SDK through package-manager (ubuntu-sdk). I noticed you recommended this ppa in bug 19. This ppa now says the phrase below. That's why I'm using ubuntu-sdk package.

== Ubuntu 13.04 ==
The PPAs are not necessarily needed anymore but are recommended to be left enabled for future updates. Ubuntu SDK and Qt 5.0.1 are now part of the Ubuntu 13.04 release. Just install 'ubuntu-sdk' package!

@flavio
Copy link
Owner

flavio commented May 8, 2013

Ok, I'll take a look at it using a virtual machine.

@vsapronov
Copy link
Author

Please, take a look. I have tried on my both work and home machines. Both the same Ubuntu 13.04 x64 and the same Qt SDK package (ubuntu-sdk). Both giving the same error.

@flavio
Copy link
Owner

flavio commented May 15, 2013

This is a nasty bug, I've been able to reproduce it but I need some time to fix it.

@niwinz
Copy link

niwinz commented Jun 2, 2013

That version of compiller you have? (Ubuntu 13.xx seems to have gcc 4.7...)

I have like this error compiling other libs (written with qt5) with gcc < 4.8. Currently I am working on "some" shared library with qt5 and if I try compile one of my library with g++ 4.6 o 4.7 I get this error. But if I compile it with g++ 4.8 or clang 3.2, all works properly.

I tried to compile qjson with clang++ 3.2 or g++ 4.8 and compiles properly!
You can see compilation logs: http://dpaste.com/1208652/

This seems qt5 bug with "old compillers", not qjson bug.

Update: http://www.airs.com/blog/archives/307

@shumski
Copy link

shumski commented Jan 2, 2014

Error is due to 'SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")'
(and it is not needed)

flavio added a commit that referenced this issue Jan 9, 2014
@flavio
Copy link
Owner

flavio commented Jan 9, 2014

@shumski thanks a lot. That works.

Fixed with 2765c55

@JackZ0
Copy link

JackZ0 commented Apr 11, 2017

relocation R_X86_64_PC32 against symbol `ff_pw_9' can not be used when making a shared object; recompile with -fPIC
What should I do ?

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

5 participants