Compile Qt5 application in QtCreator on Nixos (21.05) - c++

I am trying to compile a Qt5 application from QtCreator on Nixos.
I have created the shell.nix file as described in https://nixos.wiki/wiki/Qt . I start QtCreator as follows:
$ ls -al
...
.rw-r--r-- 236 username 30 Jun 17:31 shell.nix
...
$ nix-shell
[nix-shell:~/myproject]$ qtcreator
QtCreator starts and I can open my project file (myproject.pro).
However, when I "Build Project" [ctrl+b] I get the following error message:
9:38:09: Running steps for project myproject...
19:38:09: Starting: "/nix/store/gkr9j6p60vib8k8bxhc33581fn4pl8d8-qt-full-5.15.2/bin/qmake" /tmp/myproject/myproject.pro -spec linux-g++ CONFIG+=debug CONFIG+=qml_debug
19:38:09: The process "/nix/store/gkr9j6p60vib8k8bxhc33581fn4pl8d8-qt-full-5.15.2/bin/qmake" exited normally.
19:38:09: Starting: "/nix/store/lxmh13cqvd2kwc3qbmnjknvynw6lc2si-gnumake-4.3/bin/make" -f /tmp/build-myproject-Desktop-Debug/Makefile qmake_all
make: Nothing to be done for 'qmake_all'.
19:38:09: The process "/nix/store/lxmh13cqvd2kwc3qbmnjknvynw6lc2si-gnumake-4.3/bin/make" exited normally.
19:38:09: Starting: "/nix/store/lxmh13cqvd2kwc3qbmnjknvynw6lc2si-gnumake-4.3/bin/make" -j16
g++ -Wl,-rpath,/nix/store/wn6q10flx0id4yxa96yq1jzpmbvi7d5r-qtwebkit-5.212.0-alpha4/lib -Wl,-rpath,/nix/store/wn6q10flx0id4yxa96yq1jzpmbvi7d5r-qtwebkit-5.212.0-alpha4/lib -Wl,-rpath,/nix/store/gpw8cms1ig5k16d86zr7hkhi77gccl9r-qtwebkit-5.212.0-alpha4/lib -Wl,-rpath,/nix/store/gpw8cms1ig5k16d86zr7hkhi77gccl9r-qtwebkit-5.212.0-alpha4/lib -Wl,-rpath,/nix/store/3sx0lss99gj0krp3xgqz47zipp8fmj18-qtbase-5.14.2/lib -o myproject cobs.o main.o mainwindow.o srm60binarycom.o moc_mainwindow.o -L/nix/store/8jix4ismqsz2pz6gji3zpawdv2k5aqws-libGL-1.3.3/lib /nix/store/3sx0lss99gj0krp3xgqz47zipp8fmj18-qtbase-5.14.2/lib/libQt5Widgets.so /nix/store/3sx0lss99gj0krp3xgqz47zipp8fmj18-qtbase-5.14.2/lib/libQt5Gui.so /nix/store/3sx0lss99gj0krp3xgqz47zipp8fmj18-qtbase-5.14.2/lib/libQt5Core.so -L/nix/store/izvv5r9a8s19l742nfwr72z2w3ijq8bh-libglvnd-1.3.3/lib -lGL -lpthread
/nix/store/qvc6cz5d43jhhm4a3r48xkrc82xh1s95-binutils-2.35.1/bin/ld: cannot find crt1.o: No such file or directory
/nix/store/qvc6cz5d43jhhm4a3r48xkrc82xh1s95-binutils-2.35.1/bin/ld: cannot find crti.o: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:429: myproject] Error 1
19:38:09: The process "/nix/store/lxmh13cqvd2kwc3qbmnjknvynw6lc2si-gnumake-4.3/bin/make" exited with code 2.
Error while building/deploying project myproject (kit: Desktop)
When executing step "Make"
19:38:09: Elapsed time: 00:00.
The errors:
.../ld: cannot find crt1.o: No such file or directory
.../ld: cannot find crti.o: No such file or directory
How can I fix this issue?

This can be due to Qt Creator picking the bare gcc / g++ compiler instead of the wrapped versions. The wrapped version adds some command-line options to make things work.
In my case, I had to go into Tools > Options > Kits and switch the automatically selected C and C++ compilers from the "gcc" one to the "gcc-wrapper" one.
See related discussion at https://discourse.nixos.org/t/nix-shell-cmake-gcc-qt-creator-not-working-together/16703.

Related

Build curl lib with Mingw compiler

