Qt5 Linux cannot find Qt libraries - linux

I am trying to compile an existing QT library with QT5.1 Beta on Ubuntu 12.04 with Clang.
This project compiles fine with QT4.8.4.
I am getting the below linker error when I compile the project with QT5.1 Beta.
/usr/bin/ld: cannot find -lQt5OpenGL
/usr/bin/ld: cannot find -lQt5Widgets
/usr/bin/ld: cannot find -lQt5Network
/usr/bin/ld: cannot find -lQt5Gui
/usr/bin/ld: cannot find -lQt5Core
My current system setup is as follows:
Installed the 64 bit linux pre-built package of QT5.1 Beta on my home directory
Added Qt5.1 qmake bin directory to PATH environment variable
Added QT5.1 lib directory to LD_LIBRARY_PATH
Installed Clang 3.3 and libc++
In QT Creator added a Kit with QT5.1 and Clang and built the project using this kit
I am getting the error on both launching the qtcreator from icon and bash.
The developer who was using this ubuntu system before had installed QT4 using apt-get.
I think QT4 got installed in the default OS directories and QT4 gets picked up always rather than QT5 when I build my project. I removed the QT4 packages that were under /usr/** path
When the build fails ,I see the below command being executed in qtcreator's compiler output window.
clang++ debug/moc-xxx.o -L -L/home/user/Qt5.1.0/5.1.0-beta1/gcc_64/lib -lQ5OpenGL -lQt5Widgets -lQt5Network -lQt5Gui -lGL -lpthread
Does the -L with no path tell the compiler to use the libs from the system's default paths?
What am I missing here?

You need to compile Qt with Clang first (Clang-3.2 example):
http://libre.tibirna.org/projects/qgit/wiki/Compile_Qt5_with_clang
because pre-built Linux Qt libraries are for gcc.
After building Qt you can configure the Kit for Qt Creator:
http://libre.tibirna.org/projects/qgit/wiki/Compile_QGit_with_Qt5_and_clang

Related

Problems with sfml function in linux

I have a sfml c++ project. In this project, if I use the "sf::Mouse::setPosition" sfml method, the program crashes in 2-3 seconds after launch. If i don't use the "sf::Mouse::setPosition" sfml method, the runs successfully.
OS: Kubuntu 22.10 x64,
Kernel: 5.19.0-28-generic,
Video card: GT 730,
Compiler: gcc version 12.2.0 (Ubuntu 12.2.0-3ubuntu1),
SFML has installed by apt, libsfml-dev version 2.5.1+dfsg-2.
Makefile:
`
compile:./main.cpp
g++ -c main.cpp
g++ main.o -o app -lsfml-graphics -lsfml-window -lsfml-system
run:
./app
`
I've tried to use legacy nvidia-driver-390, xserver-xorg-video-nouveau but it doesn't work. Maybe I should compile sfml source code for better compatibility, but i don't know how to do this. Also the problem might be in gcc version (maybe sfml 2.5.1 doesn't support 12.2.0).

Eclipse debug Alsa

I am trying to add alsa library to my Eclipse in order to cross-compile and debug in my iMX8X.
I have cross compiled the alsa-lib by
./configure --host=aarch64-unknown-linux-gnu --with-pcap=linux
I have added the library path where my libasound.so is in properties-> Cross GCC Linker -> libraries (search path), in my case /usr/lib, this is built
aarch64-linux-gnu-gcc -pthread -L/usr/lib -lasound -o "test1.elf" ./src/test1.o
but this error appears in my console and I dont know how to fix it,
/usr/lib/gcc-cross/aarch64-linux-gnu/9/../../../../aarch64-linux-gnu/bin/ld: no se puede encontrar -lasound
Should I try to compile alsa-utils, firmware, ...?
Or how can I debug this in order to use alsa snd_pcm functions?
Do I have to add some more files to the library definition?(like libasound.la or libasound.a)
Thanks in advance.
I have created an Ubuntu 20.04 Virtual Box image, compiled there alsa-lib, alsa-utils and alsa-tools libraries. I installed eclipse and link all the libraries in my linker. I managed to compile it by adding -L/usr/lib and -lasound again, deleting the previous one. Make sure where the compilation of your library is and link it in the Cross GCC Linker -> Libraries in a path, which in my case was /usr/lib. No idea why the previous one didnt work.

configure test with static lib

I am trying to cross compile libpng for RaspberryPi on Ubuntu 14.04 (x_64) with zlib
but configure fails with
configure:11400: arm-linux-gnueabihf-gcc -o conftest -g -O2 -I/home/user/RPI_DEV/lib/include conftest.c -lz -lm >&5
/home/user/RPI_DEV/xtools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/../lib/gcc/arm-linux-gnueabihf/4.8.3/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
configure:11400: $? = 1
configure: failed program was:
....
Because I am using toolchain for arm, arm-ld cant find zlib.
Is there any option for configure not to compile with shared lib but to try with static lib (eg. -static -lz).
Command is
./configure --enable-static=true --enable-shared=false --with-zlib-include="/home/user/RPI_DEV/lib/include" --with-zlib-lib="/home/user/RPI_DEV/lib/lib" LDFLGS="-L/home/user/RPI_DEV/lib/lib" CPPFLAGS="-I/home/user/RPI_DEV/lib/include" -enable-static --host=arm-linux-gnueabihf --prefix=/home/user/RPI_DEV/lib --exec-prefix=/home/user/RPI_DEV/lib
You need to cross build and install zlib into your toolchain before trying to use it in another project.
What you are doing might work but only if you spell LDFLAGS correctly:
LDFLGS="-L/home/user/RPI_DEV/lib/lib"
Note the missing 'A'. I don't know why your second attempt worked, given you had the same misspelling; possibly you had a correct LDFLAGS in your environment?
Anyway there should be a Ubuntu cross-development guide somewhere that explains how to do this. It's slightly off topic but for Gentoo you use 'crossdev' to install the toolchain then a crossdev specific version of the normal package installation mechanism ([host]-emerge) to install zlib into the toolchain.
Also, the arguments --with-zlib-include and --with-zlib-lib are not supported by any current version of libpng I can find. If you are cross-compiling libpng for an RPi (or, indeed, any ARM system) you should be using the latest version of 1.6 that you can find.
Unless someone solves this the RIGHT way, this is hack I've done.
Open configure.ac file
Find and comment out line
AC_CHECK_LIB(z, zlibVersion, , AC_ERROR([zlib not installed]))
Configure will pass wihout check for zlib and then add zlib by hand
LDFLGS="-L/home/user/RPI_DEV/lib/lib -L/home/user/RPI_DEV/lib/lib/libz.a"
Run autoconf
Run ./configure ...

How to get statically linked binaries after gcc downgrade

I'm not a linux expert but I'm running into the following problem which I hope to get solved here. My system has gcc 4.4 and I had to install an older version of gcc (gcc 4.2) on my home space so I can build a simulation tool.
Anyway, everything went well and I was able to build the tool.
However, when I now try to link statically using '-static' gcc option I get errors such as:
/usr/local/bin/ld: cannot find -lm
/usr/local/bin/ld: cannot find -lc
collect2: ld returned 1 exit status
I installed the dev package for glibc using (assuming the static version of the libraries will be installed)
$ yum install glibc-devel glibc-static
But I still get the errors.
I don't know where to go from here.
By the way, I added the local version of gcc (ie gcc 4.2) to PATH and the libs to the LD_LIBRARY_PATH and LIBRARY_PATH.
Do I need to get glibc and install it locally too, if so which version should I get?
Thanks

Setup netbeans for OGRE on Linux (Ubuntu)

I read Setting Up An Application - NetBeans - Linux in Ogre tutorials. But this instructs to build the project separately on console using make && make install. It seems Netbeans is only used as a editor. Is there a way to I do everything using Netbeans?
I tried to setup Netbeans to use OGRE libraries, but it was not successful. I get some errors when I build the project. This is what I did so far.
Project properties > C++ Compiler : Include Directories
/usr/include/OGRE:/usr/include/OIS:/usr/include
In Linker : I added all the
libogre*.so files in /usr/lib as
Libraries.
I used apt-get to install OGRE
pkg-config --libs OGRE
-lOgreMain -lpthread
pkg-config --cflags OGRE
-pthread -I/usr/include/OGRE
This link only provides details for doing this on windows.
Could someone tell me how to setup Netbeans for OGRE correctly on Linux
UPDATE
The console output
g++ -o dist/Debug/GNU-Linux-x86/carrace build/Debug/GNU-Linux-x86/TutorialApplication.o build/Debug/GNU-Linux-x86/BaseApplication.o -L/usr/bin -lPlugin_BSPSceneManager -lPlugin_CgProgramManager -lPlugin_OctreeSceneManager -lPlugin_OctreeZone -lPlugin_ParticleFX -lPlugin_PCZSceneManager -lRenderSystem_GL -lOgreMain -lOgrePaging -lOgreProperty -lOgreRTShaderSystem -lOgreTerrain -lOIS-1.3.0 -lOIS -lboost_date_time-mt -lboost_date_time -lboost_serialization-mt -lboost_serialization -lboost_thread-mt -lboost_thread -lboost_wserialization-mt -lboost_wserialization
/usr/bin/ld: cannot find -lPlugin_BSPSceneManager
/usr/bin/ld: cannot find -lPlugin_CgProgramManager
/usr/bin/ld: cannot find -lPlugin_OctreeSceneManager
/usr/bin/ld: cannot find -lPlugin_OctreeZone
/usr/bin/ld: cannot find -lPlugin_ParticleFX
/usr/bin/ld: cannot find -lPlugin_PCZSceneManager
/usr/bin/ld: cannot find -lRenderSystem_GL
I tried adding these folders separately but it didn't work.
Thank you in advance.
For me it worked with
-lOgreMain -lOgreTerrain -lOIS -lpthread
as linker options
and the same includes as you have
You forgot pkg-config --ldflags OGRE
You can see my tutorial in here http://arief-rublog.blogspot.com/2011/09/cara-pengaturan-ogre-dengan-ide.html , but my tutorial in Bahasa Indonesia, may be you can use google translate to translate it. i hope my tutorial is useful for you.

Resources