Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Linking issues with armadillo
thmann last edited by
I am trying to get armadillo running with QT Creator on macOS Mojave 10.14. I have located the unpacked armadillo archive in my user directory. My .pro file currently looks like this:
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
LIBS += -larmadillo
INCLUDEPATH += /Users/xyz/armadillo-9.100.6/include
Upon running I get "library not found for -larmadillo". On windows-related threads I have seen people also adding a library path to LIBS, something like LIBS += -L/path/armadillo-xyz/lib_win64. However, I do not see which -L path would be relevant for MacOS. Could this be the issue or is it something else?
Could this be the issue
Sure. The linker has a fixed search path (which I know better on Windows and Linux, but mac should be similar to Linux). So you need to specify the directory, where
libarmadillo.so(I guess that should be the name) resides if the lib is outside the default search paths.
Please note that you need to specify the
-larmadillo, otherwise it will not work.
thmann last edited by thmann
I'm afraid I don't have any such file on my system. Possibly interesting files I could find are "libarmadillo.9.10.6.dylib" right in the armadillo directory and "wrapper.cpp.o" in ./CMakeFiles/armadillo.dir/src which both seem to have been created at the runtime library installation with cmake. These are not the same as the shared library format you are proposing, right? Sorry for asking this question, I am rather new to these terms. Anyway, the armadillo readme only provides instructions on how to compile directly. The standard advice is
g++ example1.cpp -o example1 -O2 -larmadillo
while they also tell you how to compile without using the runtime library by
g++ example1.cpp -o example1 -O2 -I /home/blah/armadillo-7.200.3/include -DARMA_DONT_USE_WRAPPER -lblas -llapack
Can I somehow reference the installed runtime library if I do everything in QT Creator?
Also, the first of the above commands did not yield any error at compilation. At runtime I got
dyld: Library not loaded: @rpath/libhdf5.101.dylib
Referenced from: /usr/local/lib/libarmadillo.9.dylib
Reason: image not found
It seems to think I have the dylib in /usr/local/lib/libarmadillo.9.dylib while actually my armadillo directory is /Users/xyz/armadillo-9.100.6 and there is a /Users/xyz/armadillo-9.100.6/libarmadillo.9.dylib alias pointing to /Users/xyz/armadillo-9.100.6/libarmadillo.9.100.6.dylib.
@thmann I'm sorry, but my mac knowledge is too limited to answer this correctly.
Hi and welcome to devnet,
Did you call
make installafter building armadillo ?
You can add the
DYLD_LIBRARY_PATHenvironment variable in the Run part of the Project panel in Qt Creator and list the folders where the dependencies of your libraries can be found.