I want to use the curl lib in my project (c++ QT creator on windows), I download the zip lib file from the website https://curl.se/download.html (Version 7.82.0)
and I wanted to build it using the Makefile with this commend
mingw32-make mingw32 as described in the documentation https://curl.se/docs/install.html
but unfortunately, I am getting an error
mingw32-make mingw32
[....]
gcc -s -m32 -static -o curl.exe curl.res slist_wc.o tool_binmode.o tool_bname.o
tool_cb_dbg.o tool_cb_hdr.o tool_cb_prg.o tool_cb_rea.o tool_cb_see.o tool_cb_wrt.o
tool_cfgable.o tool_dirhie.o tool_doswin.o tool_easysrc.o tool_filetime.o tool_findfile.o
tool_formparse.o tool_getparam.o tool_getpass.o tool_help.o tool_helpers.o tool_hugehelp.o
tool_libinfo.o tool_listhelp.o tool_main.o tool_msgs.o tool_operate.o tool_operhlp.o
tool_panykey.o tool_paramhlp.o tool_parsecfg.o tool_progress.o tool_strdup.o tool_setopt.o
tool_sleep.o tool_urlglob.o tool_util.o tool_vms.o tool_writeout.o tool_writeout_json.o
tool_xattr.o strtoofft.o nonblock.o warnless.o curl_ctype.o curl_multibyte.o version_win32.o
dynbuf.o -L../lib -lcurl -lwldap32 -lws2_32
../lib\libcurl.a: error adding symbols: Archive has no index; run ranlib to add one
collect2.exe: error: ld returned 1 exit status
make[1]: *** [curl.exe] Fehler 1
make[1]: Leaving directory `D:/Dev/API/curl-7.82.0/src'
make: *** [mingw32] Fehler 2
I tried to run ranlib lib\libcurl.a but the issue is still there,
does anyone have an idea about it?
One more question: is it possible also to build it with mingw64?

codelite unittest++/UnitTest++.h: no such file or directory

I am trying to do unit testing with C++/Codelite. I have UnitTest++ plugin installed from codelite-plugins package (Ubuntu 18.04). I can also see this:
$ ls -la /usr/include | grep Unit
drwxr-xr-x 3 root root 4096 Mar 2 11:47 UnitTest++
$ sudo dpkg -l | grep unittest++
ii libunittest++-dev 2.0.0-2 amd64 unit testing framework for c++, static library and headers
ii libunittest++2:amd64 2.0.0-2 amd64 unit testing framework for c++, runtime library
So I create a test project in Codelite and I add this:
#include <unittest++/UnitTest++.h> // This line and main are auto-created
TEST(SanityTest)
{
CHECK_EQUAL(1, 1);
}
int main(int argc, char **argv)
{
return UnitTest::RunAllTests();
}
Now I would expect test results after I press CTRL+F5. But when I do, I only get a popup window saying there are no tests:
I also noticed that when I go to Build > Build Project I get an error message:
fatal error: unittest++/UnitTest++.h: No such file or directory
I also found THIS ANSWER and tried different variation of console commands as per answer/comments there, but I always get the same no such file or directory error.
Any idea what I am missing?
EDIT:
Build log as per Stephen's Newell request:
/bin/sh -c '/usr/bin/make -j8 -e -f Makefile'
----------Building project:[ Test - Debug ]----------
make[1]: Entering directory '/home/callmebob/Documents/workspace-codelite/cpp/Test'
/usr/bin/g++ -c "/home/callmebob/Documents/workspace-codelite/cpp/Test/main.cpp" -g -o Debug/main.cpp.o -I. -I/usr/include/unittest++
/home/callmebob/Documents/workspace-codelite/cpp/Test/main.cpp:1:10: fatal error: unittest++/UnitTest++.h: No such file or directory
#include "unittest++/UnitTest++.h"
^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Test.mk:95: recipe for target 'Debug/main.cpp.o' failed
make[1]: *** [Debug/main.cpp.o] Error 1
make[1]: Leaving directory '/home/callmebob/Documents/workspace-codelite/cpp/Test'
Makefile:4: recipe for target 'All' failed
make: *** [All] Error 2
====2 errors, 0 warnings====
Also if I right-click the project, go to Settings > Compiler, I can see:
Included Paths = /usr/include/unittest++
Based on your ls output, it looks like you should change your first line to this:
#include <UnitTest++/UnitTest++.h>
I'm not sure why the answer you linked to worked with a lowercase directory name; the examples in the project documentation all use the mixed-case directory name.

Unable to Compile a Qt project in qtcreator

I am unable to compile a simple Qt project (an example with the mainwindow). I tried it via command shell and also on QtCreator. first qmake should create makefile with the command rule uic to translate as simple as it should my ui to a .h.
Qt Creator indicating the below warning / error messages on the console.
09:06:30: Running steps for project untitled...
09:06:30: Starting: "D:\QT\qt-everywhere-opensource-src-5.6.0\qtbase\bin\qmake.exe" C:\workspace_llb_27-05-2016\untitled\untitled.pro -r -spec win32-g++
09:06:32: The process "D:\QT\qt-everywhere-opensource-src-5.6.0\qtbase\bin\qmake.exe" exited normally.
09:06:32: Starting: "C:\mingw\mingwx64_481r0-sjlj-rev2\bin\mingw32-make.exe"
C:/mingw/mingwx64_481r0-sjlj-rev2/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'C:/build_untitled_Qt_5_6_0_Built_by_mingwx64_481r0_sjlj_rev2_Debug'
/C/build_untitled_Qt_5_6_0_Built_by_mingwx64_481r0_sjlj_rev2_Debug/uic_wrapper.sh ../workspace_llb_27-05-2016/untitled/mainwindow.ui -o ui_mainwindow.h
Makefile.Debug:318: recipe for target 'ui_mainwindow.h' failed
process_begin: CreateProcess(NULL, /C/build_untitled_Qt_5_6_0_Built_by_mingwx64_481r0_sjlj_rev2_Debug/uic_wrapper.sh ../workspace_llb_27-05-2016/untitled/mainwindow.ui -o ui_mainwindow.h, ...) failed.
make (e=2): Le fichier spécifié est introuvable.
mingw32-make[1]: *** [ui_mainwindow.h] Error 2
mingw32-make[1]: Leaving directory 'C:/build_untitled_Qt_5_6_0_Built_by_mingwx64_481r0_sjlj_rev2_Debug'
Makefile:34: recipe for target 'debug' failed
mingw32-make: *** [debug] Error 2
09:06:33: The process "C:\mingw\mingwx64_481r0-sjlj-rev2\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project untitled (kit: Qt 5.6.0 (Built by mingwx64_481r0-sjlj-rev2))
When executing step "Make"
Thanks
I find the solution eventually. If It happens to me it could happen to anyone. Actually everything have worked before I install gitbash. I set as variable system the bin of gitbash to my path system. However gitbach contains sh.exe which unix tool. So everytime I build via Qtcreator or console 2 uic_wrapper were created one .sh one .bat and all my makefile were unix like. in nutshell never set any UNIX TOOL TO YOUR WINDOWS SYSTEM. Mingw could contain MSYS take care !! at least most of tools oriented development are UNIX like.
I am suspecting something wrong with your Desktop Kit maybe. I tried to create a new default mainwindow project just like how you did and I see the first few steps like below:
14:48:15: Running steps for project untitled...
14:48:15: Starting: "D:\Qt\Qt5.6.0\5.6\mingw49_32\bin\qmake.exe" C:\untitled\untitled.pro -r -spec win32-g++ "CONFIG+=debug" "CONFIG+=qml_debug"
14:48:16: The process "D:\Qt\Qt5.6.0\5.6\mingw49_32\bin\qmake.exe" exited normally.
14:48:16: Starting: "D:\Qt\Qt5.6.0\Tools\mingw492_32\bin\mingw32-make.exe"
D:/Qt/Qt5.6.0/Tools/mingw492_32/bin/mingw32-make -f Makefile.Debug
You can notice there's a difference between the qmake path my application is using compared to yours.
Mine looks like this: D:\Qt\Qt5.6.0\5.6\mingw49_32\bin\qmake.exe
Yours looks like this: D:\QT\qt-everywhere-opensource-src-5.6.0\qtbase\bin\qmake.exe
And I guess qt-everywhere-opensource-src-5.6.0 looks like the Qt source code that you might have pulled from web. Hope this information gives you some pointer to figure out what's going wrong.

libQt5Core.so: undefined reference to `__cxa_throw_bad_array_new_length#CXXABI_1.3.8

