vanetza icon indicating copy to clipboard operation
vanetza copied to clipboard

CMake cannot find GeographicLib Cross-compilation

Open Sanjaer opened this issue 2 years ago • 2 comments

I cross-compiled vanetza and its dependencies a couple of months ago and everything went fine. Now I'm trying the same process (I automated it with some scripts) but it gives this error:

-- GeographicLib: using lookup code by Vanetza
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find GeographicLib (missing: GeographicLib_LIBRARY) (found
  suitable version "2.1", minimum required is "1.37")
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  cmake/FindGeographicLib.cmake:27 (find_package_handle_standard_args)
  CMakeLists.txt:63 (find_package)

However geographic lib is installed in vanetza-deps

$ ls vanetza-deps/lib/libGeographicLib.so
vanetza-deps/lib/libGeographicLib.so

This is my script to compile and install GeographicLib, based on the documentation available in the web

#!/bin/bash

WORKING_DIR=$(pwd)

if [ ! -d "vanetza" ]; then
	echo "Vanetza not found, clonning"
	git clone https://github.com/riebl/vanetza.git
fi

if [ -d "vanetza" ]; then
	git clone https://github.com/geographiclib/geographiclib geographiclib-code

	if [ -d "geographiclib-code" ]; then
		cd geographiclib-code
		mkdir build.arm
		cd build.arm
		cmake .. -DCMAKE_TOOLCHAIN_FILE=$WORKING_DIR/vanetza/cmake/Toolchain-Cohda-MK5.cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$WORKING_DIR/vanetza-deps
		make install
	else
		echo "Error clonning GeographicLib"
		exit 2
	fi
else
	echo "Error clonning vanetza"
	exit 1
fi

And for Vanetza:

#!/bin/bash

WORKING_DIR=$(pwd)

if [ -d vanetza-build ]; then
	rm -rf vanetza-build
fi

mkdir vanetza-build
cd vanetza-build

cmake $WORKING_DIR/vanetza \
    -DCMAKE_TOOLCHAIN_FILE=$WORKING_DIR/vanetza/cmake/Toolchain-Cohda-MK5.cmake \
    -DCMAKE_FIND_ROOT_PATH=$WORKING_DIR/vanetza-deps \
    -DCMAKE_INSTALL_RPATH=\$ORIGIN/../lib \
    -DCMAKE_INSTALL_PREFIX=$WORKING_DIR/vanetza-dist \
    -DBUILD_SOCKTAP=ON

make

Sanjaer avatar Jun 08 '22 08:06 Sanjaer

Hi @Sanjaer,

I suppose that a recent release of GeographicLib changes some aspects which are not yet handled correctly by our cmake/FindGeographicLib.cmake. As an intermediate fix, you may simply check out a specific version of GeographicLib, e.g. 1.52 should work fine.

riebl avatar Jun 09 '22 06:06 riebl

Hi @riebl I've found the following related issues. When I change the cmake/FindGeographicLib.cmake line 14 to find_library(GeographicLib_LIBRARY_RELEASE NAMES GeographicLib DOC "GeographicLib library (release)") instead of find_library(GeographicLib_LIBRARY_RELEASE NAMES Geographic DOC "GeographicLib library (release)"), the compilation works fine with the dependecies in $WORKING_DIR/vanetza-deps. Nevertheless, if I tried to use the option BUILD_SHARED_LIBS=ON, I've found that it is trying to include .so of geolib and crypto in /usr/include of cohda VM instead of vanetza-deps and it produces de same error commented by @Sanjaer with my change in the cmake, but it still works OK with the previous one. Can you check it this?

serserHR avatar Aug 24 '22 07:08 serserHR