I have a directory with Qt 5.15 for gcc_64 on Ubuntu. I know I need to link the proper .so (or .la?) file in the lib subdirectory and include the headers from the include directories. I would need to do this for several Qt modules. This is my second day using Linux and Bazel, and I'm not sure how to get a basic build setup going. I have tried using cc_import and cc_library so far without sucess.
I know everything is done automatically for you when using Qt Creator, but I am using Visual Sudio Code with a the Bazel build system for integration of other projects.
Here is a piece of the compiler input for a sample project when using Qt Creator.
g++ -c -pipe -g -Wall -Wextra -D_REENTRANT -fPIC -DQT_QML_DEBUG
-DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../addressbook -I. -I/home/joseph/Qt/5.15.0/gcc_64/include -I/home/joseph/Qt/5.15.0/gcc_64/include/QtWidgets -I/home/joseph/Qt/5.15.0/gcc_64/include/QtGui -I/home/joseph/Qt/5.15.0/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I/home/joseph/Qt/5.15.0/gcc_64/mkspecs/linux-g++
-o addresswidget.o ../addressbook/addresswidget.cpp
I see macros, includes, and libraries added. What is all the other stuff?
An alternate route I have decided is to build a library out of a qt project and use that with Bazel. With this, how would I access GUI objects? Would I have signal and slots?
Related
I have tried this on multiple platforms, experiencing the same issue every time.
I successfully build and run my C++ OpenFrameworks application using QtCreator - no problems are encountered.
Then, I successfully use qmake to generate the project file.
Yet when I attempt to make the executable, I receive the following error:
make
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -O2 -std=gnu++1z -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -mmacosx-version-min=12 -Wall -Wextra -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -I/opt/homebrew/lib/QtGui.framework/Headers -I/opt/homebrew/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/AGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/AGL.framework/Headers -I/opt/homebrew/share/qt/mkspecs/macx-clang -F/opt/homebrew/lib -o main.o src/main.cpp
src/main.cpp:1:10: fatal error: 'ofMain.h' file not found
#include "ofMain.h"
^~~~~~~~~~
1 error generated.
make: *** [main.o] Error 1
I can go into the .pro file and add things to the include path manually, but I don't see why these includes aren't generated automatically?
I think I recognized your problem.
The file name is main.cpp in the src/ folder. Based on its location in the src/ folder, I think your ofMain.h file is also in the src/ folder. Now a question: did you add src/ to your include path? If not with the following line:
INCLUDEPATH += \
src/
It should work now I hope.
Have a nice day!
Since I installed Catalina, any attempt to compile an R package fails. My system is set up to use home-brew. The failure messages look like this:
/usr/local/clang8/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include -I/usr/local/clang8/include -I/usr/local/Cellar/gcc/8.3.0_2/include -fopenmp -fPIC -Wall -g -O2 -c R_register_native.c -o R_register_native.o
In file included from R_register_native.c:1:
/Library/Frameworks/R.framework/Resources/include/R.h:55:11: fatal error: 'stdlib.h' file not found
# include <stdlib.h> /* Not used by R itself, but widely assumed in packages */
After googling I found this link in the home-brew site on GitHub. I can't follow much of the discussion but it seems that Apple removed the usr/include directory and that the home-brew folks are looking for a solution. I don't immediately have a need to compile these packages so my plan is to wait until home-brew finds a solution. But if there is an easy one now, please share.
After some additional searching I found this link with a bunch of discussion about this problem, a lot of which I didn't understand. But this bit of code seemed promising.
sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/* /usr/local/include/
I ran it, rebooted my mac, opened RStudio and got the list of new package updates. Ran the update, answering yes to compile. Lots of messages and some warnings but at the end of it all, there were no errors. But all the messages start with something like
/usr/local/clang8/bin/clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include -I/usr/local/clang8/include -I/usr/local/Cellar/gcc/8.3.0_2/include -fopenmp -fPIC -Wall -g -O2 -c R_register_native.c -o R_register_native.o
When I cd into /usr/local/clang8/bin and get the version of clang it is Apple clang version 11.0.0. Also clang symlinks to clang-8 and clang++ symlinks to clang
The contents of /usr/local/Cellar/gcc is a directory called 9.2.0_1. When I go to /usr/bin and run gcc --version I get messages about this being Apple clang version 11.0.0. It seems like R is compiling using the Apple clang version. Is that a problem? Is there some way to move everything to using the brew version of clang? FYI, here's my current path - /usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Apple/bin:/Library/TeX/texbin:/opt/X11/bin:/usr/local/CrossPack-AVR/bin:/usr/local/git/bin
Since Qt 5.7, C++11 support is mandatory. For some reason one large old project does not accept the C++11 arguments. It doesn't matter if I use "CONFIG += c++11" or any other; C++11 only features do not work and therefor I can not compile the project.
C:\QtE\5.7\android_armv7\include\QtCore\qbasicatomic.h:61: error:
error "Qt requires C++11 support"
^
The compiler arguments do contain "-std=c++11 -std=c++0x" if I use "CONFIG += c++11" in the .pro file. The target platform is Android ArmV7. SDK R24 and NDK R10E are used.
C:\SDKs\Android\android-ndk-r10e/toolchains/arm-linux-androideabi-4.9/prebuilt/windows/bin/arm-linux-androideabi-g++ -c -Wno-psabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -DANDROID -Wa,--noexecstack -fno-builtin-memmove -std=c++11 -fPIC -ansi -fpermissive -finline-functions -Wno-long-long -g -g -marm -O0 -fno-omit-frame-pointer -O2 -Wall -Wno-psabi -W -D_REENTRANT -fPIC -DPJ_IS_LITTLE_ENDIAN=1 -DPJ_IS_BIG_ENDIAN=0 -DQZXING_LIBRARY -DZXING_ICONV_CONST -DDISABLE_LIBRARY_FEATURES -DNOFMAXL -DBOTAN_DLL=Q_DECL_EXPORT -DBOTAN_TARGET_OS_HAS_GETTIMEOFDAY -DBOTAN_HAS_ALLOC_MMAP -DBOTAN_HAS_ENTROPY_SRC_DEV_RANDOM -DBOTAN_HAS_ENTROPY_SRC_EGD -DBOTAN_HAS_ENTROPY_SRC_FTW -DBOTAN_HAS_ENTROPY_SRC_UNIX -DBOTAN_HAS_MUTEX_PTHREAD -DBOTAN_HAS_PIPE_UNIXFD_IO -DBOTAN_TARGET_OS_IS_LINUX -DBOTAN_TARGET_OS_HAS_CLOCK_GETTIME -DBOTAN_TARGET_OS_HAS_DLOPEN -DBOTAN_TARGET_OS_HAS_GMTIME_R -DBOTAN_TARGET_OS_HAS_POSIX_MLOCK -DBOTAN_HAS_DYNAMICALLY_LOADED_ENGINE -DBOTAN_HAS_DYNAMIC_LOADER -DBOTAN_BUILD_COMPILER_IS_GCC -DQT_QML_DEBUG -DQT_QUICKWIDGETS_LIB -DQT_WIDGETS_LIB -DQT_QUICK_LIB -DQT_MULTIMEDIA_LIB -DQT_GUI_LIB -DQT_QML_LIB -DQT_WEBSOCKETS_LIB -DQT_NETWORK_LIB -DQT_POSITIONING_LIB -DQT_ANDROIDEXTRAS_LIB -DQT_CORE_LIB
Any idea is welcome :)
According to this questions accepted answer, It says CONFIG += c++11 requires Qt 5. Are you sure you are using Qt 5?
Also, It also says if you use gcc/clang you should use QMAKE_CXXFLAGS += -std=c++11 (or QMAKE_CXXFLAGS += -std=c++0x).
since you are building an android project, it will use gcc. Change CONFIG += c++11 to QMAKE_CXXFLAGS += -std=c++11 and tell me what happened.
One of the .pri sub-projects used the argument "-ansi" which is equivalent to "-std=c++98". This prevents the compilation with C++11.
Thanks to Oktalist for the solution comment :)
I tried the instructions of building latest QT5-Alpha(http://qt-project.org/wiki/Qt-5-Alpha
http://qt-project.org/wiki/Building_Qt_5_from_Git)
from GIT,but facing compilation in wayland files
Ubuntu Linux 11.10
__make[4]: Entering directory `/home/xyz/build/newqt5/qt5/qtwayland/src/plugins/platforms/wayland'
g++ -c -pipe -g -fvisibility=hidden -fvisibility-inlines-hidden -D_REENTRANT -Wall -W -fPIC -DQT_NO_LIBUDEV -DQ_PLATFORM_WAYLAND -DQT_NO_WAYLAND_XKB -DQT_WAYLAND_GL_SUPPORT -DQT_WAYLAND_WINDOWMANAGER_SUPPORT -DQ_FONTCONFIGDATABASE -DQT_COMPILES_IN_HARFBUZZ -DQT_PLUGIN -DQT_GUI_LIB -DQT_CORE_LIB -I/home/xyz/build/newqt5/qt5/qtbase/mkspecs/linux-g++ -I. -I/home/xyz/build/newqt5/qt5/qtbase/include/QtCore/5.0.0 -I/home/xyz/build/newqt5/qt5/qtbase/include/QtCore/5.0.0/QtCore -I/home/xyz/build/newqt5/qt5/qtbase/include/QtCore -I/home/xyz/build/newqt5/qt5/qtbase/include/QtGui/5.0.0 -I/home/xyz/build/newqt5/qt5/qtbase/include/QtGui/5.0.0/QtGui -I/home/xyz/build/newqt5/qt5/qtbase/include/QtGui -I/home/xyz/build/newqt5/qt5/qtbase/include/QtPlatformSupport/5.0.0 -I/home/xyz/build/newqt5/qt5/qtbase/include/QtPlatformSupport/5.0.0/QtPlatformSupport -I/home/xyz/build/newqt5/qt5/qtbase/include/QtPlatformSupport -I/home/xyz/build/newqt5/qt5/qtbase/include -I../../../shared -Igl_integration/xcomposite_share -I.moc/debug-shared -o .obj/debug-shared/qwaylandintegration.o qwaylandintegration.cpp
In file included from qwaylandshmwindow.h:45:0,
from qwaylandintegration.cpp:46:
qwaylandwindow.h:112:18: error: ‘wl_callback_listener’ does not name a type
make[4]: *** [.obj/debug-shared/qwaylandintegration.o] Error 1_
Any pointers to overcome this?
Download the alpha source package here: http://releases.qt-project.org/qt5.0/alpha/ and use the steps in README file.
The master in git is NOT what was released as alpha. The build scripts are different. You have to wait for them to add alpha tag to pull it from git. But why not just grab the gz file?
I built a Qt project in Debug mode with Qt Creator, ran Callgrind to generate profiling data and tried loading it into Cachegrind. I noticed that I only see profiling information for Qt classes, so I figured I must have forgotten to turn on a crucial flag.
Qt Creator's qmake command looks like this:
qmake /path/to/project/MyProject/MyProject.pro -r -spec linux-g++-64 CONFIG+=debug
Sample compile output for one file:
g++ -c -m64 -pipe -g -Wall -W -D_REENTRANT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I../Flowchart -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I. -I. -I../Flowchart -I. -o main.o ../Flowchart/main.cpp
The -g flag is there, so debug information should be available. I verified this by running gdb on the executable and trying to look at some random source code with l.
The Callgrind command I used was:
valgrind --tool=callgrind ./MyProject
What am I missing here?
You should do:
valgrind --tool=callgrind --trace-children=yes --demangle=yes ./MyProject
Also depending on the distribution of Linux you may have to make sure that you have the Debug information in the QT libraries you are linking against.