问题描述
我在下面的路径中有arm-none-linux-gnueabi-g ++编译器,
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++
并且我在paho的build命令中的DCMAKE_COMPILER路径中给出了相同的内容,
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
在完成此构建后,
$ sudo cmake --build build/ --target install
$ sudo ldconfig
,我从"/home/user/octane_etk_sample-6.0.0.240/paho.mqtt.c/build复制了libpaho-mqtt3c.so,libpaho-mqtt3c.so.1,libpaho-mqtt3c.so.1.3.1. /src/"到此"-lltkcpp_atmel"所在的文件夹.
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.
当我说的话,找不到-lpaho-mqtt3c,
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
如何克服这个问题?在针对arm-none-linux-gnueabi-gcc& g ++?
How to overcome this issue? Is it something wrong while building the paho against arm-none-linux-gnueabi-gcc & g++?
注1:David Ranieri建议的编译器命令
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
注意2:
我已将cmake的版本从
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++
到
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
在将库构建为静态库之后,现在我可以成功地使用"makr arm"进行编译,即,下面给出的命令
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
这篇关于无法为arm-none-linux-gnueabi-g ++编译器找到-lpaho-mqtt3c的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!