Compile Output failed: cannot find -lpthread
-
Hi and thanks in advance.
I'm trying to cross compiling a qt5.12.6 in a raspi3 using as a host Ubuntu 20.04. I've followed all the steeps mentioned in different webs and everything has gone allrigth. But when I try to compile a program using the Qt Creator (Qt creator 4.11.0 / Based on Qt 5.12.8 (GCC 9.3.0, 64 bit) ) always returned the same fail:/opt/rpi-qt5.12.6/tools/cross-pi-gcc-8.3.0-1/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lpthread
/opt/rpi-qt5.12.6/tools/cross-pi-gcc-8.3.0-1/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lm
I don't know how to continue because I repeated all the steeps to use the sysroot files or my raspi3+ with gcc 8.3.0 and ./configure, make and make install has gone ok.
I need to solve this issue and I don't have enough knowledge of Qt to solve it.
Really thanks for your time.
-
@malamerda
Hello and welcome.Those messages are asking for two libraries to link with (
libpthread.a
&libm.a
). I am not sure whether that text indicates it cannot find them or that the command line is incorrect, I'm thinking the latter. Can you show the full compiler link command line it is generating? -
Hi and thanks!
this is the compile output:.._appTerm_Resources_Qml_TestTerm_TestTerm_qml.o qmlcache_loader.o -L/opt/rpi-qt5.12.6/sysroot//opt/vc/lib -L/home/ramon/Qt_projects/CIC/build-InterCIC-CM4_Rasp_Qt5_12_6-Release/main/../appAspi/ -lappAspi -L/home/ramon/Qt_projects/CIC/build-InterCIC-CM4_Rasp_Qt5_12_6-Release/main/../appCentro/ -lappCentro -L/home/ramon/Qt_projects/CIC/build-InterCIC-CM4_Rasp_Qt5_12_6-Release/main/../appTerm/ -lappTerm -L/home/ramon/Qt_projects/CIC/build-InterCIC-CM4_Rasp_Qt5_12_6-Release/main/../idilibs/ -lidilibs -L/home/ramon/Qt_projects/CIC/build-InterCIC-CM4_Rasp_Qt5_12_6-Release/main/../libs/ -llibs -L/home/ramon/Qt_projects/CIC/build-InterCIC-CM4_Rasp_Qt5_12_6-Release/main/../selbalibs/ -lselbalibs -L/home/ramon/Qt_projects/CIC/build-InterCIC-CM4_Rasp_Qt5_12_6-Release/main/../snap7/ -lsnap7 /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5QuickControls2.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Quick.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Svg.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5PrintSupport.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Widgets.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Multimedia.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Gui.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Qml.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Network.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5SerialPort.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5SerialBus.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Sql.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Core.so /opt/rpi-qt5.12.6/sysroot//usr/lib/arm-linux-gnueabihf/libGLESv2.so -lpthread
/opt/rpi-qt5.12.6/tools/cross-pi-gcc-8.3.0-1/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lpthread
/opt/rpi-qt5.12.6/tools/cross-pi-gcc-8.3.0-1/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lm
collect2: error: ld returned 1 exit status
make: *** [Makefile:461: ../bin/interCIC] Error 1
11:23:48: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project InterCIC (kit: CM4_Rasp_Qt5.12.6)
When executing step "Make"
11:23:48: Elapsed time: 00:00. -
@malamerda
I cannot see the-lm
on that line, I guess it's earlier on than you show. I cannot see anything obviously wrong with the syntax, so maybe thecannot find -lpthread
does indicate it can't find thelibpthread.a
(or could it belibpthread.so
, not sure). Do you have that file anywhere in thearm-linux-gnueabihf
hierarchy, or elsewhere but for cross-compile? Usefind
orlocate
to search for you (e.g.locate pthread
). -
@malamerda
Well I think that looks right, assuming it looks there.
I don't suppose you can find/paste the whole of your link line, by whatever means, what you showed earlier is only the end of it, I#d like to see the whole thing from the start (before what you show beginning with.._appTerm
)?
After that, if say you temporarilycp
orln -s
both thelibpthread.a
&libpthread.so
into the compiler object/executable directory for your project (where the `.o files are), does that alter the error message? (Don't forget to delete these copies/soft links from the directory you put them in when done.) -
this the main.pro building output:
12:52:15: Running steps for project InterCIC...
12:52:15: Configuration unchanged, skipping qmake step.
12:52:15: Starting: "/usr/bin/make" -j3
/opt/rpi-qt5.12.6/tools/cross-pi-gcc-8.3.0-1/bin/arm-linux-gnueabihf-g++ -mfloat-abi=hard --sysroot=/opt/rpi-qt5.12.6/sysroot/ -Wl,-O1 -s -Wl,-rpath,/usr/local/qt5.12.6/lib -Wl,-rpath-link,/opt/rpi-qt5.12.6/qt5.12.6/lib -Wl,-rpath-link,/opt/rpi-qt5.12.6/sysroot/opt/vc/lib -Wl,-rpath-link,/opt/rpi-qt5.12.6/sysroot/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,/opt/rpi-qt5.12.6/sysroot/lib/arm-linux-gnueabihf -o ../bin/interCIC main.o qrc___InterCIC_Resources_Qml_Widgets_Widgets_qmlcache.o qrc___InterCIC_Resources_Qml_Singleton_Singleton_qmlcache.o qrc_Imagenes.o qrc_Sonidos.o qrc_translations.o qrc___InterCIC_appAspi_Resources_Qml_MainAspi_mainAspi_qmlcache.o .._Resources_Qml_Widgets_CustomProgressBar_qml.o .._Resources_Qml_Widgets_VirtualKeyboard_qml.o .._Resources_Qml_Widgets_WeatherWidget_qml.o .._Resources_Qml_Widgets_CustomText_qml.o .._Resources_Qml_Widgets_CustomTextField_qml.o .._Resources_Qml_Widgets_CustomComboBox_qml.o .._Resources_Qml_Widgets_CustomButton_qml.o .._Resources_Qml_Widgets_VirtualKeyboardPanel_qml.o .._Resources_Qml_Widgets_ImageSvg_qml.o .._Resources_Qml_Widgets_CustomTextMoving_qml.o .._Resources_Qml_Widgets_LangButton_qml.o .._Resources_Qml_Complementos_AsistenteLavado_qml.o .._Resources_Qml_Complementos_BotonConf_qml.o .._Resources_Qml_Complementos_BotonIstobal_qml.o .._Resources_Qml_Complementos_FondoPantalla_qml.o .._Resources_Qml_Complementos_C_NumeroPrograma_qml.o .._Resources_Qml_Complementos_BotonSelecFase_qml.o .._Resources_Qml_Complementos_BotonX_qml.o .._Resources_Qml_Complementos_PMR_qml.o .._Resources_Qml_Complementos_LogoIstobal_qml.o .._Resources_Qml_Complementos_TiempoDinero_qml.o .._Resources_Qml_Complementos_QMLError_qml.o .._Resources_Qml_Complementos_A_InfoServicios_qml.o .._Resources_Qml_Complementos_C_InfoServicios_qml.o .._Resources_Qml_Complementos_TiempoDinero_15p_qml.o .._Resources_Qml_Ventanas_InstrucTFidelidadWin_qml.o .._Resources_Qml_Ventanas_C_InstrucPistolaWin_qml.o .._Resources_Qml_Ventanas_TFidelidadAceptadaWin_qml.o .._Resources_Qml_Ventanas_ConfirmFinWin_qml.o .._Resources_Qml_Ventanas_CreditoAPagarWin1_qml.o .._Resources_Qml_Ventanas_C_PagoTiempoSelWin_qml.o .._Resources_Qml_Ventanas_RecargaTFidMonedas_qml.o .._Resources_Qml_Ventanas_InfoFinServicio_qml.o .._Resources_Qml_Ventanas_ImportPersWin_qml.o .._Resources_Qml_Ventanas_ErrorCodigoWin_qml.o .._Resources_Qml_Ventanas_InstrucTarjetaWin_qml.o .._Resources_Qml_Ventanas_C_PagoTiempoSelWin_15p_qml.o .._Resources_Qml_Ventanas_ErrorCriticoWin_qml.o .._Resources_Qml_Ventanas_PagoTiempoSelWin_qml.o .._Resources_Qml_Ventanas_MetodosPagoWin_qml.o .._Resources_Qml_Ventanas_ModoEsperaWin_qml.o .._Resources_Qml_Ventanas_PagoAceptadoWin_qml.o .._Resources_Qml_Ventanas_TFidelidadWin_qml.o .._Resources_Qml_Ventanas_C_ModoEsperaWin_qml.o .._Resources_Qml_Ventanas_ErrorPagoWin_qml.o .._Resources_Qml_Ventanas_C_TFidelidadWin_qml.o .._Resources_Qml_Ventanas_BienvenidaWin_qml.o .._Resources_Qml_Ventanas_RecargaTFidTarjetaWin_qml.o .._Resources_Qml_Ventanas_RecargaTFidelidadWin_qml.o .._Resources_Qml_Ventanas_CreditoAPagarWin_qml.o .._Resources_Qml_Ventanas_IntroCodigo_qml.o .._Resources_Qml_Ventanas_InstrucMoneda_qml.o .._Resources_Qml_Utils_models_js.o .._Resources_Qml_Utils_utils_js.o .._Resources_Qml_Utils_JSON_JSONListModel_qml.o .._Resources_Qml_Utils_JSON_jsonpath_js.o .._Resources_Qml_Utils_JSON_JSONQueue_qml.o .._Resources_Qml_Utils_JSON_JSONpost_js.o .._Resources_Qml_Conf_ConfUpgrades_qml.o .._Resources_Qml_Conf_ConfLogin_qml.o .._Resources_Qml_Conf_ConfContFunc_qml.o .._Resources_Qml_Conf_QMLConfiguracion_qml.o .._Resources_Qml_Conf_ConfSignalbConfPLC_qml.o .._Resources_Qml_Conf_ConfAspirador_qml.o .._Resources_Qml_Conf_ModeloListaConf_qml.o .._Resources_Qml_Conf_ConfPlcS7_qml.o .._Resources_Qml_Conf_ConfLogger_qml.o .._Resources_Qml_Conf_ConfBusiness_qml.o .._Resources_Qml_Conf_ConfAvanzadas_qml.o .._Resources_Qml_Conf_ConfBotonCancel_qml.o .._Resources_Qml_Conf_ConfImportes_qml.o .._Resources_Qml_Conf_ConfFail_qml.o .._Resources_Qml_Conf_ConfReinicio_qml.o .._Resources_Qml_Conf_ConfCentro_qml.o .._Resources_Qml_Conf_ConfUpgradesFrom.ui_qml.o .._Resources_Qml_Conf_ConfManager_qml.o .._Resources_Qml_Conf_ConfRed_qml.o .._Resources_Qml_Conf_ConfContEco_qml.o .._Resources_Qml_Conf_ConfPlcCondicional_qml.o .._Resources_Qml_Conf_ConfBotonAceptar_qml.o .._Resources_Qml_Conf_ConfPagos_qml.o .._Resources_Qml_Conf_ConfLangs_qml.o .._Resources_Qml_Conf_ConfSistema_qml.o .._Resources_Qml_Conf_ConfTarifas_qml.o .._Resources_Qml_Test_TestBotones_qml.o .._Resources_Qml_Test_TestCoiner_qml.o .._Resources_Qml_Test_TestInOut_qml.o .._Resources_Qml_Test_TestMifare_qml.o .._Resources_Qml_Test_TestTeclado_qml.o .._Resources_Qml_Test_TestInOutCustomRow_qml.o .._Resources_Qml_Test_TestCanMonitor_qml.o .._Resources_Qml_Test_TestQR_qml.o .._Resources_Qml_Test_TestTPV_qml.o .._Resources_Qml_Singleton_Languages_qml.o .._Resources_Qml_Singleton_VariablesGlobales_qml.o .._appAspi_Resources_Qml_MainAspi_mainAspi_qml.o .._appAspi_Resources_Qml_TestAspi_TestAspi_qml.o .._appCentro_Resources_Qml_MainCentro_mainCentro_qml.o .._appCentro_Resources_Qml_TestCentro_TestCentro_qml.o .._appTerm_Resources_Qml_MainTerm_mainTerm_qml.o .._appTerm_Resources_Qml_TestTerm_TestTerm_qml.o qmlcache_loader.o -L/opt/rpi-qt5.12.6/sysroot//opt/vc/lib -L/home/disco_ssd/otilio/Qt_projects/CIC/build-InterCIC-CM4_Rasp_Qt5_12_6-Release/main/../appAspi/ -lappAspi -L/home/disco_ssd/otilio/Qt_projects/CIC/build-InterCIC-CM4_Rasp_Qt5_12_6-Release/main/../appCentro/ -lappCentro -L/home/disco_ssd/otilio/Qt_projects/CIC/build-InterCIC-CM4_Rasp_Qt5_12_6-Release/main/../appTerm/ -lappTerm -L/home/disco_ssd/otilio/Qt_projects/CIC/build-InterCIC-CM4_Rasp_Qt5_12_6-Release/main/../idilibs/ -lidilibs -L/home/disco_ssd/otilio/Qt_projects/CIC/build-InterCIC-CM4_Rasp_Qt5_12_6-Release/main/../libs/ -llibs -L/home/disco_ssd/otilio/Qt_projects/CIC/build-InterCIC-CM4_Rasp_Qt5_12_6-Release/main/../selbalibs/ -lselbalibs -L/home/disco_ssd/otilio/Qt_projects/CIC/build-InterCIC-CM4_Rasp_Qt5_12_6-Release/main/../snap7/ -lsnap7 /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5QuickControls2.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Quick.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Svg.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5PrintSupport.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Widgets.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Multimedia.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Gui.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Qml.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Network.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5SerialPort.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5SerialBus.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Sql.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Core.so /opt/rpi-qt5.12.6/sysroot//usr/lib/arm-linux-gnueabihf/libGLESv2.so -lpthread
/opt/rpi-qt5.12.6/tools/cross-pi-gcc-8.3.0-1/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lpthread
/opt/rpi-qt5.12.6/tools/cross-pi-gcc-8.3.0-1/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lm
collect2: error: ld returned 1 exit status
make: *** [Makefile:461: ../bin/interCIC] Error 1
12:52:15: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project InterCIC (kit: CM4_Rasp_Qt5.12.6)
When executing step "Make"
12:52:15: Elapsed time: 00:00.I've done a ln -s from the dir where the files appear to /opt/rpi-qt5.12.6/sysroot/usr/lib/arm-linux-gnueabihf but this not fixe the issue. I'll try to do other ln -s to the executable pro.
Really thanks -
I did the ln -s of libpthread* and libm* to object/executable/lib dir and the message have changed asking for another libs:
rpi-qt5.12.6/qt5.12.6/lib/libQt5Quick.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Svg.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5PrintSupport.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Widgets.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Multimedia.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Gui.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Qml.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Network.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5SerialPort.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5SerialBus.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Sql.so /opt/rpi-qt5.12.6/qt5.12.6/lib/libQt5Core.so /opt/rpi-qt5.12.6/sysroot//usr/lib/arm-linux-gnueabihf/libGLESv2.so -lpthread
/opt/rpi-qt5.12.6/tools/cross-pi-gcc-8.3.0-1/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: cannot find /lib/libc.so.6
/opt/rpi-qt5.12.6/tools/cross-pi-gcc-8.3.0-1/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: cannot find /usr/lib/libc_nonshared.a
/opt/rpi-qt5.12.6/tools/cross-pi-gcc-8.3.0-1/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld: cannot find /lib/ld-linux-armhf.so.3
collect2: error: ld returned 1 exit status
make: *** [Makefile:461: ../bin/interCIC] Error 1
13:01:09: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project InterCIC (kit: CM4_Rasp_Qt5.12.6)
When executing step "Make"
13:01:09: Elapsed time: 00:01.I can't understand what happend with the libs dependencies in the project and I don't know how and where I can changed them.
-
@malamerda
Still looks kind of Ok to me.
Mysteriously, there is still no-lm
argument anywhere, so where/why it gets itscannot find -lm
I do not know.
My "copy/link" was never intended to "fix" the issue, just to see if changed the error message. Though I'm not even surelib...
files in the current directory are picked up by-l...
argument. -
@malamerda said in Compile Output failed: cannot find -lpthread:
I did the ln -s of libpthread* and libm* to object/executable/lib dir and the message have changed asking for another libs:
Ah, the clue I hoped for! That tells you the
ld
is not currently being told to look for libraries in some directory where it is searching (usually the ones named in all your-L...
arguments [note: upper-caseL
for this]). I know nothing about RPi/cross-compilation, but that is what you need to investigate..... -
this is the ./configure I used to cross compile the raspberry sysroot:
../qt-everywhere-src-5.12.6/configure -opengl es2 -eglfs -no-gtk -device linux-rasp-pi-g++ -device-option CROSS_COMPILE=/opt/rpi-qt5.12.6/tools/cross-pi-gcc-8.3.0-1/bin/arm-linux-gnueabihf- -sysroot /opt/rpi-qt5.12.6/sysroot/ -prefix /usr/local/qt5.12.6 -extprefix /opt/rpi-qt5.12.6/qt5.12.6 -opensource -confirm-license -release -reduce-exports -force-pkg-config -nomake examples -nomake tests -no-compile-examples -no-use-gold-linker -skip qtwayland -skip qtwebengine -skip qtlocation -skip qtsensors -qt-pcre -no-pch -evdev -system-freetype -fontconfig -glib -qpa eglfs -v -recheck -L/opt/rpi-qt5.12.6/sysroot/usr/lib/arm-linux-gnueabihf -I/opt/rpi-qt5.12.6/sysroot/usr/include/arm-linux-gnueabihf
I'm not sure if I have to change the path in the -L/opt/... because I'm not sure the relation between this path and the Qt creator to build a project.
Really thanks for your time.
-
@JonB
anyway, do you know the way to install a Qt5.12.6 in embedded system in wich is installed by default a Qt5.11.3 version.
Our goal is to get a raspberry with a buster (raspbian distribution) with a Qt5.12.6 version. To do this I downloaded the qt5.12.6 sources and try to configure, make and make install in order to prepare a sysroot to cross compiling with a ubuntu 20.04 host. -
Hello guys I had similiar issue and I got some solution. In my case I was trying to make a crosscompilation between my VM with ubuntu 20 and RPI with ubuntu server 20. I was using this guide https://github.com/abhiTronix/raspberry-pi-cross-compilers/blob/master/QT_build_instructions.md
For some weird reason when there is line in qmake:
QT -= gui
it removes -L/home/jakub/rpi-qt/sysroot/usr/lib/arm-linux-gnueabihf from command line while building. So I added to qmake:
LIBS += -L/home/jakub/rpi-qt/sysroot/usr/lib/arm-linux-gnueabihf
Now it works fine. So try using line in *.pro file but change your <path to sysroot>.
LIBS += -L<Path_to_sysroot>/sysroot/usr/lib/arm-linux-gnueabihf