Qt CrossCompile on raspberry pi shared library not found
-
I'm doing a project on my PC that is using a subdir project where I have the main program and few librarys.
I've tried to run the program without any link to the library (run it from PC to pi) and is fine everything is working as it should. any way when I'm linking the libraryes then is telling me that it can not vint and load the library. the library are in the same folder as the program witch is /home/pi/myApp/in my pro I have
target.path = /home/pi/myApp/ INSTALLS += target LIBS += -L/home/pi/myApp/ INCLUDEPATH += \ $$PWD/mainApp \ $$PWD/firstPlugIn \ $$PWD/secondPlugIn \ $$PWD/thirdPlugIn
now only in the pro of the mainApp I have the following to load the librarys
#LIBS += # -L/home/pi/myApp/ -lfirstPlugIn \ # -L/home/pi/myApp/ -lsecondPlugIn \ unix:LIBS += -L/home/pi/myApp/ -lfirstPlugIn unix:{ QMAKE_LFLAGS += -Wl,--rpath=/home/pi/myApp/ # QMAKE_LFLAGS_RPATH = }
On run config in Qt I've even added the
LD_LIBRARY_PATH /home/pi/myApp
but nothing seams to be working.
I want my library to be in the folder with my main program or in a subfolder of it.
What I have to do in this case??? -
Not really sure what does not work.
Anyhow one thing strikes
#LIBS += # -L/home/pi/myApp/ -lfirstPlugIn \ # -L/home/pi/myApp/ -lsecondPlugIn \
First the statements are commented out with the hash tag.
Second, if you remove the hash tag it is not correct. The "LIBS +=" statement is standing alone. The next two lines are connected, but only with each other by the continuation mark (backslash) at the end of line.
Possibly all an error due your attempts to get it work. However, if you want to make those statements work, you need to write it asLIBS += \ -L/home/pi/myApp/ -lfirstPlugIn \ -L/home/pi/myApp/ -lsecondPlugIn
the last backslash continued into an empty line, which should not cause problems, but it is not required.
-
I've tried that and is not working.. is commented out because now I'm using
unix:LIBS += -L/home/pi/myApp/ -lfirstPlugIn
witch is doing the same thing. instead of all 3 library I'm trying to figure out at least one. thel all other will be the same. but at the moment none of them seams to work (only if I'll put my libs in the lib folder witch I do not want. I want my libs in my own lib folder not the linux one)
It was commented out because I'm using the second bit..
any way at the moment nothing is working same error can not find teh lib firstPlugIn.any help highly apreciated
-
If you are not working with different OS' I would not use too many switches. Just a personal advice.
I am typically working on windows. However, as far as I remember is home some sort of a short cut which is being expended by the OS repectively the terminal you are using.
If I am not completely wrong, you should try to use the complete name of the folder.
-
@koahnig
thte error I'm getting is/home/andrei/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lfirstPlugIn
Tried everithing I could think of including
unix:QMAKE_RPATHDIR += /home/pi/myApp
nothing is working
-
Sorry, just saw that my memory failed on home. Again I am working on Windows and linux is scarcely used by me.
According to the qmake manual the -L part, resepctively teh actual path does not have a slash at the end. Not sure if that could be the problem.
Another issue are typically the names used. In that respect windows is less strict. -
@koahnig
the problem that I have is that on my PC I'm using a different pathe compared to RPI. maybe this is the problem .. but my program is intended to run on RPI.. so it has to be there.. and it has to be cross compiled and not native compiled... any sugestions?? -
@arsinte_andrei
I have posted a link to this post for someone else from the moderators. I have not enough knowledge to be of help, I fear. -
@koahnig
It create:firstPlugIn.so firstPlugIn.so.1 firstPlugIn.so.1.0 firstPlugIn.so.1.0.0
but only the last one is the actual file, all other are just the links to it made by compiler (Qt Creator - qmake)
and also it put this files in the corect folder where they should be
remote pi: /home/pi/myApp/ -
After a long and long search and searching others code I've found out how to make it work...
CONFIG(debug, debug|release) { ROUTDIR = debug } else { ROUTDIR = release } CONFIG(plugin, plugin) { build_pass:CONFIG(debug, debug|release) { TARGET = $$join(TARGET,,,_debug) # Qt uses '_debug' for unix and 'd' for Windows # which is not reliably detectable (e.g.: abcd.dll) # unix: TARGET = $$join(TARGET,,,_debug) # else: TARGET = $$join(TARGET,,,d) } } CONFIG -= warn_off CONFIG += warn_on CONFIG += debug_and_release ordered embed_manifest_dll embed_manifest_exe target.path = /home/pi/myApp INSTALLS += target DESTDIR = $$PWD/$$ROUTDIR LIBS += -L$$PWD/$$ROUTDIR INCLUDEPATH += \ $$PWD/myApp\ $$PWD/firstPlugIn\ $$PWD/secondPlugIn\ $$PWD/thirdPlugIn LIBS += \ -lfirstPlugIn \ -lsecondPlugIn -lthirdPlugIn
now is working on both... PC and raspberry pi
Many thanks for all hep -
Thank you for updating so others can learn from it.
-
-
Hi,
IIRC, you can use
$$qtLibraryTarget(name_of_the_library)
to get the name of the library with the correct extension. -
Hi, I am having simmilar problem to yours: https://forum.qt.io/topic/72844/could-not-load-shared-library-symbols
When I debug it still cannot find the symbols. I tried to set the LD_LIBRARY_PATH to /home/pi/ (this is where my executable is on the Raspberry Pi) but nothing changes. Could I please ask for help?EDIT: I have partially solved the problem in the linked topic, maybe someone will find it usefull.