I am trying to cross compile Qt on Ubuntu Linux for ARM. But I get the following error:
bin/rcc: File does not exist 'dialogs/qprintdialog.qrc'
The build command which produces this is:
bin/rcc -name qprintdialog dialogs/qprintdialog.qrc -o .rcc/release-shared/qrc_qprintdialog.cpp
I tried to manually execute this command by giving an absolute path to dialogs/qprintdialog.qrc but still have the same error although dialogs/qprintdialog.qrc does exist.
I have configured Qt as:
./configure -no-exceptions -no-accessibility -no-xsync -no-xinerama -no-xcursor -no-xfixes -no-xrandr -no-xrender -no-mitshm -no-xinput -no-xkb -no-nas-sound -arch arm -platform linux-g++ -xplatform qws/linux-arm-g++ -release -opensource -fast -I$ARM/usr/include -L$ARM/usr/lib -L$ARM/lib -lrt -lX11 -lxcb -lXau -lXdmcp -lXext -lz -prefix custom_path_to_install
Any help would be appreciated.
An easy way to troobleshot this could be to install Qt Creator. Create a project with your code. Then, don't compile and run inside the IDE, but instead, in your terminal, do to your project folder with all your code (and new Qt Creator file .pro), and enter this:
qmake -project
qmake
make
Don't change -project, it's really the command, not the name of your project. I believe it will do it. Qt create has a .pro file which is then compile into a Makefile via qmake and manage all that for you.
Related
I'm on Arch Linux, and I have a C++ SDL2 program, contained in single main.cpp file, and I compile it for Linux with such command:
g++ main.cpp -lSDL2 -lSDL2_image
Now I wanna compile it for windows. Any advice on what should I do?
I suggest my own tool, quasi-msys2, which lets you reuse the precompiled SDL2 for MinGW provided by MSYS2 (and more).
Install Clang, LLD, make, wget, tar, zstd, gpg.
git clone https://github.com/HolyBlackCat/quasi-msys2
cd quasi-msys2/
make install _gcc _SDL2 _SDL2_image
env/shell.sh
win-clang++ main.cpp `pkg-config --cflags --libs sdl2 SDL2_image`
This should produce a.exe, which you can test using wine a.exe (or just ./a.exe, after running env/shell.sh).
How to do this manually:
For completeness, SDL2 itself distributes precompiled binaries for MinGW, meaning the manual setup is not hard. Any tutorial for MinGW should work.
Install MinGW from your package manager.
Download and unpack SDL2-devel-??-mingw.zip and SDL2_image-devel-??-mingw.zip.
Specify the paths to the directories with .a files using -L... and to .h files using -I.... Add -lmingw32 -lmingw32 -mwindows -lSDL2main -lSDL2 -lSDL2_image to the linker flags.
Follow this troubleshooting guide if you get stuck.
I'd go for cmake really.. SDL2 ships with a CMakeLists.txt and it's as simple as running this from your build folder.
cmake.exe ..
cmake.exe --build .
EDIT: if you want to cross-compile, you need MinGW and the addition of the mingw flags to the cmake generator
cmake \
-D CMAKE_C_COMPILER=/path/to/wingw/gcc \
-D CMAKE_CXX_COMPILER=/path/to/mingw/g++ \
-G "MinGW Makefiles" ..
Is there a reasonably easy to follow way to link SFML libraries with VSCode in macOS?
My case:
Using Mac
Using Clang with VSCode
Have Xcode installed
Am an amateur
Note : I am using clang and Mac
See my question and answer here: Manually link and compile C++ program with SFML (macOS)
In a nutshell:
download sfml for mac
copy include directory from extracted folder to your project directory
copy the dynamic library files to your project also, folder lib
in terminal type the g++ command and link to the dynamic libs
It will be something like this:
g++ main.cpp -o main -I include -L lib -l sfml-system -l sfml-window -l sfml-graphics -l sfml-audio -l sfml-network -Wl,-rpath ./lib
here's a boiler plate to link sfml in vs code:
https://github.com/andrew-r-king/sfml-vscode-boilerplate
If you have Macbook M1, the other answers won't work. The reason is because sfml from the website is compiled in x86_64, and you can't compile the libraries directly to arm64. So, you need sfml and pkg-config to be installed on Homebrew.
Command:
g++ main.cpp $(pkg-config --libs --cflags sfml-window sfml-system sfml-graphics) -o main
More detailed solution here: https://stackoverflow.com/a/53510642/16264548
If you don't wan to use pkg-config, then you can manually type in the locations:
main.cpp -I/opt/homebrew/Cellar/sfml/2.5.1_1/include -L/opt/homebrew/Cellar/sfml/2.5.1_1/lib -lsfml-window -lsfml-system -lsfml-graphics -o main
To enable the editor features, you can add library include files to C/C++ configurations:
Open Command Palette (⇧⌘P by default)
Type and select "C/C++: Edit Configurations (UI)"
In section "Include path" add a line: /your/path/to/sfml/include/*
In my case, the path is /usr/local/Cellar/sfml/2.5.1_1/include/*
My goal is to add my Qt project to a Jenkins buildserver, for nightly builds. Therefore I want to compile my project from the command line. I copied the buildsteps located in the build configuration:
"/opt/fslc-x11/2.5/sysroots/x86_64-fslcsdk-linux/usr/bin/qt5/qmake" "/home/xxxx/repositories/xxx/xxx.pro" -spec linux-oe-g++ && /usr/bin/make qmake_all
"/usr/bin/make"
I execute these commands in the build directory. The problem lies in the qmake command. The qmake command generates the makefile, but this makefile is different when I generate it in the command line instead of in QtCreator. The binary result after make is ofcourse very different.
It seems that the qmake command from the command line creates a debug makefile instead of a release makefile:
CFLAGS = -pipe -02 -pipe -g -feliminate-unused-debug-types --sysroot=.........
The -02 -pipe -g -feliminate-unused-debug-types part is the only thing added when I run qmake in the command line (checked with diff).
I've tried the following:
Added CONFIG+=release to the qmake command
Added CONFIG-=DEBUG to the qmake command
Furthermore I've verified that the system environment and the terminal emulator is the same.
My question comes down to:
Why does qmake add the (debug) flags when running from the command line?
Does QtCreator add more to the environment that I might have missed?
Let me know if you need more information about the settings or the makefile that is generated.
Ok. So long story short: I've tried compiling for the local Linux distro with the standard qmake and my problem was solved.
It seems that problem lies at the custom qmake of the target (x86_64-fslcsdk-linux). I'm not gonna put more time in this issue, so feel free to add a more satisfying answer. I'll be happy to try it out :).
I am trying to link a Qt program with GraphicsMagick, but Qt/qmake refuses to search /usr/local/* for GraphicsMagick++-config. I am using the $$system() command to fetch the flags like so:
QMAKE_CXXFLAGS += $$system(GraphicsMagick++-config --cppflags --cxxflags)
QMAKE_LIBS += $$system(GraphicsMagick++-config --ldflags --libs)
But every time, qmake complains /bin/sh: GraphicsMagick++-config: command not found. I have tested my path, and I can see /usr/local/bin from sh, csh, zsh, and bash. I am not sure why Qt can't find this command. Is there something simple I am missing?
I am running OS X 10.9, with Qt 5.3.1.
Make sure that you run qmake from the same shell where you did the PATH test, running it through a Finder-launched QtCreator might not inherit the environment if you set it in your ~.*shrc file.
I tried your code and qmake properly calls GraphicsMagick++-config with my brew installed GraphicsMagick.
FWIW, even though you might get the same error, a better way to get it to work would be to let qmake figure out the pkgconfig logic itself:
CONFIG += link_pkgconfig
PKGCONFIG = GraphicsMagick++
I am using ubuntu to build a project that uses mysql. To compile the project from the command line I use the following flags:
$(mysql_config --cflags)$(mysql_config --libs)
However, when I am trying to build from Qt, I get that undefined reference to mysql_close and the rest of mysql connection functions.
I tried adding the representation of the previous command line flags to QMAKe in Qt and still same errors.
Any Help?
Add the output of "mysql_config --cflags" to the compiler flags with:
QMAKE_CFLAGS += $$system(mysql_config --cflags)
QMAKE_CXXFLAGS += $$system(mysql_config --cflags)
Likewise for LIBS:
LIBS += $$system(mysql_config --libs)
All of the above goes into your project file (*.pro) of course.
To include Qt's SQL modules, you need this
QT += sql
in your .pro file. You also need to make sure the drivers have been compiled, and put into the plugins folder, libqsqlmysql.so in
~/QtSDK/Desktop/Qt/4.8.0/gcc/plugins/sqldrivers
in my case.
Mysql is not included in the SQL modules by default so Matt Philip's solution won't work.
What you need to do is install the mysql dev package by doing
sudo apt-get install libmysqlclient-dev
and then add it to the pro file like this
LIB += -L/usr/lib/mysql -lmysqlclient
This worked for me on ubuntu