Issue
I'm trying to compile the AWS iot localproxy on an rPi (have tried 3 and 4 and getting the same issue). I follow the instructions here >> href="https://github.com/aws-samples/aws-iot-securetunneling-localproxy" rel="nofollow noreferrer">https://github.com/aws-samples/aws-iot-securetunneling-localproxy
I have been sucessful compiling on macOS and the binary works, but when building on an rPi I get the folowing error...
[ 4%] Linking CXX executable bin/localproxytest
/usr/bin/ld: /usr/local/lib/arm-linux-gnueabihf/libprotobuf-lite.a(arena.cc.o): in function `google::protobuf::internal::ThreadSafeArena::Init(bool)':
arena.cc:(.text+0xa60): undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/localproxytest.dir/build.make:292: bin/localproxytest] Error 1
make[1]: *** [CMakeFiles/Makefile2:97: CMakeFiles/localproxytest.dir/all] Error 2
make: *** [Makefile:103: all] Error 2
It seems to be a problem linking to '__atomic_fetch_add_8' or the atomic libs? Any clues on how to resolve? Anyone been successful building this on an rPi?
Solution
I believe there is an issue with CMake and the order of linking with ld.
moving.
In CMakeLists.txt
Moving atomic
to be the last link command after all the sources fixed this for me
https://github.com/aws-samples/aws-iot-securetunneling-localproxy/blob/main/CMakeLists.txt#L94
if(NOT APPLE AND NOT MSVC) target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TARGET_NAME} atomic) target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} atomic) endif()
should be below https://github.com/aws-samples/aws-iot-securetunneling-localproxy/blob/main/CMakeLists.txt#L111
target_link_libraries(${AWS_TUNNEL_LOCAL_PROXY_TEST_NAME} ${Protobuf_LITE_STATIC_LIBRARY})
Answered By - BAO Answer Checked By - Mildred Charles (WPSolving Admin)