rust-qt / ritual

Use C++ libraries from Rust
Apache License 2.0
1.22k stars 49 forks source link

Cannot run examples #117

Closed lemon37564 closed 2 years ago

lemon37564 commented 2 years ago

I've downloaded examples from https://github.com/rust-qt/examples, the examples were succeeded to compile. But when running the executable, it shows the error target/debug/hello_qml: symbol lookup error: target/debug/hello_qml: undefined symbol: _Z9qIsFinite8qfloat16, version Qt_5 How can I fix it?

lemon37564 commented 2 years ago

rust version: rustc 1.53.0 (53cb7b09b 2021-06-17) linux/amd64 5.8.0-59-generic Qt version: 5.12.11

UditDey commented 2 years ago

I'm having the same issue, using Qt version 5.15.2, the symbol is different for me though undefined symbol: _ZN2Qt8showbaseER11QTextStream

UditDey commented 2 years ago

I was having another issue and I'll add it because I think its related

I installed Qt 5.15.2 from the official installer and I was having trouble adding it to the path in a way the ritual build script could detect it. Adding ~/Qt/5.15.2/gcc_64//bin to the $PATH in ~/.profile according to the instructions here made the installed qmake work correctly from a terminal but the build script could not find it, failing with failed to run command: "qmake" "-query" "QT_VERSION". I did some testing and Rust's std::process::Command was the problem as it couldn't find the added $PATH. Interestingly enough python's os.system was able to find it.

I created a symlink of ~/Qt/5.15.2/gcc_64/bin/qmake to /usr/bin and the example compiled fine, but I got the symbol lookup error: target/debug/_: undefined symbol: _ZN2Qt8showbaseER11QTextStream, version Qt_5. I ran ldd on the generated executable and it showed that it was linking against the /lib/x86_64-linux-gnu/libQt5* libraries installed with Ubuntu and not the ~/Qt/5.15.2/gcc_64/lib/libQt5* libraries that I installed. However, the C++ examples in ~/Qt/Examples ran just fine and linked with the correct libraries.

So this seems to be an environment variable/ritual build system issue. I'm gonna try and use Ubuntu's provided Qt and not the custom installed one and see if that works. This problem should be fixed nonetheless, but idk if the project is still being maintained

UditDey commented 2 years ago

Update: using just Ubuntu's Qt packages and not the custom installed one works just fine, maybe that can fix your issue as well

Riateche commented 2 years ago

Yes, undefined symbol errors when running an executable usually mean that you've built it against one Qt version but another Qt version is picked up by dynamic linker. As long as you follow Setting up, you should be fine. If the issue remains, try to examine relevant environment variables and remove any paths to the wrong Qt version from them.