2017-12-24 2 views
0

우분투 16.04, cmake 3.10.1, QT 5.6.2를 사용하고 있습니다.
Windows에서 응용 프로그램을 개발하는 데 익숙해 졌으므로 Linux 플랫폼에서 문제를 해결하는 방법을 잘 모릅니다. 나는 내 코드를 컴파일 할 때
-reduce-relocations로 QT를 빌드하는 방법

, 나는 오류

In file included from /usr/local/Qt/5.6.2/5.6/gcc_64/include/QtCore/qcoreapplication.h:37:0, 
       from /usr/local/Qt/5.6.2/5.6/gcc_64/include/QtWidgets/qapplication.h:37, 
       from /usr/local/Qt/5.6.2/5.6/gcc_64/include/QtWidgets/QApplication:1, 
       from /home/sulfred/Documents/SoftwareDev/github/SulfredLee/PcapReplayer/BackEnd/main.cpp:3: 
/usr/local/Qt/5.6.2/5.6/gcc_64/include/QtCore/qglobal.h:1087:4: error: #error "You must build your code with position independent code if Qt was built with -reduce-relocations. " "Compile your code with -fPIC (-fPIE is not enough)." 
# error "You must build your code with position independent code if Qt was built with -reduce-relocations. "\ 
    ^

Q1을 얻을.
내 Qt가 -reduce-relocations으로 빌드되었는지 확인하는 방법.

+2

이 질문이 있으십니까? https://stackoverflow.com/questions/24825093/how-to-remove-fpie-compiler-switch-from-qt-creator – MrEricSir

+0

대단히 감사합니다.하지만 QMake를 사용하지는 않습니다. – sflee

답변

1

분명히 Qt는 -reduce-relocations으로 컴파일됩니다. 오류 메시지는 적절한 플래그를 사용하여 사용자 고유의 코드를 작성해야한다고 지적합니다. 관련 :

Error while compiling QT project in cmake

https://github.com/wkhtmltopdf/qtbase/commit/36d6eb721e7d5997ade75e289d4088dc48678d0d

그래서 당신의 컴파일러 플래그에 -fPIE 또는 -fPIC 플래그 중 하나를 추가하려고합니다.

+1

고맙습니다. 다음은'CMakeLists.txt','set (CMAKE_CXX_FLAGS "-Wall -fPIC -std = C++ 11")'에서 사용하고있는 내용입니다. – sflee