I have the same error than here. There's no solution there and also I'm gonna try to explain it more clearly so hopefully someone has the solution. Also I've installed everything from the answer to this question.
I'm trying to compile a program that a friend has done in QT (linux). I've tryed it on Windows and it runs just fine, the problem is that I can't run it on Ubuntu 11.10.
This is the compiling output at QT:
...
glwidget.o:glwidget.cpp:function GLWidget::resizeGL(int, int): error: undefined reference to 'gluOrtho2D'
glwidget.o:glwidget.cpp:function GLWidget::projectScene(): error: undefined reference to 'gluOrtho2D'
make: Leaving directory...
collect2: ld returned 1 exit status
make: *** [QTapplication] Error 1
...
glu.h and gl.h are #included.
QT += opengl is put at the .pro
I don't know if it's problem of Ubuntu 11.10. I've read that it has some problems with the linker though I downloaded "binutils-gold" that supposedly fixed it. Also I've tryed to add manually the library with right click over the projects' .pro->Add Librarys, but it won't let me add nothing at "/usr/include/GL".
Finally, here's the complete compile output:
make: Entering directory `/home/daniel/Escritorio/Practica3-build-desktop-Desktop_Qt_4_8_0_for_GCC__Qt_SDK__Release'
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../QtSDK/Desktop/Qt/4.8.0/gcc/mkspecs/linux-g++ -I../Practica3 -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtCore -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtGui -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtOpenGL -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include -I../Practica3/SceneObjects -I../Practica3/SceneObjects/Auxiliar -I/usr/X11R6/include -I. -I. -I../Practica3 -I. -o main.o ../Practica3/main.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../QtSDK/Desktop/Qt/4.8.0/gcc/mkspecs/linux-g++ -I../Practica3 -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtCore -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtGui -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtOpenGL -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include -I../Practica3/SceneObjects -I../Practica3/SceneObjects/Auxiliar -I/usr/X11R6/include -I. -I. -I../Practica3 -I. -o mainwindow.o ../Practica3/mainwindow.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../QtSDK/Desktop/Qt/4.8.0/gcc/mkspecs/linux-g++ -I../Practica3 -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtCore -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtGui -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtOpenGL -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include -I../Practica3/SceneObjects -I../Practica3/SceneObjects/Auxiliar -I/usr/X11R6/include -I. -I. -I../Practica3 -I. -o glwidget.o ../Practica3/glwidget.cpp
../Practica3/glwidget.cpp:120:6: warning: unused parameter 'event' [-Wunused-parameter]
/home/daniel/QtSDK/Desktop/Qt/4.8.0/gcc/bin/moc -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../QtSDK/Desktop/Qt/4.8.0/gcc/mkspecs/linux-g++ -I../Practica3 -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtCore -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtGui -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtOpenGL -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include -I../Practica3/SceneObjects -I../Practica3/SceneObjects/Auxiliar -I/usr/X11R6/include -I. -I. -I../Practica3 -I. ../Practica3/mainwindow.h -o moc_mainwindow.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../QtSDK/Desktop/Qt/4.8.0/gcc/mkspecs/linux-g++ -I../Practica3 -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtCore -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtGui -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtOpenGL -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include -I../Practica3/SceneObjects -I../Practica3/SceneObjects/Auxiliar -I/usr/X11R6/include -I. -I. -I../Practica3 -I. -o moc_mainwindow.o moc_mainwindow.cpp
/home/daniel/QtSDK/Desktop/Qt/4.8.0/gcc/bin/moc -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../QtSDK/Desktop/Qt/4.8.0/gcc/mkspecs/linux-g++ -I../Practica3 -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtCore -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtGui -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtOpenGL -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include -I../Practica3/SceneObjects -I../Practica3/SceneObjects/Auxiliar -I/usr/X11R6/include -I. -I. -I../Practica3 -I. ../Practica3/glwidget.h -o moc_glwidget.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../QtSDK/Desktop/Qt/4.8.0/gcc/mkspecs/linux-g++ -I../Practica3 -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtCore -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtGui -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include/QtOpenGL -I../../QtSDK/Desktop/Qt/4.8.0/gcc/include -I../Practica3/SceneObjects -I../Practica3/SceneObjects/Auxiliar -I/usr/X11R6/include -I. -I. -I../Practica3 -I. -o moc_glwidget.o moc_glwidget.cpp
g++ -Wl,-O1 -Wl,-rpath,/home/daniel/QtSDK/Desktop/Qt/4.8.0/gcc/lib -o Practica3 main.o mainwindow.o glwidget.o scene.o pv2d.o regularpolygon.o obstacle.o sceneobject.o rectangle.o paintableobject.o segment.o point.o pen.o bouncingball.o circle.o moc_mainwindow.o moc_glwidget.o -L/home/daniel/QtSDK/Desktop/Qt/4.8.0/gcc/lib -L/usr/X11R6/lib -lQtOpenGL -lQtGui -lQtCore -lGL -lpthread
glwidget.o:glwidget.cpp:function GLWidget::resizeGL(int, int): error: undefined reference to 'gluOrtho2D'
make: Leaving directory `/home/daniel/Escritorio/Practica3-build-desktop-Desktop_Qt_4_8_0_for_GCC__Qt_SDK__Release'
glwidget.o:glwidget.cpp:function GLWidget::projectScene(): error: undefined reference to 'gluOrtho2D'
collect2: ld returned 1 exit status
make: *** [Practica3] Error 1
16:44:35: The process "/usr/bin/make" exited with code 2.
Error while building project Practica3 (target: Desktop)
When executing build step 'Make'
You need to add the relevant libraries to the linker options.
Libraries are added with -l options (lower-case L). They are not paths, but actual files that contain code. On Linux, those files have .so* extensions. On Windows, those are .dll files. Extensions vary on other platforms.
One of the questions you link states that you need the following libraries:
-lglut -lGL -lGLU -lGLEW
(gluOrtho2D is actually in libGLU, but you might be missing others.)
Read your IDE's docs to see how you're supposed to add those to the linker options, but many allow you to enter them just like that in the right area of the project settings.
If those libraries are not in the usual library paths on your machine (/lib, /usr/lib on Linux, possibly /lib64 and /usr/lib64, or same with 32 instead), you'll have to tell the linker to look in other directories.
For that, either your IDE has another option for linker search paths, or you can specify them in the same spot as the actual libraries. You use the -L switch for that.
-L for search paths, -l for libraries.
Recap: if you want to link with libsuperfoo.so that is in /usr/local/bar/libs, then the correct linker options are:
-L/usr/local/bar/libs -lsuperfoo
If you're using qmake, the only thing you need to add to the .pro file is (for the above hypothetical library):
LIBS += -L/usr/local/bar/libs -lsuperfoo
In windows, adding
LIBS += -lopengl32 -lglu32
in the .pro file and
#include<GL/glu.h>
in the source file solves the issue.
Related
Getting the following error in my library when trying to compile a library that is linking against Qt.
/opt/local/libexec/qt5/lib/QtCore.framework/QtCore:1:1: error: source file is not valid UTF-8
File.cxx is
#include <QtCore>
int main(){
return 0;
}
Using mac ports
Unsure if this is some weird mac problem or?
/opt/local/bin/clang++-mp-11 -DQT_CORE_LIB -D_LINUX_OS_ -D_XOPEN_SOURCE=600 -I/opt/local/libexec/qt5/include -isystem /opt/local/libexec/qt5/lib/QtCore.framework -isystem /opt/local/libexec/qt5/lib/QtCore.framework/Headers -isystem /opt/local/libexec/qt5/./mkspecs/macx-clang -g -std=c99 -pedantic -Wall -Wstrict-prototypes -Wwrite-strings -Wpointer-arith -Wcast-align -Werror -fPIC -std=gnu++11 -MD -MT fie.cxx.obj -MF file.cxx.obj.d -o file.cxx.obj -c file.cxx
Ive gotten similar results using xcode's compiler
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/CC
I am having some issues trying to link an executable which transitively uses Qt5.
I have configured my project using CMake with the option CMAKE_POSITION_INDEPENDENT_CODE = ON but still, when compiling the executable, Qt5 complains that I should use fPIC.
[ 99%] Building CXX object tools/deSimRunner/CMakeFiles/deSimRunner.dir/main.cpp.o
cd /home/jjcasmar/projects/Hybrid/Desilico/prj/Release/tools/deSimRunner && /home/jjcasmar/usr/local/bin/c++ -DBOOST_ALL_DYN_LINK -DFMT_SHARED -DHAVE_CUDA -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -D_GLIBCXX_USE_CXX11_ABI=1 -I/home/jjcasmar/projects/Hybrid/Desilico/src/deCore -I/home/jjcasmar/projects/Hybrid/Desilico/src/deCore/.. -I/home/jjcasmar/projects/Hybrid/Desilico/src/deGeom/.. -I/opt/cuda/include -I/home/jjcasmar/projects/Hybrid/Desilico/src/deSim/.. -isystem /home/jjcasmar/.conan/data/eigen/3.3.7/conan/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include/eigen3 -isystem /home/jjcasmar/.conan/data/rapidjson/1.1.0/bincrafters/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -isystem /home/jjcasmar/.conan/data/boost/1.71.0/conan/stable/package/393cfc058d5be864014f06fc0bb0e29c6845d9e9/include -isystem /home/jjcasmar/.conan/data/zlib/1.2.11/conan/stable/package/1d877a3df840030e6a8abb74c5ffb9088d08b47a/include -isystem /home/jjcasmar/.conan/data/bzip2/1.0.8/conan/stable/package/a5875aed3fc7ae8dd0488f7e5e99acbc480d721d/include -isystem /usr/include/qt -isystem /usr/include/qt/QtCore -isystem /usr/lib/qt/mkspecs/linux-g++ -isystem /home/jjcasmar/.conan/data/spdlog/1.4.2/bincrafters/stable/package/f31849fd5982a882fc905666fe297f0c231b10af/include -isystem /home/jjcasmar/.conan/data/fmt/6.0.0/bincrafters/stable/package/ca4b767114c8e107f72671a3380d9917e2b9adff/include -isystem /home/jjcasmar/.conan/data/OpenMesh/7.1/desilico/stable/package/b80d46004713aa37d6a90b42e2a326a056a237b5/include -isystem /home/jjcasmar/.conan/data/nanoflann/1.3.0/desilico/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -isystem /home/jjcasmar/usr/local/include -isystem /home/jjcasmar/.conan/data/cereal/1.2.2/conan/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -isystem /home/jjcasmar/.conan/data/glm/0.9.9.5/g-truc/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -isystem /usr/include/qt/QtGui -isystem /home/jjcasmar/.conan/data/range-v3/0.9.1/ericniebler/stable/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -fopenmp -O3 -DNDEBUG -fPIE -DNON_COMMERCIAL_LICENSE -std=gnu++14 -o CMakeFiles/deSimRunner.dir/main.cpp.o -c /home/jjcasmar/projects/Hybrid/Desilico/tools/deSimRunner/main.cpp
In file included from /usr/include/qt/QtCore/qjsonvalue.h:43,
from /usr/include/qt/QtCore/qjsondocument.h:43,
from /usr/include/qt/QtCore/QJsonDocument:1,
from /home/jjcasmar/projects/Hybrid/Desilico/tools/deSimRunner/main.cpp:23:
/usr/include/qt/QtCore/qglobal.h:1204: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. "\
I have these two options enabled in my main CMakeLists.txt file
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(BUILD_SHARED_LIBS ON)
How should I correctly add the fPIC option for my final executable?
Your error states:
"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)."
However, your compilation flags only contain fPIE, not fPIC:
/usr/local/bin/c++ -DBOOST_ALL_DYN_LINK ...
...
-fopenmp -O3 -DNDEBUG -fPIE -DNON_COMMERCIAL_LICENSE -std=gnu++14 -o CMakeFiles/deSimRunner.dir/main.cpp.o -c /home/jjcasmar/projects/Hybrid/Desilico/tools/deSimRunner/main.cpp
You were correct to try using CMAKE_POSITION_INDEPENDENT_CODE, but this variable may not set the flags you expect. The fairly undocumented behavior for this variable is this:
If the target is a library, the flag -fPIC is added by CMake to the compilation and linker steps.
If the target is an executable, the flag -fPIE is added by CMake to the compilation and linker steps.
Thus, you will have to add the -fPIC flag for your executable somewhat manually, with something like this:
add_executable(deSimRunner ... )
target_compile_options(deSimRunner PRIVATE -fPIC)
For example, lets take a default QT widget application that we get. So instead of using QT Creator if we want to build using the terminal then what is the way to do that?
Basically we want to produce the build for the project which actually also contains the dmg file.
Compile output when done using QT Creator shown is below when no change is done :
14:37:04: Running steps for project QTDefaultProj...
14:37:04: Configuration unchanged, skipping qmake step.
14:37:04: Starting: "/usr/bin/make"
make: Nothing to be done for `first'.
14:37:05: The process "/usr/bin/make" exited normally.
14:37:05: Elapsed time: 00:00.
Compile Output after changing the directory :
15:31:50: Running steps for project QTDefaultProj...
15:31:50: Starting: "/Users/arqam/Desktop/ImageToCartoon/QT/5.10.0/clang_64/bin/qmake" /Users/arqam/Desktop/Junk/QTDefaultProj/QTDefaultProj.pro -spec macx-clang CONFIG+=debug CONFIG+=x86_64 CONFIG+=qml_debug
Info: creating stash file /Users/arqam/Desktop/Junk/build-QTDefaultProj-Desktop_Qt_5_10_0_clang_64bit-Debug-2/.qmake.stash
15:31:50: The process "/Users/arqam/Desktop/ImageToCartoon/QT/5.10.0/clang_64/bin/qmake" exited normally.
15:31:50: Starting: "/usr/bin/make" qmake_all
make: Nothing to be done for `qmake_all'.
15:31:51: The process "/usr/bin/make" exited normally.
15:31:51: Starting: "/usr/bin/make"
/Users/arqam/Desktop/ImageToCartoon/QT/5.10.0/clang_64/bin/uic ../QTDefaultProj/mainwindow.ui -o ui_mainwindow.h
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -std=gnu++11 -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.10 -Wall -W -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../QTDefaultProj -I. -I../../ImageToCartoon/QT/5.10.0/clang_64/lib/QtWidgets.framework/Headers -I../../ImageToCartoon/QT/5.10.0/clang_64/lib/QtGui.framework/Headers -I../../ImageToCartoon/QT/5.10.0/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I../../ImageToCartoon/QT/5.10.0/clang_64/mkspecs/macx-clang -F/Users/arqam/Desktop/ImageToCartoon/QT/5.10.0/clang_64/lib -o main.o ../QTDefaultProj/main.cpp
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -std=gnu++11 -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.10 -Wall -W -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../QTDefaultProj -I. -I../../ImageToCartoon/QT/5.10.0/clang_64/lib/QtWidgets.framework/Headers -I../../ImageToCartoon/QT/5.10.0/clang_64/lib/QtGui.framework/Headers -I../../ImageToCartoon/QT/5.10.0/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I../../ImageToCartoon/QT/5.10.0/clang_64/mkspecs/macx-clang -F/Users/arqam/Desktop/ImageToCartoon/QT/5.10.0/clang_64/lib -o mainwindow.o ../QTDefaultProj/mainwindow.cpp
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -pipe -stdlib=libc++ -g -std=gnu++11 -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.10 -Wall -W -dM -E -o moc_predefs.h ../../ImageToCartoon/QT/5.10.0/clang_64/mkspecs/features/data/dummy.cpp
/Users/arqam/Desktop/ImageToCartoon/QT/5.10.0/clang_64/bin/moc -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB --include ./moc_predefs.h -I/Users/arqam/Desktop/ImageToCartoon/QT/5.10.0/clang_64/mkspecs/macx-clang -I/Users/arqam/Desktop/Junk/QTDefaultProj -I/Users/arqam/Desktop/ImageToCartoon/QT/5.10.0/clang_64/lib/QtWidgets.framework/Headers -I/Users/arqam/Desktop/ImageToCartoon/QT/5.10.0/clang_64/lib/QtGui.framework/Headers -I/Users/arqam/Desktop/ImageToCartoon/QT/5.10.0/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/8.1.0/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include -F/Users/arqam/Desktop/ImageToCartoon/QT/5.10.0/clang_64/lib ../QTDefaultProj/mainwindow.h -o moc_mainwindow.cpp
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -g -std=gnu++11 -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.10 -Wall -W -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../QTDefaultProj -I. -I../../ImageToCartoon/QT/5.10.0/clang_64/lib/QtWidgets.framework/Headers -I../../ImageToCartoon/QT/5.10.0/clang_64/lib/QtGui.framework/Headers -I../../ImageToCartoon/QT/5.10.0/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/AGL.framework/Headers -I. -I../../ImageToCartoon/QT/5.10.0/clang_64/mkspecs/macx-clang -F/Users/arqam/Desktop/ImageToCartoon/QT/5.10.0/clang_64/lib -o moc_mainwindow.o moc_mainwindow.cpp
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -stdlib=libc++ -headerpad_max_install_names -arch x86_64 -Wl,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -mmacosx-version-min=10.10 -Wl,-rpath,#executable_path/Frameworks -Wl,-rpath,/Users/arqam/Desktop/ImageToCartoon/QT/5.10.0/clang_64/lib -o QTDefaultProj.app/Contents/MacOS/QTDefaultProj main.o mainwindow.o moc_mainwindow.o -F/Users/arqam/Desktop/ImageToCartoon/QT/5.10.0/clang_64/lib -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL
15:31:55: The process "/usr/bin/make" exited normally.
15:31:55: Elapsed time: 00:05.
With help from m7913d I am finally able to build the QT project from terminal without using QT Creator.
So steps are :
Create an empty folder name it as build-debug for example.
Inside your build-debug folder run the following command :
pathToQTDirectory/QT/5.10.0/clang_64/bin/qmake pathToQTProjectFolder/MyProject/
/usr/bin/make qmake_all
/usr/bin/make
If the above doesn't work then try seeing in the QT Creator compiler output the steps involved when you specify a new directory as the build directory.
With cmake 3.5.0 (on windows) and CMAKE_AUTORCC and one rcc.qrc file in add_executable every build (using ninja) compiles the rcc file and links again even if there is nothing changed. Is that normal or is there something missing in my cmakelists.txt file?
cmake_minimum_required(VERSION 3.2)
project(auto_moc_uic_rcc)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
find_package (Qt5Widgets REQUIRED)
add_executable(${PROJECT_NAME}
main.cpp
MainWindow
MainWindow.ui
rcc.qrc
)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets)
If I remove CMAKE_AUTORCC and replace it with qt5_add_resources(RCC rcc.qrc) and add ${RCC} to the executable, the project only builds and links if there is actually something changed.
Output of cmake (from cmake_gui):
The C compiler identification is GNU 4.9.1
The CXX compiler identification is GNU 4.9.1
Check for working C compiler using: Ninja
Check for working C compiler using: Ninja -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler using: Ninja
Check for working CXX compiler using: Ninja -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
Configuring done
First run ninja -v:
[1/7] cmd.exe /C "cd /D E:\source\builds\qt\debug\Test\junk\auto_moc_uic_rcc\auto_moc_uic_rcc && E:\bin\cmake\bin\cmake.exe -E cmake_autogen E:/source/builds/qt/debug/Test/junk/auto_moc_uic_rcc/auto_moc_uic_rcc/CMakeFiles/auto_moc_uic_rcc_automoc.dir/ Debug"
Generating ui_MainWindow.h
Generating moc_MainWindow.cpp
[2/7] E:\Qt\mingw\bin\c++.exe -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -I. -IE:/source/src/Test/junk/autouic/auto_moc_uic-rcc -isystem E:/Qt/qt/include -isystem E:/Qt/qt/include/QtWidgets -isystem E:/Qt/qt/include/QtGui -isystem E:/Qt/qt/include/QtCore -isystem E:/Qt/qt/mkspecs/win32-g++ -g -MMD -MT CMakeFiles/auto_moc_uic_rcc.dir/CMakeFiles/auto_moc_uic_rcc.dir/qrc_rcc.cpp.obj -MF CMakeFiles/auto_moc_uic_rcc.dir/CMakeFiles/auto_moc_uic_rcc.dir/qrc_rcc.cpp.obj.d -o CMakeFiles/auto_moc_uic_rcc.dir/CMakeFiles/auto_moc_uic_rcc.dir/qrc_rcc.cpp.obj -c CMakeFiles/auto_moc_uic_rcc.dir/qrc_rcc.cpp
[3/7] E:\Qt\mingw\bin\c++.exe -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -I. -IE:/source/src/Test/junk/autouic/auto_moc_uic-rcc -isystem E:/Qt/qt/include -isystem E:/Qt/qt/include/QtWidgets -isystem E:/Qt/qt/include/QtGui -isystem E:/Qt/qt/include/QtCore -isystem E:/Qt/qt/mkspecs/win32-g++ -g -MMD -MT CMakeFiles/auto_moc_uic_rcc.dir/MainWindow.cpp.obj -MF CMakeFiles/auto_moc_uic_rcc.dir/MainWindow.cpp.obj.d -o CMakeFiles/auto_moc_uic_rcc.dir/MainWindow.cpp.obj -c E:/source/src/Test/junk/autouic/auto_moc_uic-rcc/MainWindow.cpp
[4/7] E:\Qt\mingw\bin\c++.exe -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -I. -IE:/source/src/Test/junk/autouic/auto_moc_uic-rcc -isystem E:/Qt/qt/include -isystem E:/Qt/qt/include/QtWidgets -isystem E:/Qt/qt/include/QtGui -isystem E:/Qt/qt/include/QtCore -isystem E:/Qt/qt/mkspecs/win32-g++ -g -MMD -MT CMakeFiles/auto_moc_uic_rcc.dir/main.cpp.obj -MF CMakeFiles/auto_moc_uic_rcc.dir/main.cpp.obj.d -o CMakeFiles/auto_moc_uic_rcc.dir/main.cpp.obj -c E:/source/src/Test/junk/autouic/auto_moc_uic-rcc/main.cpp
[5/7] cmd.exe /c
[6/7] E:\Qt\mingw\bin\c++.exe -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -I. -IE:/source/src/Test/junk/autouic/auto_moc_uic-rcc -isystem E:/Qt/qt/include -isystem E:/Qt/qt/include/QtWidgets -isystem E:/Qt/qt/include/QtGui -isystem E:/Qt/qt/include/QtCore -isystem E:/Qt/qt/mkspecs/win32-g++ -g -MMD -MT CMakeFiles/auto_moc_uic_rcc.dir/auto_moc_uic_rcc_automoc.cpp.obj -MF CMakeFiles/auto_moc_uic_rcc.dir/auto_moc_uic_rcc_automoc.cpp.obj.d -o CMakeFiles/auto_moc_uic_rcc.dir/auto_moc_uic_rcc_automoc.cpp.obj -c auto_moc_uic_rcc_automoc.cpp
[7/7] cmd.exe /C "cd . && E:\Qt\mingw\bin\c++.exe -g CMakeFiles/auto_moc_uic_rcc.dir/main.cpp.obj CMakeFiles/auto_moc_uic_rcc.dir/MainWindow.cpp.obj CMakeFiles/auto_moc_uic_rcc.dir/auto_moc_uic_rcc_automoc.cpp.obj CMakeFiles/auto_moc_uic_rcc.dir/CMakeFiles/auto_moc_uic_rcc.dir/qrc_rcc.cpp.obj -o auto_moc_uic_rcc.exe -Wl,--out-implib,libauto_moc_uic_rcc.dll.a -Wl,--major-image-version,0,--minor-image-version,0 E:/Qt/qt/lib/libQt5Widgetsd.a E:/Qt/qt/lib/libQt5Guid.a E:/Qt/qt/lib/libQt5Cored.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
Second run ninja -v. Consecutive runs have the same output:
[1/3] cmd.exe /C "cd /D E:\source\builds\qt\debug\Test\junk\auto_moc_uic_rcc\auto_moc_uic_rcc && E:\bin\cmake\bin\cmake.exe -E cmake_autogen E:/source/builds/qt/debug/Test/junk/auto_moc_uic_rcc/auto_moc_uic_rcc/CMakeFiles/auto_moc_uic_rcc_automoc.dir/ Debug"
[2/3] E:\Qt\mingw\bin\c++.exe -DQT_CORE_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -I. -IE:/source/src/Test/junk/autouic/auto_moc_uic-rcc -isystem E:/Qt/qt/include -isystem E:/Qt/qt/include/QtWidgets -isystem E:/Qt/qt/include/QtGui -isystem E:/Qt/qt/include/QtCore -isystem E:/Qt/qt/mkspecs/win32-g++ -g -MMD -MT CMakeFiles/auto_moc_uic_rcc.dir/CMakeFiles/auto_moc_uic_rcc.dir/qrc_rcc.cpp.obj -MF CMakeFiles/auto_moc_uic_rcc.dir/CMakeFiles/auto_moc_uic_rcc.dir/qrc_rcc.cpp.obj.d -o CMakeFiles/auto_moc_uic_rcc.dir/CMakeFiles/auto_moc_uic_rcc.dir/qrc_rcc.cpp.obj -c CMakeFiles/auto_moc_uic_rcc.dir/qrc_rcc.cpp
[3/3] cmd.exe /C "cd . && E:\Qt\mingw\bin\c++.exe -g CMakeFiles/auto_moc_uic_rcc.dir/main.cpp.obj CMakeFiles/auto_moc_uic_rcc.dir/MainWindow.cpp.obj CMakeFiles/auto_moc_uic_rcc.dir/auto_moc_uic_rcc_automoc.cpp.obj CMakeFiles/auto_moc_uic_rcc.dir/CMakeFiles/auto_moc_uic_rcc.dir/qrc_rcc.cpp.obj -o auto_moc_uic_rcc.exe -Wl,--out-implib,libauto_moc_uic_rcc.dll.a -Wl,--major-image-version,0,--minor-image-version,0 E:/Qt/qt/lib/libQt5Widgetsd.a E:/Qt/qt/lib/libQt5Guid.a E:/Qt/qt/lib/libQt5Cored.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
Here is the output of ninja -v when I use qt5_add_resources(RCC rcc.qrc) instead of CMAKE_AUTORCC:
[1/8] cmd.exe /C "cd /D E:\source\builds\qt\debug\Test\junk\auto_moc_uic_rcc\auto_moc_uic && E:\bin\CMake\bin\cmake.exe -E cmake_autogen E:/source/builds/qt/debug/Test/junk/auto_moc_uic_rcc/auto_moc_uic/CMakeFiles/auto_moc_uic_automoc.dir/ """
Generating ui_MainWindow.h
Generating moc_MainWindow.cpp
[2/8] cmd.exe /C "cd /D E:\source\builds\qt\debug\Test\junk\auto_moc_uic_rcc\auto_moc_uic && E:\Qt\qt\bin\rcc.exe -name rcc -o E:/source/builds/qt/debug/Test/junk/auto_moc_uic_rcc/auto_moc_uic/qrc_rcc.cpp E:/source/src/Test/junk/autouic/auto_moc_uic/rcc.qrc"
[3/8] E:\Qt\mingw\bin\g++.exe -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -I. -IE:/source/src/Test/junk/autouic/auto_moc_uic -isystem E:/Qt/qt/include -isystem E:/Qt/qt/include/QtWidgets -isystem E:/Qt/qt/include/QtGui -isystem E:/Qt/qt/include/QtCore -isystem E:/Qt/qt/mkspecs/win32-g++ -MMD -MT CMakeFiles/auto_moc_uic.dir/MainWindow.cpp.obj -MF CMakeFiles/auto_moc_uic.dir/MainWindow.cpp.obj.d -o CMakeFiles/auto_moc_uic.dir/MainWindow.cpp.obj -c E:/source/src/Test/junk/autouic/auto_moc_uic/MainWindow.cpp
[4/8] E:\Qt\mingw\bin\g++.exe -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -I. -IE:/source/src/Test/junk/autouic/auto_moc_uic -isystem E:/Qt/qt/include -isystem E:/Qt/qt/include/QtWidgets -isystem E:/Qt/qt/include/QtGui -isystem E:/Qt/qt/include/QtCore -isystem E:/Qt/qt/mkspecs/win32-g++ -MMD -MT CMakeFiles/auto_moc_uic.dir/qrc_rcc.cpp.obj -MF CMakeFiles/auto_moc_uic.dir/qrc_rcc.cpp.obj.d -o CMakeFiles/auto_moc_uic.dir/qrc_rcc.cpp.obj -c qrc_rcc.cpp
[5/8] E:\Qt\mingw\bin\g++.exe -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -I. -IE:/source/src/Test/junk/autouic/auto_moc_uic -isystem E:/Qt/qt/include -isystem E:/Qt/qt/include/QtWidgets -isystem E:/Qt/qt/include/QtGui -isystem E:/Qt/qt/include/QtCore -isystem E:/Qt/qt/mkspecs/win32-g++ -MMD -MT CMakeFiles/auto_moc_uic.dir/main.cpp.obj -MF CMakeFiles/auto_moc_uic.dir/main.cpp.obj.d -o CMakeFiles/auto_moc_uic.dir/main.cpp.obj -c E:/source/src/Test/junk/autouic/auto_moc_uic/main.cpp
[6/8] cmd.exe /c
[7/8] E:\Qt\mingw\bin\g++.exe -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -I. -IE:/source/src/Test/junk/autouic/auto_moc_uic -isystem E:/Qt/qt/include -isystem E:/Qt/qt/include/QtWidgets -isystem E:/Qt/qt/include/QtGui -isystem E:/Qt/qt/include/QtCore -isystem E:/Qt/qt/mkspecs/win32-g++ -MMD -MT CMakeFiles/auto_moc_uic.dir/auto_moc_uic_automoc.cpp.obj -MF CMakeFiles/auto_moc_uic.dir/auto_moc_uic_automoc.cpp.obj.d -o CMakeFiles/auto_moc_uic.dir/auto_moc_uic_automoc.cpp.obj -c auto_moc_uic_automoc.cpp
[8/8] cmd.exe /C "cd . && E:\Qt\mingw\bin\g++.exe CMakeFiles/auto_moc_uic.dir/main.cpp.obj CMakeFiles/auto_moc_uic.dir/MainWindow.cpp.obj CMakeFiles/auto_moc_uic.dir/qrc_rcc.cpp.obj CMakeFiles/auto_moc_uic.dir/auto_moc_uic_automoc.cpp.obj -o auto_moc_uic.exe -Wl,--out-implib,libauto_moc_uic.dll.a -Wl,--major-image-version,0,--minor-image-version,0 E:/Qt/qt/lib/libQt5Widgets.a E:/Qt/qt/lib/libQt5Gui.a E:/Qt/qt/lib/libQt5Core.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
And consecutive runs:
[1/1] cmd.exe /C "cd /D E:\source\builds\qt\debug\Test\junk\auto_moc_uic_rcc\auto_moc_uic && E:\bin\CMake\bin\cmake.exe -E cmake_autogen E:/source/builds/qt/debug/Test/junk/auto_moc_uic_rcc/auto_moc_uic/CMakeFiles/auto_moc_uic_automoc.dir/ """
I try to compile my app, QNX and Qt is all set.
in line 3.
C:/QNX650/target/qnx6armle-v7 is in the QNX_TARGET env var, and C:/QNX650/host/win32/x86 is QNX_HOST env var. this is strange they combine together.
Qtcreator, debug mode.this is the only output
qcc -Vgcc_ntoarmv7le -c -Wno-psabi -lang-c++ -g -Wall -W -D_REENTRANT -fPIE -DQT_NO_CLIPBOARD -DHMI_PLUGIN_DEBUG -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_QUICK_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../../../../QtQNX/Qt5.0.2/5.0.2/qnx_armv7le/mkspecs/qnx-armv7le-qcc -I../MQueue_Demo -I../MQueue_Demo/qtquick2applicationviewer -I../MQueue_Demo/depends/MQueue/include -I../MQueue_Demo/depends/MQueue/include/native -I../MQueue_Demo/depends/hmi_interfaces -I../../../../QtQNX/Qt5.0.2/5.0.2/qnx_armv7le/include -I../../../../QtQNX/Qt5.0.2/5.0.2/qnx_armv7le/include/QtQuick -I../../../../QtQNX/Qt5.0.2/5.0.2/qnx_armv7le/include/QtQml -I../../../../QtQNX/Qt5.0.2/5.0.2/qnx_armv7le/include/QtNetwork -I../../../../QtQNX/Qt5.0.2/5.0.2/qnx_armv7le/include/QtGui -I../../../../QtQNX/Qt5.0.2/5.0.2/qnx_armv7le/include/QtGui/5.0.2 -I../../../../QtQNX/Qt5.0.2/5.0.2/qnx_armv7le/include/QtGui/5.0.2/QtGui -I../../../../QtQNX/Qt5.0.2/5.0.2/qnx_armv7le/include/QtCore -I. -IC:\QNX650\target\qnx6\armle-v7/target/qnx6/usr/include -IC:\QNX650\target\qnx6\armle-v7/target/qnx6/usr/include/freetype2 -I. -o main.obj ../MQueue_Demo/main.cpp
cc: unknown target 'gcc_ntoarmv7le+debug'
cc: no targets defined in C:/QNX650/target/qnx6/armle-v7/host/win32/x86/etc/qcc!
make: *** [main.obj] Error 1
09:46:25: The process "C:\QNX650\host\win32\x86\usr\bin\make.exe" exited with code 2.