[Update]
I was able to get it working by:
- Inside navigator-lib/Cargo.toml, add the following lines
crate-type = ["staticlib", "dylib"]
- Execute:
$ cargo build --release --lib
- Delete the .so file in project-repo/navigator-lib/aarch64-unknown-linux-gnu/
- Move the new .so library from target/release/libbluerobotics_navigator.so to ~/project-repo/build/navigator_lib/aarch64-unknown-linux-gnu/libbluerobotics_navigator.so
- Recompile my project
When I inspect the new file I get this output, where it is a 32 bit .so, which is not present in any of the builds which are pulled from from the CMake file.
$ file target/release/libbluerobotics_navigator.so target/release/libbluerobotics_navigator.so: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, BuildID[sha1]=e14dc02b1b208c83983f5ebae7763f8a202b43f0, with debug_info, not stripped
I built and ran the new applications just fine after doing this. Will a change be posted upstream on Github?
–
[Original Post]
I have a collection of applications which use the navigator library, and I’m having problems when linking to the libbluerobotics_navigator.so file. I was wondering if this may be an issue with the cross compiler used upstream? I was basing this off of:
The issue is that when building, it says that the shared object library is not recognized. This baseline application in test_nav_simple
, is the simple.cpp application which is in the navigator-lib repository.
[ 68%] Linking CXX executable ../../../../bin/test_nav_simple
/home/pi/project-repo/build/navigator_lib/aarch64-unknown-linux-gnu/libbluerobotics_navigator.so: file not recognized: file format not recognized
collect2: error: ld returned 1 exit status
make[2]: *** [src/applets/test_nav_simple/CMakeFiles/test_nav_simple.dir/build.make:104: ../bin/test_nav_simple] Error 1
make[1]: *** [CMakeFiles/Makefile2:316: src/applets/test_nav_simple/CMakeFiles/test_nav_simple.dir/all] Error 2
make: *** [Makefile:103: all] Error 2
$ file ~/project-repo/build/navigator_lib/aarch64-unknown-linux-gnu/libbluerobotics_navigator.so
build/navigator_lib/aarch64-unknown-linux-gnu/libbluerobotics_navigator.so: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[sha1]=8aebddf9e0333ff9e36676a8f8113a607b128397, with debug_info, not stripped
File structure:
~/navigator-lib/
~/project-repo/
-- build.sh
-- clean.sh
-- CMakeLists.txt (1)
-- src/
-- -- CMakeList.txt (2) -> adds applications and sets environmental variables such as the path for the navigator library
-- -- applets/
-- -- -- CMakeList.txt (3) -> simply adds the app subdirectories
-- -- -- test_app/
-- -- -- -- CMakeList.txt (4)
-- -- -- -- main.cpp
CMakeList.txt (1) is generic and can be found here: https://oceanai.mit.edu/svn/moos-ivp-extend/trunk/CMakeLists.txt
I have it such that in CMakeList.txt (2), the library is defined for all downstream applications.
CMakeList.txt (2)
#============================================================================
# Add the libraries in the current directory to the include path
#============================================================================
FILE(GLOB LOCAL_LIBRARY_DIRS ./lib_*)
INCLUDE_DIRECTORIES(${LOCAL_LIBRARY_DIRS})
include(ExternalProject)
# Navigator version and download URL
set(NAVIGATOR_VERSION "0.0.3")
set(ZIP_URL "https://github.com/bluerobotics/navigator-lib/releases/download/${NAVIGATOR_VERSION}/cpp.zip")
# Download and unpack Navigator library
ExternalProject_Add(
navigator_zip
URL ${ZIP_URL}
DOWNLOAD_DIR "${CMAKE_BINARY_DIR}/navigator_lib_download"
SOURCE_DIR "${CMAKE_BINARY_DIR}/navigator_lib"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
# Determine the system architecture and set the library directory accordingly
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv7")
set(NAVIGATOR_LIB "${CMAKE_BINARY_DIR}/navigator_lib/armv7-unknown-linux-gnueabihf/libbluerobotics_navigator.so" CACHE INTERNAL "Navigator library directory")
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
set(NAVIGATOR_LIB "${CMAKE_BINARY_DIR}/navigator_lib/aarch64-unknown-linux-gnu/libbluerobotics_navigator.so" CACHE INTERNAL "Navigator library directory")
# Add more architectures as needed
else()
message(FATAL_ERROR "Unsupported architecture")
endif()
set(NAVIGATOR_INCLUDE "${CMAKE_BINARY_DIR}/navigator_lib")
#============================================================================
# List the subdirectories to build...
#============================================================================
ADD_SUBDIRECTORY(applets)
CMakeList.txt (4)
# Set System Specific Libraries
if (${WIN32})
# Windows Libraries
SET(SYSTEM_LIBS
wsock32 )
else (${WIN32})
# Linux and Apple Libraries
SET(SYSTEM_LIBS
m
pthread )
endif (${WIN32})
SET(SRC
main.cpp
)
message(STATUS "test_simple building")
message(STATUS "Headers: ${NAVIGATOR_INCLUDE}")
message(STATUS "Lib: ${NAVIGATOR_LIB}")
ADD_EXECUTABLE(test_nav_simple ${SRC})
TARGET_INCLUDE_DIRECTORIES(test_nav_simple PRIVATE "${NAVIGATOR_INCLUDE}")
TARGET_LINK_LIBRARIES(test_nav_simple
${NAVIGATOR_LIB})
CMakeList.txt (4) does print out:
-- Headers: /home/pi/project-repo/build/navigator_lib
-- Lib: /home/pi/project-repo/build/navigator_lib/aarch64-unknown-linux-gnu/libbluerobotics_navigator.so
Any thoughts on why the file may not be recognized/not working?
Thanks