could not add wiringPi to Qt after cross compiling
-
(Unless I am missing it and my eyes are too slow...) Your screenshot shows that the '*so' is in the
test_v1
folder, but INCLUDEPATH is not for finding the '*so', it is for finding the header file. So as @mrjj asked: what folder has as plain-text file named "wiringPi.h" inside it? That is the folder to add to INCLUDPATH.If you can find a copy of this book (either an online PDF copy or any other), then I highly recommend it to all people just getting started in either C or C++. It's less than 100 pages and full of compilation examples that precisely clarify what header files are and what their relationship to '*so' files is.
Also, while the book title says "GCC", the same principles hold one-for-one when using Clang.
(Book: An Introduction to GCC, by Brian Gough)
-
Typically, in order to use a
*so
shared library, you need both the binary library itself (the*so
) and the human-readable header files*h
.In the build configuration, you need to "point to" the location of both those:
INCLUDEPATH += $${dirforheaders} # DO NOT COPY THIS LITERALLY. Adjust for your use. LIBS += -L$$shadowed($$PWD) -lwiringPi # DO NOT COPY THIS LITERALLY. Adjust for your use.
There is no technology that allows the build process (the "build toolchain") to extrapolate from the
*so
where to find the corresponding headers.So you almost always need to adjust you INCLUDEPATH and your LIBS.
You might be thinking of an exceptional case, like... "well how is it that I use
zlib.h
orlocale.h
or other well-known header files without figuring out the relevant INCLUDEPATH?" ... This would be a good question! This is due to certain paths being automatically searched.The following are common automatically-searched paths:
/usr/local/include
/usr/includeMore info: https://gcc.gnu.org/onlinedocs/gcc-4.9.4/cpp/Search-Path.html
UPDATE: @Pablo-J-Rogina is correct to also mention the particular specific concerns in a cross-compiling environment. I admit that even though "cross compile" is mentioned immediately at the top of the question, I neglected to consider those particulars.
At minute 23:20 of the video tutorial the video author switches the target to Arm ABI, and that is when he made the "no such file or directory" go away on his machine. Suggesting that on the video author's machine, the header was present in some directory such as
"${MY_CROSSCOMPILE_TOOLS}/arm_abi/sysroot/usr/include/"
-
@KH-219Design
Thank you for clarifying! it seems quite obvioushttps://www.youtube.com/watch?v=_R_NA-vubKw
I was following this tutorial (minute 21:48) he is adding this library and he just copied the .so file
but I think that wiringPi is installed on his raspberry before he cross compiled Qt so when he created the sysroot directory it contains already the wiringPi.h but the problem is when he added the external library he putted in the INCULUDEPATH the path of his working directory and not the sysroot/usr/include but it worked for him.
I just copied the /usr/include/wiringPi.h in my working folder and now it is working.
Thank you ! -
@amina just in case, when you're working with a cross-compile environment and you later on add a library (.so + .h files) to your device, you're supposed to synchronize again, that is, making those files from the device copied into your sysroot in your host machine.
-
I'm glad it's working now.
I noticed in the description of the YouTube video that the video author links to a GitHub repo, and indeed the GitHub repo shows no sign of adding any
INCLUDEPATH
other than$$PWD
.You might be able to communicate with the author on GitHub by opening an issue on that repo. It seems unnecessary now. But if anything else comes up you might entertain the idea.
-
@Pablo-J-Rogina
thank you, I didn't know that. I just need to synchronize the /usr/include and /usr/lib or all the sysroot?rsync -avz pi@192.168.1.31:/usr/include sysroot/usr rsync -avz pi@192.168.1.31:/usr/lib sysroot/usr
-
@KH-219Design said in could not add wiringPi to Qt after cross compiling:
You might be able to communicate with the author on GitHub by opening an issue on that repo. It seems unnecessary now. But if anything else comes up you might entertain the idea.
okay i will consider it next time, thank you
-
@amina said in could not add wiringPi to Qt after cross compiling:
I just need to synchronize the /usr/include and /usr/lib or all the sysroot?
It depends on the changes you do, and if you know exactly what folders were modified.
Some people perform the sync for the whole sysroot just in case.