linux 编译mqtt静态库,无法为arm-none-linux-gnueabi-g ++编译器找到-lpaho-mqtt3c

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值