Navigator-Lib: .so file not recognized

[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

1 Like

Hi @rturrisi,

Is there a reason to not use the standalone cmake provided ?
It should work as expected and it does the proper tests.
I would recommend to use and test it, and once it’s working, do the necessary changes for your project based on that.

I just verified the .so files and the architectures are correct.

1 Like

Hey @rturrisi ,

I’ve updated the CMakeList for standalone;
there’s an issue with the folder’s architecture name for 64 bits.

I’ve tested it with the latest Raspbian Lite 64-bit image.

Could you try it out and let me know if you encounter any issues?

2 Likes

Hey Raul,

Thanks for getting back to me. The only libraries that I can pull from upstream that work are the 32 git images.

Locally working image:

$ file ../navigator-lib/target/release/libbluerobotics_navigator.so
../navigator-lib/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

Upstream libraries installed locally from the CMake file you uploaded:

$ file build/navigator_lib/*/*                                     
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
build/navigator_lib/aarch64-unknown-linux-musl/libbluerobotics_navigator.so:     ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, with debug_info, not stripped
build/navigator_lib/armv7-unknown-linux-gnueabihf/libbluerobotics_navigator.so:  ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, BuildID[sha1]=972a9393ad71ecbf1c6279441f971c6bee6a6a6f, with debug_info, not stripped
build/navigator_lib/armv7-unknown-linux-musleabihf/libbluerobotics_navigator.so: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, with debug_info, not stripped

When I run uname -a, my architecture is indeed aarch64, however it does not work within the CMake file. I made the following updates and it works.

Within my project’s top level CMake file, I have:


IF(${ON_VEHICLE})

   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")

   set(ZIP_UNPACK_DIR "${CMAKE_BINARY_DIR}/navigator_lib")
   message(STATUS "Identified system processor: ${CMAKE_SYSTEM_PROCESSOR}")

   # Download and unpack Navigator library
   ExternalProject_Add(
      navigator_lib
      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 ""
   )

      if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv7")
         set(LIB_PATH_SUBDIR "armv7-unknown-linux-gnueabihf")
      elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv8" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
         #set(LIB_PATH_SUBDIR "aarch64-unknown-linux-gnu")
         set(LIB_PATH_SUBDIR "armv7-unknown-linux-gnueabihf")
      else()
         message(FATAL_ERROR "Unsupported architecture")
   endif()

   set(NAVIGATOR_LIB "${ZIP_UNPACK_DIR}/${LIB_PATH_SUBDIR}/libbluerobotics_navigator.so")
   set(NAVIGATOR_INCLUDE "${ZIP_UNPACK_DIR}/")
   include_directories(${NAVIGATOR_INCLUDE})

ENDIF(${ON_VEHICLE})

and downstream when building an application, I have:

SET(SRC
   main.cpp  
) 

ADD_EXECUTABLE(test_nav_ipt ${SRC})

add_dependencies(test_nav_ipt navigator_lib)

TARGET_INCLUDE_DIRECTORIES(test_nav_ipt PRIVATE "${NAVIGATOR_INCLUDE}")

TARGET_LINK_LIBRARIES(test_nav_ipt
   ${NAVIGATOR_LIB}
   rpi_utils)

and it builds/executes just fine.

Let me know if there is anything else I can provide.

@rturrisi The OS is the one from BlueOS with apt-get upgraded kernel?

Personally I didn’t like the way the upgrade is being done for the raspbian armv7 versions,
It’s is forcing to load the architecture aarch64 after the upgrade, it can break all your applications if they are armv7 based. To avoid this kernel change you can add arm_64bit=0 inside /boot/config.txt

Yes - I cloned the BlueOS image provided with the navigator kit onto a new SD card, ssh’d into the Pi, removed all docker containers/docker artifacts, and began custom software installation where I had to update/upgrade the system with apt. Once more, thank you for your response!