riebl / vanetza

Open-source implementation of the ETSI C-ITS protocol stack
Other
202 stars 158 forks source link

Recompiling error #183

Closed Krupass closed 1 year ago

Krupass commented 1 year ago

Hello, I tried to recompile with sudo cmake .. -D BUILD_SOCKTAP=ON -D BUILD_CERTIFY=ON -D SOCKTAP_WITH_GPSD=ON -DCMAKE_PREFIX_PATH="some path" as advised in https://github.com/riebl/vanetza/issues/182. I got error Could NOT find GPS (missing: GPS_INCLUDE_DIR GPS_LIBRARY).

Any idea how to fix this?

riebl commented 1 year ago

You need to have gpsd installed on your computer when you enable the SOCKTAP_WITH_GPSD option. Ubuntu and Debian call the required package libgps-dev.

Krupass commented 1 year ago

I already used gpsd, but when I try to search libgps-dev with apt list --installed | grep gpsd i get gpsd-clients/focal-updates,focal-security,now 3.20-8ubuntu0.4 amd64 [installed] gpsd/focal-updates,focal-security,now 3.20-8ubuntu0.4 amd64 [installed]. Does it mean i still need the libgps-dev?

riebl commented 1 year ago

Yes, you need the header files of gpsd found in libgps-dev.

Krupass commented 1 year ago

ok, thanks

lo-hei commented 1 year ago

Sorry for asking but i get the same Error.

CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find GPS (missing: GPS_INCLUDE_DIR GPS_LIBRARY)

gpsd and libgps-dev is installed.

gpsd-clients/focal-updates,focal-security,now 3.20-8ubuntu0.4 amd64 [installed]
gpsd/focal-updates,focal-security,now 3.20-8ubuntu0.4 amd64 [installed]

libgps-dev/focal-updates,focal-security,now 3.20-8ubuntu0.4 amd64 [installed]

What was your solution to the problem? @Krupass It seems Line 1&2 in FindGPS.cmake are not working correctly.

Thanks

Krupass commented 1 year ago

Hi @lo-hei , I can not remember what solved it for me, because it was some time ago. Maybe try to restart system, or reinstall the library and gpsd. If you find out how to fix it please post it here. Good luck

lo-hei commented 1 year ago

Hm, sadly i could not find a solution. I am getting the Error

CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find GPS (missing: GPS_INCLUDE_DIR GPS_LIBRARY)
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  cmake/FindGPS.cmake:23 (find_package_handle_standard_args)
  tools/socktap/CMakeLists.txt:61 (find_package)

Do i have to copy the package (for example the gps.h file) into the vanetza-folder? I tried to debug with -DCMAKE_FIND_DEBUG_MOD=ON but i seems like it is not correctly searching for the file because no line is indicating some searching for something with "gpsd" or "libgps-dev".

riebl commented 1 year ago

Does this error also occur with a fresh build directory after installing the gpsd packages as well?

lo-hei commented 1 year ago

Thank you very much for your answer. Yes, unfortunately the error occurs even after multiple deletes and re-builds of the folder. Also a reinstallation of GPSD was tried. gps.h can be found in /usr/include

lo-hei commented 1 year ago

I noticed following problem:

if i add add find_package(GPS REQUIRED) to the top of the vanetza/CMakeLists.txt with a cmake_print_variables inside FindGPS.cmake, and then run

cmake .. \
        -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-Autotalks-Craton.cmake \
        -DCMAKE_FIND_ROOT_PATH=$HOME/vanetza-deps \
        -DCMAKE_INSTALL_RPATH=\$ORIGIN/../lib \
        -DCMAKE_INSTALL_PREFIX=$HOME/vanetza-dist \
        -DBUILD_SOCKTAP=ON \
        -DSOCKTAP_WITH_AUTOTALKS=ON \
        -DSOCKTAP_WITH_GPSD=ON

it will not find the GPS package (Variable-Prints are NOT_FOUND) But if i just execute

cmake .. \
        -DBUILD_SOCKTAP=ON \
        -DSOCKTAP_WITH_AUTOTALKS=ON \
        -DSOCKTAP_WITH_GPSD=ON

Then it will not compile completely (obviously), but it will find the GPS library (Paths in Prints are correct). For me it would be find to set the Path by my self. So i added in FindGPS.cmake

if (NOT GPS_INCLUDE_DIR)
    SET(GPS_INCLUDE_DIR /usr/include)
    message("Set GPS_INCLUDE_DIR manually to /usr/include")
endif()
if (NOT GPS_LIBRARY)
    SET(GPS_LIBRARY /usr/lib/x86_64-linux-gnu/libgps.so)
    message("Set GPS_LIBRARY manually to /usr/lib/x86_64-linux-gnu/libgps.so")
endif()

cmake is working, but then i will et an error in make (_/vanetza/tools/socktap/gps_positionprovider.hpp:10:10: fatal error: gps.h: No such file or directory)

Maybe this is helpful to get to the bottom of the error. I also try to debug further.

riebl commented 1 year ago

Ah, you are cross-compiling! In that case, gpsd files are not looked up in your host system's directories. The CMAKE_FIND_ROOT_PATH variable tells CMake to look for such dependency files only in $HOME/vanetza-deps. Thus, gps.h and the libgps library need to be located there. Possibly, the Autotalks SDK already ships a pre-compiled version of libgps for their platform.

lo-hei commented 1 year ago

Sorry for asking, but i am very new into it. Sadly Autotalks does not provide any precompiled libgpsd-dev package. How can i cross-compile it for vanetza?

I tried to follow this instruction (https://gpsd.io/building.html#_cross_building) and copied everything into the vanetza-deps folder (cmake is finding all needed files) but it is not working (/vanetza-deps/lib/libgps.so: file not recognized: file format not recognized)

For that my .scons-option-cache looked like this:

libgpsmm = False
libQgpsmm = False
python = False
target = 'arm-poky-linux-gnueabi'
lo-hei commented 1 year ago

Okay I finally figured it out after a lot of trying and researching.

If Vanetza should run with precompiled GPSD (for example on an EVK), you can follow the instructions (https://gpsd.io/building.html#_cross_building).

after that the compilation should work.