0

I am trying to compile a C++ plugin using Ubuntu 14.04, Qt, and some boost libraries.

I built the boost libraries as follows:

libboost-all-dev

If I use shared boost libraries, e.g. libboost_system.so, the project compiles just fine. However, I want to compile using static boost libraries (libboost_system.a). I get the following error in my boost project:

 "relocation R_X86-64-32 against '.rodata.str1.1' cannot be used when making a shared object; recompile with -fPIC". 

This is my Qt project file:

VERSION = 1.3.1
TEMPLATE = lib
QT -= gui
CONFIG += warn_on plugin release 
CONFIG -= thread exceptions qt rtti debug 
CONFIG += c++11

INCLUDEPATH += /usr/include

LIBS += "/usr/lib/x86_64-linux-gnu/libboost_system.a" 
LIBS += "/usr/lib/x86_64-linux-gnu/libboost_filesystem.a"

DEFINES += APL=0 IBM=0 LIN=1 
DEFINES += IGOCONNECT_LIN_LIBRARY

TARGET = lin.xpl

QMAKE_CXXFLAGS += -fvisibility=hidden 
QMAKE_CXXFLAGS += -fPIC

SOURCES += igoconnect_lin.cpp
HEADERS +=
unix {  
target.path = /usr/lib  
INSTALLS += target 
}

Anything I am doing wrong? Thank you so much!

2
  • what happens when you recompile with -fPIC like it says?
    – chris
    Feb 1, 2015 at 1:50
  • Thank you. Not sure what was meant: recompile the project or recompile the boost library. I tried to build the project with the following: qmake /home/igor/Projects/igoconnect_lin/igoconnect_lin.pro -r -spec linux-g++ -fPIC. It is not even starting to compile giving an immediate error. Thanks anyways. Feb 1, 2015 at 6:02

1 Answer 1

0

Try that

LIBS += -lboost_system
2
  • It compiled! Let me check tomorrow if the plugin actually works in the program environment and I will accept the answer if everything is fine. In any case, many thanks! Feb 1, 2015 at 6:09
  • Although I wonder whether this compiles libraries dynamically. Cheers. Feb 1, 2015 at 6:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.