Closed garethbaker11 closed 1 year ago
Hmmmz, I currently have no idea why it's not working.
Can you confirm that e.g. the file given by nim r ./scripts/nimqt_paths.nim '${qtcoreheaderdir}/qobject.h
exists?
And does ls /Users/garethbaker/Qt/6.4.2/
list macos
or macOS
(lower- vs uppercase)? I think the case should not matter on OSX, but just to be sure (on my system it's all lowercase).
Hi, The first command gives: /Users/garethbaker/Qt/6.4.2/macos/lib/QtCore.framework/Headers//qobject.h Not sure if the '//' has any effect but the file exists in that folder. 'macos' is all lowercase.
I think I found my mistake. Can you install the latest version, and try again?
Hi,
Thanks for working on this.
Compiling the example now gives a different error in the Link phase:
Hint: [Link]
Hint: gc: refc; opt: none (DEBUG BUILD, -d:release
generates faster code)
96933 lines; 4.232s; 179.242MiB peakmem; proj: /Users/garethbaker/Development/Nim/NimQtHello/hello.nim; out: /Users/garethbaker/Development/Nim/NimQtHello/hello [SuccessX]
Hint: /Users/garethbaker/Development/Nim/NimQtHello/hello [Exec]
dyld[17588]: Library not loaded: @rpath/QtCore.framework/Versions/A/QtCore
Referenced from: <3C614B45-7661-31CD-9FCC-4AF5B51EF3B9> /Users/garethbaker/Development/Nim/NimQtHello/hello
Reason: tried: '/System/Volumes/Preboot/Cryptexes/OS@rpath/QtCore.framework/Versions/A/QtCore' (no such file), '/Library/Frameworks/QtCore.framework/Versions/A/QtCore' (no such file), '/System/Library/Frameworks/QtCore.framework/Versions/A/QtCore' (no such file, not in dyld cache)
Error: execution of an external program failed: '/Users/garethbaker/Development/Nim/NimQtHello/hello '
The file its looking for is here on my system: Users/garethbaker/Qt/6.4.2/macos/lib/QtCore.framework/Versions/A/QtCore
The compilation (and linking) succeeded :)
The problem is now in running the executable (just try nim cpp
and run the file).
On OSX the custom library path is not stored in the binary. To do that, I think it's the easiest if you look at the build_hello
target in https://github.com/jerous86/nimqt/blob/main/Makefile, especially the install_name_tool
command.
Thus, QMAKE_PATH=/Users/garethbaker/Qt/6.4.2/macos/bin/qmake make examples/hello
should compile and run the hello example from the repository successfully.
Hi
Running install_name_tool on the generated binary fixes the problem.
Many thanks for working on this!
Using the Example in the README.md. I have nim set up via Homebrew and the compile fails with "fatal error: fatal error: 'QtWidgets/qapplication.h' file not found"
nim r scripts/nimqt_paths.nim Qt_root -> /Users/garethbaker/Qt/6.4.2/macOS/lib
qmake -v -> QMake version 3.1 Using Qt version 6.4.2 in /Users/garethbaker/Qt/6.4.2/macOS/lib
MacOS version 13.2.1 (Ventura)
Full compile output: Executing task: nim cpp -r hello.nim
Hint: used config file '/opt/homebrew/Cellar/nim/1.6.10/nim/config/nim.cfg' [Conf] Hint: used config file '/opt/homebrew/Cellar/nim/1.6.10/nim/config/config.nims' [Conf] ...................................................................................................................................................................................................... /Users/garethbaker/.nimble/pkgs/nimqt-0.1/nimqt.nim(64, 24) Warning: imported and not used: 'qnamespace' [UnusedImport] CC: ../../../../../opt/homebrew/Cellar/nim/1.6.10/nim/lib/system.nim CC: ../../../../../opt/homebrew/Cellar/nim/1.6.10/nim/lib/pure/parseutils.nim CC: ../../../../../opt/homebrew/Cellar/nim/1.6.10/nim/lib/pure/os.nim CC: ../../../../../opt/homebrew/Cellar/nim/1.6.10/nim/lib/pure/concurrency/cpuinfo.nim CC: ../../../.nimble/pkgs/nimqt-0.1/nimqt/qtcore/qstring.nim CC: ../../../.nimble/pkgs/nimqt-0.1/nimqt/qtcore/qobject.nim CC: ../../../.nimble/pkgs/nimqt-0.1/nimqt.nim CC: hello.nim /Users/garethbaker/.cache/nim/hello_d/@m..@s..@s..@s.nimble@spkgs@snimqt-0.1@snimqt@sqtcore@sqobject.nim.cpp:9/Users/garethbaker/.cache/nim/hello_d/@m..@s..@s..@s.nimble@spkgs@snimqt-0.1@snimqt.nim.cpp::109:: 10: fatal error: /Users/garethbaker/.cache/nim/hello_d/@mhello.nim.cpp/Users/garethbaker/.cache/nim/hello_d/@m..@s..@s..@s.nimble@spkgs@snimqt-0.1@snimqt@sqtcore@sqstring.nim.cpp::9'QtWidgets/qlayout.h' file not found9::10 10:: fatal error: fatal error: 'QtWidgets/qapplication.h' file not found 'QtCore/qstring.h' file not found fatal error: 'QtCore/qnamespace.h' file not found
include "QtWidgets/qapplication.h"
include "QtCore/qstring.h"
include "QtWidgets/qlayout.h"
include "QtCore/qnamespace.h"
1 error generated. 1 error generated. 1 error generated. Error: execution of an external compiler program 'clang++ -c -std=gnu++14 -funsigned-char -std=c++17 -I/Users/garethbaker/.nimble/pkgs/nimqt-0.1 -I/opt/homebrew/Cellar/nim/1.6.10/nim/lib -I/Users/garethbaker/Development/Nim/NimQtHello -o /Users/garethbaker/.cache/nim/hello_d/@m..@s..@s..@s.nimble@spkgs@snimqt-0.1@snimqt@sqtcore@sqobject.nim.cpp.o /Users/garethbaker/.cache/nim/hello_d/@m..@s..@s..@s.nimble@spkgs@snimqt-0.1@snimqt@sqtcore@sqobject.nim.cpp' failed with exit code: 1