Problem with using nimqt
Closed this issue · 19 comments
Hi, I have a new laptop (well new, I bought it from an auction), it's a Lenovo T480 and I installed Ubuntu in it. I also installed the Qt package (6.4.2) and I set up the following string into the .bashrc
file:
export QMAKE_PATH=$HOME/Qt/6.4.2/gcc_64/bin/qmake
I went to the nimqt directory and then to the examples directory and I tried to compile the examples and the majority compiles but it failed at loading the Qt libraries.
Did I do something wrong?
This is the command to compile an example nim cpp -r text_view.nim
Note that in my other laptop nimqt compiles without any error.
Can you try and see if make text_view
works? It adds a path to the compiler command.
If that make command succeeds, then I guess you had nimqt also installed in ~/.nimble/pkgs and it was using that library (rather than the one from pwd).
If it doesn't work, I'll have to figure out something else :)
Thanks! It works now! :-) I tried all the examples and all they all work, except make load_ui
doesn't compile. That gives an error:
/home/user/.cache/nim/load_ui_d/@mload_ui.nim.cpp:12:10: fatal error: QtUiTools/quiloader.h: No such file or directory
12 | #include "QtUiTools/quiloader.h"
installing libqt6uitools6
and qt6-tools-dev
should resolve that
Did that, but shouldn't these files be installed with Qt itself, because now you get different release files?
Anyway, make load_ui
compiles fine until this:
if [ Linux = Darwin ]; then install_name_tool -add_rpath /home/user/Qt/6.4.2/gcc_64/lib/ examples/load_ui; fi
./examples/load_ui
./examples/load_ui: /lib/x86_64-linux-gnu/libQt6Core.so.6: version Qt_6.4 not found (required by ./examples/load_ui)
make[1]: *** [Makefile:61: run_load_ui] Error 1
make[1]: Leaving directory '/home/user/nimqt'
make: *** [Makefile:56: load_ui] Error 2
So... it compiles but I don't think that it linked. When I run ./load_ui
the answer that I get is:
./load_ui: /lib/x86_64-linux-gnu/libQt6Core.so.6: version Qt_6.4 not found (required by ./load_ui)
Edit1:
And all the examples have some issues.
Edit 2:
Maybe it's better to deal with these problems until Nim 2.0 arrives?
Did that, but shouldn't these files be installed with Qt itself, because now you get different release files?
Right, sorry, I forgot you are using a custom Qt installation.
Which files does find /home/user/Qt/6.4.2/ | grep -i quiloader.h
return?
It is only one file: /home/user/Qt/6.4.2/gcc_64/include/QtUiTools/quiloader.h
Ok, weird. And just to be sure, what does
QMAKE_PATH=$HOME/Qt/6.4.2/gcc_64/bin/qmake nim r $(NIMQT_REPO)scripts/nimqt_paths.nim Qt_install_headers
return?
NIMQT_REPO: command not found
oserr.nim(95) raiseOSError
Error: unhandled exception: No such file or directory
Additional info: scripts [OSError]
That is because I didn't set the parameter NIMQT_REPO
Is this variable necessary?
The output of
QMAKE_PATH=$HOME/Qt/6.4.2/gcc_64/bin/qmake nim r $HOME/nimqt/scripts/nimqt_paths.nim Qt_install_headers
is
Hint: used config file '/home/user/.choosenim/toolchains/nim-1.6.12/config/nim.cfg' [Conf]
Hint: used config file '/home/user/.choosenim/toolchains/nim-1.6.12/config/config.nims' [Conf]
....................................................................................................
Hint: [Link]
Hint: gc: refc; opt: none (DEBUG BUILD, `-d:release` generates faster code)
60456 lines; 3.079s; 75.5MiB peakmem; proj: /home/user/nimqt/scripts/nimqt_paths.nim; out: /home/user/.cache/nim/nimqt_paths_d/nimqt_paths_5819F8AF411D318AB12C6048A98F72E66505DDFC [SuccessX]
Hint: /home/user/.cache/nim/nimqt_paths_d/nimqt_paths_5819F8AF411D318AB12C6048A98F72E66505DDFC Qt_install_headers [Exec]
/home/user/Qt/6.4.2/gcc_64/include
Yeah, I sometimes use $(VAR) to mean replace it with the value of VAR on your system, but in bash it's something different :)
Can you give me the output of make build_load_ui
, but with the additional flag --listCmd
right before the --path
flag on line 58?
To be sure it will compile, it might be better to clear the cache with (I think) rm -r $HOME/.cache/nim/load_ui_d/
.
Hint: used config file '/home/user/.choosenim/toolchains/nim-1.6.12/config/nim.cfg' [Conf]
Hint: used config file '/home/user/.choosenim/toolchains/nim-1.6.12/config/config.nims' [Conf]
Hint: gc: refc; opt: none (DEBUG BUILD, -d:release
generates faster code)
9916 lines; 0.072s; 10.691MiB peakmem; proj: /home/user/nimqt/scripts/nimqt_paths.nim; out: /home/user/.cache/nim/nimqt_paths_d/nimqt_paths_AF158E3C0ABAB08B8B6D98653080DE636023C0F1 [SuccessX]
Hint: /home/user/.cache/nim/nimqt_paths_d/nimqt_paths_AF158E3C0ABAB08B8B6D98653080DE636023C0F1 qtinstalllibs [Exec]
nim cpp --listCmd --path:qt/6.4.2_gui_widgets/ examples/load_ui.nim
Hint: used config file '/home/user/.choosenim/toolchains/nim-1.6.12/config/nim.cfg' [Conf]
Hint: used config file '/home/user/.choosenim/toolchains/nim-1.6.12/config/config.nims' [Conf]
.....................................................................................................................................................................................................................................
/home/user/nimqt/qt/6.4.2_gui_widgets/nimqt.nim(65, 24) Warning: imported and not used: 'qnamespace' [UnusedImport]
CC: ../../.choosenim/toolchains/nim-1.6.12/lib/std/private/digitsutils.nim: g++ -c -std=gnu++14 -funsigned-char -w -fmax-errors=3 -fpermissive -std=c++17 -I/home/user/nimqt/qt/6.4.2_gui_widgets -I/home/user/Qt/6.4.2/gcc_64/include -fPIC -I/home/user/.choosenim/toolchains/nim-1.6.12/lib -I/home/user/nimqt/examples -o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@sstd@sprivate@sdigitsutils.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@sstd@sprivate@sdigitsutils.nim.cpp
CC: ../../.choosenim/toolchains/nim-1.6.12/lib/system/assertions.nim: g++ -c -std=gnu++14 -funsigned-char -w -fmax-errors=3 -fpermissive -std=c++17 -I/home/user/nimqt/qt/6.4.2_gui_widgets -I/home/user/Qt/6.4.2/gcc_64/include -fPIC -I/home/user/.choosenim/toolchains/nim-1.6.12/lib -I/home/user/nimqt/examples -o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@ssystem@sassertions.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@ssystem@sassertions.nim.cpp
CC: ../../.choosenim/toolchains/nim-1.6.12/lib/system/dollars.nim: g++ -c -std=gnu++14 -funsigned-char -w -fmax-errors=3 -fpermissive -std=c++17 -I/home/user/nimqt/qt/6.4.2_gui_widgets -I/home/user/Qt/6.4.2/gcc_64/include -fPIC -I/home/user/.choosenim/toolchains/nim-1.6.12/lib -I/home/user/nimqt/examples -o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@ssystem@sdollars.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@ssystem@sdollars.nim.cpp
CC: ../../.choosenim/toolchains/nim-1.6.12/lib/system/io.nim: g++ -c -std=gnu++14 -funsigned-char -w -fmax-errors=3 -fpermissive -std=c++17 -I/home/user/nimqt/qt/6.4.2_gui_widgets -I/home/user/Qt/6.4.2/gcc_64/include -fPIC -I/home/user/.choosenim/toolchains/nim-1.6.12/lib -I/home/user/nimqt/examples -o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@ssystem@sio.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@ssystem@sio.nim.cpp
CC: ../../.choosenim/toolchains/nim-1.6.12/lib/system.nim: g++ -c -std=gnu++14 -funsigned-char -w -fmax-errors=3 -fpermissive -std=c++17 -I/home/user/nimqt/qt/6.4.2_gui_widgets -I/home/user/Qt/6.4.2/gcc_64/include -fPIC -I/home/user/.choosenim/toolchains/nim-1.6.12/lib -I/home/user/nimqt/examples -o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@ssystem.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@ssystem.nim.cpp
CC: ../../.choosenim/toolchains/nim-1.6.12/lib/pure/parseutils.nim: g++ -c -std=gnu++14 -funsigned-char -w -fmax-errors=3 -fpermissive -std=c++17 -I/home/user/nimqt/qt/6.4.2_gui_widgets -I/home/user/Qt/6.4.2/gcc_64/include -fPIC -I/home/user/.choosenim/toolchains/nim-1.6.12/lib -I/home/user/nimqt/examples -o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@sparseutils.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@sparseutils.nim.cpp
CC: ../../.choosenim/toolchains/nim-1.6.12/lib/pure/unicode.nim: g++ -c -std=gnu++14 -funsigned-char -w -fmax-errors=3 -fpermissive -std=c++17 -I/home/user/nimqt/qt/6.4.2_gui_widgets -I/home/user/Qt/6.4.2/gcc_64/include -fPIC -I/home/user/.choosenim/toolchains/nim-1.6.12/lib -I/home/user/nimqt/examples -o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@sunicode.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@sunicode.nim.cpp
CC: ../../.choosenim/toolchains/nim-1.6.12/lib/pure/strutils.nim: g++ -c -std=gnu++14 -funsigned-char -w -fmax-errors=3 -fpermissive -std=c++17 -I/home/user/nimqt/qt/6.4.2_gui_widgets -I/home/user/Qt/6.4.2/gcc_64/include -fPIC -I/home/user/.choosenim/toolchains/nim-1.6.12/lib -I/home/user/nimqt/examples -o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@sstrutils.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@sstrutils.nim.cpp
CC: ../../.choosenim/toolchains/nim-1.6.12/lib/pure/pathnorm.nim: g++ -c -std=gnu++14 -funsigned-char -w -fmax-errors=3 -fpermissive -std=c++17 -I/home/user/nimqt/qt/6.4.2_gui_widgets -I/home/user/Qt/6.4.2/gcc_64/include -fPIC -I/home/user/.choosenim/toolchains/nim-1.6.12/lib -I/home/user/nimqt/examples -o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@spathnorm.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@spathnorm.nim.cpp
CC: ../../.choosenim/toolchains/nim-1.6.12/lib/pure/times.nim: g++ -c -std=gnu++14 -funsigned-char -w -fmax-errors=3 -fpermissive -std=c++17 -I/home/user/nimqt/qt/6.4.2_gui_widgets -I/home/user/Qt/6.4.2/gcc_64/include -fPIC -I/home/user/.choosenim/toolchains/nim-1.6.12/lib -I/home/user/nimqt/examples -o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@stimes.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@stimes.nim.cpp
CC: ../../.choosenim/toolchains/nim-1.6.12/lib/pure/os.nim: g++ -c -std=gnu++14 -funsigned-char -w -fmax-errors=3 -fpermissive -std=c++17 -I/home/user/nimqt/qt/6.4.2_gui_widgets -I/home/user/Qt/6.4.2/gcc_64/include -fPIC -I/home/user/.choosenim/toolchains/nim-1.6.12/lib -I/home/user/nimqt/examples -o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@sos.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@sos.nim.cpp
CC: ../../.choosenim/toolchains/nim-1.6.12/lib/pure/strformat.nim: g++ -c -std=gnu++14 -funsigned-char -w -fmax-errors=3 -fpermissive -std=c++17 -I/home/user/nimqt/qt/6.4.2_gui_widgets -I/home/user/Qt/6.4.2/gcc_64/include -fPIC -I/home/user/.choosenim/toolchains/nim-1.6.12/lib -I/home/user/nimqt/examples -o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@sstrformat.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@sstrformat.nim.cpp
CC: ../qt/6.4.2_gui_widgets/nimqt/nimqt_paths.nim: g++ -c -std=gnu++14 -funsigned-char -w -fmax-errors=3 -fpermissive -std=c++17 -I/home/user/nimqt/qt/6.4.2_gui_widgets -I/home/user/Qt/6.4.2/gcc_64/include -fPIC -I/home/user/.choosenim/toolchains/nim-1.6.12/lib -I/home/user/nimqt/examples -o /home/user/.cache/nim/load_ui_d/@m..@sqt@s6.4.2_gui_widgets@snimqt@snimqt_paths.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@sqt@s6.4.2_gui_widgets@snimqt@snimqt_paths.nim.cpp
CC: ../qt/6.4.2_gui_widgets/nimqt/qtcore/qstring.nim: g++ -c -std=gnu++14 -funsigned-char -w -fmax-errors=3 -fpermissive -std=c++17 -I/home/user/nimqt/qt/6.4.2_gui_widgets -I/home/user/Qt/6.4.2/gcc_64/include -fPIC -I/home/user/.choosenim/toolchains/nim-1.6.12/lib -I/home/user/nimqt/examples -o /home/user/.cache/nim/load_ui_d/@m..@sqt@s6.4.2_gui_widgets@snimqt@sqtcore@sqstring.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@sqt@s6.4.2_gui_widgets@snimqt@sqtcore@sqstring.nim.cpp
CC: ../qt/6.4.2_gui_widgets/nimqt/qtcore/qobject.nim: g++ -c -std=gnu++14 -funsigned-char -w -fmax-errors=3 -fpermissive -std=c++17 -I/home/user/nimqt/qt/6.4.2_gui_widgets -I/home/user/Qt/6.4.2/gcc_64/include -fPIC -I/home/user/.choosenim/toolchains/nim-1.6.12/lib -I/home/user/nimqt/examples -o /home/user/.cache/nim/load_ui_d/@m..@sqt@s6.4.2_gui_widgets@snimqt@sqtcore@sqobject.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@sqt@s6.4.2_gui_widgets@snimqt@sqtcore@sqobject.nim.cpp
CC: load_ui.nim: g++ -c -std=gnu++14 -funsigned-char -w -fmax-errors=3 -fpermissive -std=c++17 -I/home/user/nimqt/qt/6.4.2_gui_widgets -I/home/user/Qt/6.4.2/gcc_64/include -fPIC -I/home/user/.choosenim/toolchains/nim-1.6.12/lib -I/home/user/nimqt/examples -o /home/user/.cache/nim/load_ui_d/@mload_ui.nim.cpp.o /home/user/.cache/nim/load_ui_d/@mload_ui.nim.cpp
Hint: g++ -o /home/user/nimqt/examples/load_ui /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@sstd@sprivate@sdigitsutils.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@ssystem@sassertions.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@ssystem@sdollars.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@ssystem@sio.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@ssystem.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@sparseutils.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@sunicode.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@sstrutils.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@spathnorm.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@stimes.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@sos.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@s..@s.choosenim@stoolchains@snim-1.6.12@slib@spure@sstrformat.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@sqt@s6.4.2_gui_widgets@snimqt@snimqt_paths.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@sqt@s6.4.2_gui_widgets@snimqt@sqtcore@sqstring.nim.cpp.o /home/user/.cache/nim/load_ui_d/@m..@sqt@s6.4.2_gui_widgets@snimqt@sqtcore@sqobject.nim.cpp.o /home/user/.cache/nim/load_ui_d/@mload_ui.nim.cpp.o -lm -lm -lrt -L/home/user/Qt/6.4.2/gcc_64/lib -lQt6Core -lQt6Gui -lQt6Widgets -lQt6UiTools -ldl [Link]
Hint: gc: refc; opt: none (DEBUG BUILD, -d:release
generates faster code)
129006 lines; 17.362s; 221.84MiB peakmem; proj: /home/user/nimqt/examples/load_ui.nim; out: /home/user/nimqt/examples/load_ui [SuccessX]
if [ Linux = Darwin ]; then install_name_tool -add_rpath /home/user/Qt/6.4.2/gcc_64/lib/ examples/load_ui; fi
It is compiling because you still have installed libqt6uitools6 and qt6-tools-dev, right? Can you remove them and try again?
I removed them already.
The output of load_ui
is the same:
./load_ui: error while loading shared libraries: libQt6Core.so.6: cannot open shared object file: No such file or directory
Ah, so then the issue of QtUiTools/quiloader.h: No such file or directory
is suddenly resolved?
Can you try and see if it works with LD_LIBRARY_PATH=$HOME/Qt/6.4.2/gcc_64/lib QMAKE_PATH=$HOME/Qt/6.4.2/gcc_64/bin/qmake make load_ui
?
Yes, this compiles and runs ;)
All examples compile!
The only line that I need to add in my .bashrc is export LD_LIBRARY_PATH=$HOME/Qt/6.4.2/gcc_64/lib
I didn't know that I also needed to add that line.
Great :)
For OSX, the line install_name_tool -add_rpath ... examples/load_ui
hardcodes the library path into the executable. In linux it is probably also possible, but currently not on linux. If you find out what command it is, let me know and I'll update the Makefile :)
I guess on your old laptop, you have the Qt libraries installed, and it was using those, instead of the ones in $HOME/Qt ...
Yes, you are right. We experimented quite a lot with that :)
Now I can clean that one up. Thanks!
In my .bashrc
file there are two lines (actually four lines):
# for Nim
export PATH=/home/user/.nimble/bin:$PATH
export QMAKE_PATH=$HOME/Qt/6.4.2/gcc_64/bin/qmake
export LD_LIBRARY_PATH=$HOME/Qt/6.4.2/gcc_64/lib
The last two lines I think that you should add in the README.md
I am closing this issue. Again THANKS!!!
Edit: Sorry, $LD_LIBRARY_PATH is a global library path, which means that when you overwrite that, you should at least overwrite it with something like: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/Qt/6.4.2/gcc_64/lib
Edit2:
But I think that it is better to use something like this:
export QT6_INSTALL=$HOME/Qt/6.4.2/gcc_64
export QMAKE_PATH=$QT6_INSTALL/bin/qmake
export LD_LIBRARY_PATH=$QT6_INSTALL/lib:$LD_LIBRARY_PATH
Edit3:
Maybe it is even simpler.
export QT6_RELEASE=6.4.2
export QMAKE_PATH=$HOME/Qt/$QT6_RELEASE/gcc_64/bin/qmake
export LD_LIBRARY_PATH=$HOME/Qt/$QT6_RELEASE/gcc_64/lib:$LIBRARY_PATH
Edit4 (I am sorry).
But what if you don't want to install Qt with the Qt installer?
What if you want to only install Qt with: sudo apt install libqt6uitools6 qt6-tools-dev
Then my previous remarks are unnecessary. Then you only want to add the QMAKE_PATH and the LD_LIBRARY_PATH.
The only problem is that I don't know the path of LD_LIBRARY_PATH
This remark is only food for thought.