赞
踩
I have the arm-none-linux-gnueabi-g++ compiler in the below path,
root@user-VirtualBox:~# which arm-none-linux-gnueabi-g++
/home/user/octane_etk-6.0.0.240/arm-toolchain/bin/arm-none-linux-gnueabi-g++
and I have given the same in DCMAKE_COMPILER path in the build command of paho,
user@user-VirtualBox:~/octane_etk_sample-6.0.0.240/paho.mqtt.c$ cmake -Bbuild -H. -DPAHO_WITH_SSL=OFF -DPAHO_ENABLE_TESTING=OFF -DCMAKE_C_COMPILER=/home/user/octane_etk-6.0.0.240/arm-toolchain/bin/arm-none-linux-gnueabi-gcc -DCMAKE_CXX_COMPILER=/home/user/octane_etk-6.0.0.240/arm-toolchain/bin/arm-none-linux-gnueabi-g++
-- The C compiler identification is GNU 4.8.1
-- Check for working C compiler: /home/user/octane_etk-6.0.0.240/arm-toolchain/bin/arm-none-linux-gnueabi-gcc
-- Check for working C compiler: /home/user/octane_etk-6.0.0.240/arm-toolchain/bin/arm-none-linux-gnueabi-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- CMake version: 3.10.2
-- CMake system name: Linux
-- Timestamp is 2020-04-17T07:33:49Z
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_CXX_COMPILER
-- Build files have been written to: /home/user/octane_etk_sample-6.0.0.240/paho.mqtt.c/build
After this build I have given,
$ sudo cmake --build build/ --target install
$ sudo ldconfig
and I have copied libpaho-mqtt3c.so, libpaho-mqtt3c.so.1, libpaho-mqtt3c.so.1.3.1 from "/home/user/octane_etk_sample-6.0.0.240/paho.mqtt.c/build/src/" to the same folder where this "-lltkcpp_atmel" resides.
Whereas, when I give make it says, cannot find -lpaho-mqtt3c,
root@user-VirtualBox:/home/user/octane_etk_sample-6.0.0.240# make arm
mkdir -p ./bin
arm-none-linux-gnueabi-g++ \
-Wno-write-strings \
-Iinclude \
speedway_embedded_example.cpp -lpaho-mqtt3c \
-Llib \
-static -lltkcpp_atmel -lltkcppimpinj_atmel -lxml2_atmel \
-lssl_atmel -lcrypto_atmel -ldl_atmel \
-o bin/speedwayr_arm
/home/user/octane_etk-6.0.0.240/arm-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.1/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lpaho-mqtt3c
How to overcome this issue? Is it something wrong while building the paho against arm-none-linux-gnueabi-gcc & g++?
Note 1:
Compiler command suggested by David Ranieri
root@user-VirtualBox:/home/mindlogic/octane_etk_sample-6.0.0.240# make arm
mkdir -p ./bin
arm-none-linux-gnueabi-g++ \
-Wno-write-strings \
-o bin/speedwayr_arm \
-Iinclude \
speedway_embedded_example.cpp -lpaho-mqtt3c \
-Llib \
-static -lltkcpp_atmel -lltkcppimpinj_atmel -lxml2_atmel \
-lssl_atmel -lcrypto_atmel -ldl_atmel
/home/mindlogic/octane_etk-6.0.0.240/arm-toolchain/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.1/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lpaho-mqtt3c
Note 2:
I have changed the cmake build from
cmake -Bbuild -H. -DPAHO_WITH_SSL=OFF -DPAHO_ENABLE_TESTING=OFF -DCMAKE_C_COMPILER=/home/user/octane_etk-6.0.0.240/arm-toolchain/bin/arm-none-linux-gnueabi-gcc -DCMAKE_CXX_COMPILER=/home/user/octane_etk-6.0.0.240/arm-toolchain/bin/arm-none-linux-gnueabi-g++
to
cmake -Bbuild -H. -DPAHO_WITH_SSL=OFF -DPAHO_ENABLE_TESTING=OFF
-DPAHO_BUILD_STATIC=True -DCMAKE_C_COMPILER=/home/user/octane_etk-6.0.0.240/arm-toolchain/bin/arm-none-linux-gnueabi-gcc -DCMAKE_CXX_COMPILER=/home/user/octane_etk-6.0.0.240/arm-toolchain
After building a library as static one, now I can able to compile with "makr arm", successfully i.e., commands given below
root@user-VirtualBox:/home/user/octane_etk_sample-6.0.0.240# make cap
mkdir -p ./bin
arm-none-linux-gnueabi-g++ \
-Wno-write-strings \
-Iinclude \
speedway_embedded_example.cpp \
-Llib \
-static -lltkcpp_atmel -lltkcppimpinj_atmel -lxml2_atmel \
-lssl_atmel -lcrypto_atmel -ldl_atmel -lpaho-mqtt3c-static -ljansson -lpthread \
-o bin/speedwayr_arm
解决方案
Order matters, try generating the object before linking:
arm-none-linux-gnueabi-g++ \
-Wno-write-strings \
-o bin/speedwayr_arm \
-Iinclude \
speedway_embedded_example.cpp -lpaho-mqtt3c \
-Llib \
-static -lltkcpp_atmel -lltkcppimpinj_atmel -lxml2_atmel \
-lssl_atmel -lcrypto_atmel -ldl_atmel
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。