简体   繁体   English

在 Nixos (21.05) 上的 QtCreator 中编译 Qt5 应用程序

[英]Compile Qt5 application in QtCreator on Nixos (21.05)

I am trying to compile a Qt5 application from QtCreator on Nixos.我正在尝试从 Nixos 上的 QtCreator 编译一个 Qt5 应用程序。

I have created the shell.nix file as described in https://nixos.wiki/wiki/Qt .我创建了 shell.nix 文件,如https://nixos.wiki/wiki/Qt中所述。 I start QtCreator as follows:我按如下方式启动 QtCreator:

$ 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). QtCreator 启动,我可以打开我的项目文件 (myproject.pro)。

However, when I "Build Project" [ctrl+b] I get the following error message:但是,当我“构建项目”[ctrl+b] 时,我收到以下错误消息:

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.这可能是由于 Qt Creator 选择了裸 gcc / g++ 编译器而不是包装版本。 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.在我的例子中,我必须 go 进入工具 > 选项 > 工具包并将自动选择的 C 和 C++ 编译器从“gcc”编译器切换到“gcc-wrapper”编译器。

See related discussion at https://discourse.nixos.org/t/nix-shell-cmake-gcc-qt-creator-not-working-together/16703 .请参阅https://discourse.nixos.org/t/nix-shell-cmake-gcc-qt-creator-not-working-together/16703上的相关讨论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM