Error while building app in cross-compiled qt in raspberry - c++

I'm trying to build and app on a cross-compiled qt5 in a raspberry pi.
This app is based on this rf24l01 library. When I compile a cpp program from the RPi, everything works fine, but when I tried from my pc running ubuntu 12.04 (32bits) the following error is through:
error: cannot find -lrf24-bcm
I point to the library using this line in the pro file:
LIBS += -L/mnt/rpi/usr/local/lib -lrf24-bcm
AFAIK, this is the path where the lib is located:
This is the result of `ls /mnt/rpi/usr/local/lib:
librf24-bcm.so libwiringPiDev.so libwiringPi.so.2.0
librf24-bcm.so.1 libwiringPiDev.so.2.0 python2.6
librf24-bcm.so.1.0 libwiringPi.so python2.7
Finally, this is the appeared error in detail:
/home/atron/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/arm-linux-gnueabihf-g++ -Wl,-rpath-link,/mnt/rpi/opt/vc/lib -Wl,-rpath-link,/mnt/rpi/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,/mnt/rpi/lib/arm-linux-gnueabihf --sysroot=/mnt/rpi -Wl,-rpath,/usr/local/opt/lib -o homekit main.o -L/mnt/rpi/usr/local/lib -lrf24-bcm -L/mnt/rpi/usr/local/opt/lib -lQt5Network -L/usr/local/opt/lib -lQt5Core -lpthread
/home/atron/opt/gcc-4.7-linaro-rpi-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lrf24-bcm
collect2: error: ld returned 1 exit status
What I`m doing wrong?
Thanks in advance,

I don't know if this is "technically" correct, but solved my problem.
The main idea is create a symbolic link of the library to my pc /usr/local/lib folder:
sudo ln -s /mnt/rpi/usr/local/lib/librf24-bcm.so /usr/local/lib/librf24-bcm.so
sudo ln -s /mnt/rpi/usr/local/lib/librf24-bcm.so.1 /usr/local/lib/librf24-bcm.so.1
sudo ln -s /mnt/rpi/usr/local/lib/librf24-bcm.so.1.0 /usr/local/lib/librf24-bcm.so.1.0
Then, on QT creator *pro file you only need to add the lib reference:
LIBS=-lrf24-bcm
I hope this could help to some newbie like me.
Regards,

Related

'uWS/uWS.h' file not found in XCode

I am attempting to import a C++ Game Server project into Xcode.
But I am running into the following error:
'uWS/uWS.h' file not found in XCode
I have tried importing the library by dragging it into the project, and ran the following commands to compile the uWebSockets library in Terminal:
git clone https://github.com/uNetworking/uWebSockets
cd uWebSockets
make
sudo make install
cd ..
But am running into this error. I have tried to search for how to resolve this is issue for a couple of hours, but still can't figure it out.
XCode Error
Here is my project hierarchy, I have tried to import/add the library in various different ways:
Project Hierarchy
Prior to using XCode, I would compile my code through terminal by running the following command:
g++ -O3 -L/usr/lib64 -std=c++14 src/main.cpp -pthread -lz -luWS -lssl -luv -o main
Any help would be highly appreciated.

Can't use static lib of mongo-cxx-driver on Linux

So I follow the official tutorial for the installation : https://mongodb.github.io/mongo-cxx-driver/mongocxx-v3/installation/
Neverless, I can't use the produced libraries as static.
So I managed to compile the C version of the driver as described, I've enabled the flag --enable-static=yes with the ./configure before doing make && sudo make install and I got the libmongoc-1.0.a and the libbson-1.0.a which are static. So this far, everything it's alright.
Then I have done the cxx version of the driver, except that there is no configuration file as in the C version. So I've juste done a
cmake -DCMAKE_BUILD_TYPE=Release -DBSONCXX_POLY_USE_BOOST=1 -DCMAKE_INSTALL_PREFIX=/usr/local
from the build folder, followed by a make && sudo make install
So I got the libmongocxx.a and the libbsoncxx.a, but when I try to compile with them, I can't run the binary because I got the following error :
error while loading shared libraries: libmongocxx.so._noabi: cannot open shared object file: No such file or directory
So I understand that is because there is some symbols missing and then I need to use the shared library to run the binary but I don't want this to happend, I want the symbols within the binary that I can run it without any LD_PRELOAD.
Any suggestions ?
I had the same issue in an Ubuntu 16.04 and I run a apt-get update & apt-get upgrade and the problem was solved.
It seems that there were some update to the compiler and some libraries that prevent some test from reaching the shared libraries.
I have a similar question, and solved, now I compiled and run my binary with static libs successfully.
I write my build script using newlisp, but the static link options are very helpful, I paste it here.
c++ /to/your/path/site/code/back_end/builder/object/files1.cc.o ... /to/your/path/site/code/back_end/builder/object/files10.cc.o -o bin/site -static-libgcc -static-libstdc++ -L/usr/lib -lpthread -l:libmongocxx.a -l:libbsoncxx.a -l:libmongoc-1.0.a -l:libbson-1.0.a -lrt -lssl -lcrypto -lsasl2 -l:libboost_log.a -l:libboost_log_setup.a -l:libboost_system.a -l:libboost_thread.a -l:libboost_filesystem.a -lcppcms -lbooster -lcurl -ljsoncpp

ld linker error "cpu model hidden symbol"

I'm getting an ld error when attempting to compile an sfml program on ubuntu 16.04. This is apparently a known issue, and there is supposed to be a workaround, but I don't understand what is it...
http://web.archive.org/web/20160509014317/https://gitlab.peach-bun.com/pinion/SFML/commit/3383b4a472f0bd16a8161fb8760cd3e6333f1782.patch
The error spat out by ld is
hidden symbol `__cpu_model' in /usr/lib/gcc/x86_64-linux-gnu/4.9/libgcc.a(cpuinfo.o) is referenced by DSO
There is no relevant code to this - as I understand it this error is produced on all ubuntu 16.04 systems with g++ 5, if the program to be linked contains objects such as sf::Texture and sf::Sprite. (I don't know any more detail than this.)
I have tried also compiling with g++ 4.9, but the same error occurs.
My compile line is g++-4.9 --std=c++11 -Wall main.cpp -lsfml-graphics -lsfml-window -lsfml-system -o a.out
Has anyone else experienced this error and resolved it successfully?
I've had to fix this issue several times. Instead of applying the patch, you can manually fix it by editing the file SFML/src/SFML/Graphics/CMakeLists.txt. At line 149, you will find the following:
if(SFML_COMPILER_GCC)
set_source_files_properties(${SRCROOT}/ImageLoader.cpp PROPERTIES COMPILE_FLAGS -fno-strict-aliasing)
endif()
After the endif(), insert the following:
if(SFML_COMPILER_GCC AND BUILD_SHARED_LIBS)
list(APPEND GRAPHICS_EXT_LIBS "-lgcc_s -lgcc")
endif()
Then, in the top-level SFML folder, run the following:
mkdir build && cd build
cmake .. -DSFML_BUILD_EXAMPLES=ON -DSFML_BUILD_DOCS=ON
make
sudo make install
sudo ldconfig
This will get it built and installed without the compiler error. (Note: Remove the -D flags from cmake if you don't want docs or examples)
I ran this in the SFML source directory before running the standard cmake...make:
curl https://gitlab.peach-bun.com/pinion/SFML/commit/3383b4a472f0bd16a8161fb8760cd3e6333f1782.patch \
| patch -p1
and that solved the problem
I've got the same linker error when trying to build SFML 2.4.2 with examples, specifically with opengl and shader ones.
Inspired by the #Joshua solution, I tried to change the compiler from GCC to Clang. It worked.
I am sharing here because it seems to be a simpler solution if you have no restrictions to use Clang.
Just download SFML and change to its directory. And...
mkdir build && cd build
cmake .. -DSFML_BUILD_EXAMPLES=ON -DCMAKE_CXX_COMPILER=clang++
make
sudo make install
sudo ldconfig
Removing -fvisibility=hidden from compiler options worked for me.

Qt5.5 static build cannot find -IGL on ubuntu14

I have compiled qt 5.5 for static building and it works fine.
However, when I add the widgets "QT += widgets" in the pro file I get the link error "cannot find -IGL"
From what I read this is to do with the Open GL libs. I have tried the following:
sudo apt-get install libglu1-mesa-dev
and
sudo apt-get install libgl1-mesa-dev
But no luck here... I am wondering if I need a static version of this? or maybe a symlink is missing, but I can't figure out the next step :(
Edit This is the actual error message:
g++ -static -static-libgcc -static-libstdc++ -Wl,-O1 -o ../targetRel/McpSupervisor main.o cconfig.o cconfigxml.o mcpprocessbase.o rpeprocess.o supervisor.o cipcomms.o mcpsupervisor_plugin_import.o moc_mcpprocessbase.o moc_supervisor.o moc_cipcomms.o -L/usr/lib/i386-linux-gnu/mesa -L/usr/local/Qt-5.5.1/lib -lQt5Xml -lQt5Widgets -L/usr/local/Qt-5.5.1/plugins/bearer -lqconnmanbearer -lqgenericbearer -lqnmbearer -lQt5Network -L/usr/local/Qt-5.5.1/plugins/platforms -lqxcb -L/usr/local/Qt-5.5.1/plugins/xcbglintegrations -lqxcb-glx-integration -lxcb-glx -lQt5XcbQpa -lX11-xcb -lXi -lxcb-render-util -lxcb-render -lxcb -lxcb-image -lxcb-icccm -lxcb-sync -lxcb-xfixes -lxcb-shm -lxcb-randr -lxcb-shape -lxcb-keysyms -lxcb-xkb -lQt5PlatformSupport -lfontconfig -lfreetype -lQt5DBus -lXrender -lXext -lX11 -L/usr/local/Qt-5.5.1/plugins/imageformats -lqdds -lqicns -lqico -lqjp2 -lqmng -lqtga -lqtiff -lqwbmp -lqwebp -lQt5Gui -lpng -lqtharfbuzzng -lQt5Core -lz -licui18n -licuuc -licudata -lqtpcre -lm -ldl -pthread -lgthread-2.0 -lglib-2.0 -lrt -lGL -lpthread
/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libX11.a(CrGlCur.o): In function open_library':
(.text+0x33): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: cannot find -lGL
/usr/local/Qt-5.5.1/plugins/imageformats/libqjp2.a(jas_stream.o): In functionjas_stream_tmpfile':
jas_stream.c:(.text+0x7a4): warning: the use of tmpnam' is dangerous, better usemkstemp'
/usr/local/Qt-5.5.1/lib/libQt5Core.a(qfilesystemengine_unix.o): In function QFileSystemEngine::resolveGroupName(unsigned int)':
qfilesystemengine_unix.cpp:(.text+0x943): warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libglib-2.0.a(libglib_2_0_la-gutils.o): In functiong_get_user_database_entry':
(.text+0x25a): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/i686-linux-gnu/4.8/../../../i386-linux-gnu/libglib-2.0.a(libglib_2_0_la-gutils.o): In function g_get_user_database_entry':
(.text+0xa3): warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/local/Qt-5.5.1/lib/libQt5Core.a(qfilesystemengine_unix.o): In functionQFileSystemEngine::resolveUserName(unsigned int)':
qfilesystemengine_unix.cpp:(.text+0x592): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/local/Qt-5.5.1/lib/libQt5Network.a(qhostinfo_unix.o): In function `QHostInfoAgent::fromName(QString const&)':
qhostinfo_unix.cpp:(.text+0x580): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status
make: *** [../targetRel/McpSupervisor] Error 1
09:49:17: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project qtMain (kit: Qt 5.5.1 GCC 32bit Static)
When executing step "Make"
09:49:17: Elapsed time: 00:08.
What is your actual problem :
You have unmet dependencies .
You are thinking that you have all the required dependencies because you installed
sudo apt-get install libglu1-mesa-dev
sudo apt-get install libgl1-mesa-dev
The problem is that you have a i386 system that is x32 system.
But you have installed development files for x64 systems using the commands above
Here is the ANSWER :
Intsall the following things
sudo apt-get install libgl1-mesa-dev:i386
sudo apt-get install libglu1-mesa-dev:i386
Now it should work ;)
Some other helpful stuff for visitors to this particular question
The lines below were my attempt to solve the problem but they did not work because the person who asked the question has a x32 system but the comments below work for x64 systems . But never the less the meta answer below will serve well for people who have the same problem and x64 systems. And also it will help problem to understand what are the basic steps to do after a similar problem occurs
# code_fodder I wanted to ask a question by making a comment below your question but I do not have 50 reputations to do so.
So I have to use the answer submission form to do so. :(
Do you have Miscellaneous Mesa GL utilities ?
If you dont have them then install using
sudo apt-get install mesa-utils
If you want to use OpenGl ES then you have to install Miscellaneous Mesa utilies (opengles, egl) using
sudo apt-get install mesa-utils-extra
Let me know if that works .
POSTING NEW INFORMATION ON 17-DEC-2015
I will post a portion of my project.pro file here . It specifically contains the library linking methods that I used for a simple OpenGL project.
I am using GLEW with OpenGL and SDL2
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp \
mesh.cpp \
display.cpp \
shader.cpp
HEADERS += \
mesh.h \
display.h\
shader.h
unix|win32: LIBS += -lGL \
-lGLEW \
/usr/local/lib/libSDL2-2.0.so
As you can notice I am using both static and dynamically linked libraries.
You may need to add:
unix | win32: LIBS += -L/usr/lib/x86_64-linux-gnu/mesa/ to your .pro file. However the path may be different for 32 bit systems. In that folder there are is the required mesa library files. These are the files for my system.
zehel#zehel-PC:/usr/lib/x86_64-linux-gnu/mesa$ ls
ld.so.conf libGL.so libGL.so.1 libGL.so.1.2.0
Try compiling now and see if that works
If that doesn't then either you have unmet dependencies or you are using old OpenGL.
Now after running the sudo apt-get install mesa-utils you will be able to use a command called glxinfo . It will show you all required information about your graphics card.
Run glxinfo | grep "OpenGl version string"
It will show you what version of OpenGl and mesa you have
mine is like this
OpenGL version string: 3.0 Mesa 10.3.2
If they are less than 3.0 then you are not using modern OpenGL and you may want to update your graphics drivers.
But if they are 3.0 or above then you are probably okay.
I cant reproduce your problem so I think that you have missing dependencies
See this posts on the QT forum where people with same problem as you are saying that there problems were fixed after installing the dependencies
http://forum.qt.io/topic/36282/solved-qt-5-2-0-and-lgl-issue
The last answer in the qt forum is quite good please refer it.
Update me whether it works or not .
Hope That helps .
You might need to specify the path where the GL library can be found, for exmaple by using the -L option to GCC, which has the following man page description:
-Ldir
Add directory dir to the list of directories to be searched for -l.

libboost-system linker errors when cross-compiling to x86

I'm trying to build a 32-bit application on Ubuntu 11.04 x64. I'm having some issues with the build because of linker errors with libboost. The build statement has -lboost_system in it, but when I try to build I get a bunch of these:
CommunicationModule.cpp:(.text+0x68c1): undefined reference to boost::system::generic_category()
CommunicationModule.cpp:(.text+0x68d7): undefined reference to boost::system::system_category()
Everything I've found on google says I need to link to the boost_system library. One place I found says to try linking to it directly, but when i do locate boost_system the result is empty. When I try doing a sudo apt-get install libboost-system-dev it tells me that it's already installed. I'm kind of at a loss here. The library is installed, but it's not being found by locate?
Can anyone tell me what I need to do to properly link to boost::system? I'm fairly new to linux and the complexities of compilers so any help here would be appreciated.
Update:
Here is the output of dpkg -L libboost-system1.42-dev:
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libboost-system1.42-dev
/usr/share/doc/libboost-system1.42-dev/copyright
/usr/share/doc/libboost-system1.42-dev/NEWS.Debian.gz
/usr/share/doc/libboost-system1.42-dev/README.Debian.gz
/usr/lib
/usr/lib/libboost_system.a
/usr/lib/libboost_system-mt.so
/usr/lib/libboost_system-mt.a
/usr/lib/libboost_system.so
Is there a flag I can use to link to one of these directly? I tried using -L /usr/lib/libboost_system.so and -L /usr/lib/libboost_system-mt.so and neither of those fixed the issue. Same with just adding /usr/lib/libboost_system.a and /usr/lib/libboost_system-mt.a to the build statement.
Here is the compilation line:
g++ -m32 -Wl,-O1 -o UTNaoTool [.o files] -L/usr/lib32 -lqglviewer-qt4 -lqwt-qt4 -lboost_system -lboost_thread -lQtXml -lQtOpenGL -lQtGui -lQtNetwork -lQtCore -lGLU -lpthread
Update 2:
I downloaded boost 1.49 and built everything for 32-bit and that seemed to help. A lot of the errors went away, but now I still have these:
CommunicationModule.cpp:(.text+0x68c1): undefined reference to
boost::system::get_generic_category()
Note that the function is different. So all of my errors are regarding undefined references to get_system_category() and get_generic_category() now. I tried adding a -lboost_filesystem to the build command but that didn't fix this, and I made sure it was referencing the 32-bit library that I built when I built libboost_system.
Looking at my own installation, it seems libboost-system-dev does not install the libraries. Using dpkg to tell me what was installed bz libboost-system-dev I get:
$ dpkg -L libboost-system-dev
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libboost-system-dev
/usr/share/doc/libboost-system-dev/copyright
/usr/share/doc/libboost-system-dev/changelog.gz
Poking around, I think you need to install libboost-system1.48.1 (or some other version).
sudo apt-get install libboost-system1.XX.Y
You can also search fo rthe libraries using the find command, for example, search under /usr for all files starting with libboost_system:
find /usr -name "libboost_system*"
Edit: Since you are cross-compiling from a 64 bit OS to a 32 bit one, you need 32 bit versions of the boost libraries. I would be tempted to set up a small 32 bit virtual machine to do this, rather than cross-compiling all the dependencies.
I had the same problem with boost_serialization here is what i found out after couple of googling..
first this library need to be compiled separately :
so after downloading the boost library ,extract it and execute sudo ./bootstrap.sh' then
sudo ./b2 --with-system
after this step you should be find a result when executing locate boost_system
then to link it manually I did:
both should work
g++ boostexample.cpp -o run /PATH/libboost_serialization.a
g++ boostexample.cpp -o run -L/PATH/ -lboost_serialization
well this is a little work around and I'm still looking for how to link the library properly
I hope this helped :)