I'm using a cross compiled qt 5.4.2 and I getting the following error when I try to build simple QtWidget app (the app is just a window)
09:55:42: Running steps for project untitled...
09:55:42: Configuration unchanged, skipping qmake step.
09:55:42: Starting: "/usr/bin/make"
g++ --sysroot=/home/pf/ssdk-d6cx/host/usr/x86_64-buildroot-linux-gnu/sysroot -Wl,-O1 -Wl,-rpath,/usr/local/qt5.4-d6cx/lib -o untitled main.o mainwindow.o moc_mainwindow.o -L/home/pf/ssdk-d6cx/host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/local/qt5.4-d6cx/lib -lQt5Widgets -L/home/pf/ssdk-d6cx/host/usr/x86_64-buildroot-linux-gnu/sysroot/lib64 -L/usr/local/qt5.4-d6cx/lib -lQt5Gui -lQt5Core -lGLESv2 -lpthread
/home/pf/ssdk-d6cx/host/usr/x86_64-buildroot-linux-gnu/sysroot/usr/local/qt5.4-d6cx/lib/libQt5Core.so: undefined reference to `__cxa_throw_bad_array_new_length#CXXABI_1.3.8'
collect2: ld returned 1 exit status
make: *** [untitled] Error 1
09:55:42: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project untitled (kit: d6cx)
When executing step "Make"
09:55:42: Elapsed time: 00:00.
I really don't understand what is going on.
Could be a compatibility problem with some libs on the target OS?
I will appreciate any help that point me to the solution.
Thanks in advance.
I found the solution to the problem.
The real problem was that I was using Qt Creator as IDE to cross compile and it set qmake to use a device different that the one I was cross compiling for.
I mean the original setting for qmake was:
qmake '/home/pf/D6Cx/test app/untitled/untitled.pro' -r -spec linux-g++
and it should be:
qmake '/home/pf/D6Cx/test app/untitled/untitled.pro' -r -spec devices/linux-d6cx-g++
whith this last one configuration the app is built correctly!!
The way I use to force qmake to use my specific device was (in Qt Creator):
go to Projects/Build setting
in the section Build Steps -> qmake add in Additional arguments:
-spec devices/linux-d6cx-g++
and that will overwrite the original setting for -spec
Thanks!

Audiere incomplete universal character name \U Error

Hey so I'm trying to make a music player using QT and Audiere. First I installed Audiere and put the header file in the compiler's include folder. Then I added the .lib file to the QT project. I wrote the following code:
AudioDevicePtr device(OpenDevice());
if(!device){
//failure
}
SampleSource* source = OpenSampleSource("C:\Users\Amenechi\Downloads\LMFAO - Sexy And I Know It");
OutputStreamPtr stream(OpenSound(device,source,true));
if(!stream){
//failure
}
stream->setRepeat(true);
stream->setVolume(0.5f);
stream->play();
But I get this error:
http://s20.postimage.org/u1yxk0d0s/Untitled.jpg
Now I'm not sure where it went wrong, maybe i installed the audiere library incorrectly?
EDIT:
Hey here's the compile output if that helps.
07:37:45: Running steps for project QTunesV2...
07:37:45: Configuration unchanged, skipping qmake step.
07:37:45: Starting: "C:\Qt\Qt5.0.1\Tools\MinGW\bin\mingw32-make.exe"
C:/Qt/Qt5.0.1/Tools/MinGW/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'C:/Qt/Qt5.0.1/Tools/QtCreator/bin/QTunesV1/QTunesV2-build-Desktop_Qt_5_0_1_MinGW_32bit-Debug'
g++ -Wl,-subsystem,windows -mthreads -o debug\QTunesV2.exe debug/main.o debug/mainwindow.o debug/moc_mainwindow.o -lmingw32 -lqtmaind -LC:/Qt/Qt5.0.1/Tools/QtCreator/bin/QTunesV1/QTunesV2/../../ -laudiered -LC:\Qt\Qt5.0.1\5.0.1\mingw47_32\lib -lQt5Widgetsd -lQt5Guid -lQt5Cored -llibEGLd -llibGLESv2d -lgdi32 -luser32
c:/qt/qt5.0.1/tools/mingw/bin/../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -laudiered
collect2.exe: error: ld returned 1 exit status
Makefile.Debug:80: recipe for target 'debug\QTunesV2.exe' failed
mingw32-make[1]: *** [debug\QTunesV2.exe] Error 1
mingw32-make[1]: Leaving directory 'C:/Qt/Qt5.0.1/Tools/QtCreator/bin/QTunesV1/QTunesV2-build-Desktop_Qt_5_0_1_MinGW_32bit-Debug'
mingw32-make: *** [debug] Error 2
makefile:34: recipe for target 'debug' failed
07:37:45: The process "C:\Qt\Qt5.0.1\Tools\MinGW\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project QTunesV2 (kit: Desktop Qt 5.0.1 MinGW 32bit)
When executing step 'Make'