Closed jbhoot closed 9 months ago
It looks GNU/Linux has right paths by default, but Mac doesn't. I think, that MacPorts should install pkg-config files somewhere with Qt5. In particular, you need to find a file /usr/lib/x86_64-linux-gnu/pkgconfig/Qt5Quick.pc
or something.
This file will be locate in some path and you could try to run
$ PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu pkg-config --libs-only-L Qt5Quick
In my GNU/Linux it gives and empty string (probably it is a reason why everyhting works out of box). Another useful command is
$ PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu pkg-config --libs-only-l Qt5Quick
-lQt5Quick -lQt5Gui -lQt5QmlModels -lQt5Qml -lQt5Network -lQt5Core
It is a list of libraries to link, which should be put into ocamlfind invocation with a proper amount of -ccopt
switches (I hope you see the pattern).
As a final step you should run something like
$ PKG_CONFIG_PATH=<path with .pc files> ocamlfind opt -package lablqml main.ml -thread -linkpkg \
-ccopt $(pkg-config --libs-only-L Qt5Quick)
-cclib -lQt5Quick -cclib -lQt5Qml -cclib -lQt5Network -cclib -lQt5Widgets -cclib -lQt5Gui -cclib -lQt5Core \
-cclib -lstdc++
N.B. I don't use MacOS, so my advice may be imprecise
P.S. There is a dune sample in the repo, you could try dune exec dune_test/program.exe
. It should invoke pkg-config itself, if you give right PKG_CONFIG_PATH=... variable.
After some experiments in docker, it looks like the right command for Mac is
export PATH=/opt/local/libexec/qt5/bin:$PATH
dune b @install -p lablqml && dune install lablqml
# create right files
ocamlfind opt -package lablqml a.ml -thread -linkpkg \
-ccopt -F/opt/local/libexec/qt5/lib -ccopt -framework -ccopt QtQuick -ccopt -framework -ccopt QtGui -ccopt -framework -ccopt QtQmlModels -ccopt -framework -ccopt QtQml -ccopt -framework -ccopt QtNetwork -ccopt -framework -ccopt QtCore \
-ccopt -lstdc++
Your last suggestion works! Now on to test more complex GUIs
I have been able to
opam install lablqml
. Qt5 is installed in the system through MacPorts.While trying to run the sample app as instructed in README, I get the following error:
I suspect that linker cannot find the location of Qt, but I don't know how to provide to it the location. Or I am wrong and there is another problem going on. Can you help?