MattiaMontanari / openGJK

Fast and reliable implementation of the Gilbert-Johnson-Keerthi (GJK) algorithm for C, C#, Go, Matlab and Python
https://www.mattiamontanari.com/opengjk/
GNU General Public License v3.0
135 stars 37 forks source link

Compilation issues on CentOS 7 #5

Closed rquey closed 2 years ago

rquey commented 4 years ago

On a CentOS 7 system, several compilation issues arise, as detailed below. I am providing fixes here rather than in a commit as I am not sure they are the best.

The top-level CMakeLists.txt requires CMake version 3.5 or higher. My CMake is 2.8. Changing the version line to cmake_minimum_required(VERSION 2.8) does the trick, so the version requirement could be set to 2.8 for greater system compatibility.

Compilation generates several errors such as openGJK/lib/src/openGJK.c:74:3: error: ‘for’ loop initial declarations are only allowed in C99 mode.. This can be fixed by adding set(CMAKE_C_FLAGS "-std=gnu99") to openGJK/lib/CMakeLists.txt.

Compilation finally generates the following error:

Linking C executable demo
../lib/libopenGJKlib.a(openGJK.c.o): In function `S2D':
openGJK.c:(.text+0x127): undefined reference to `pow'
openGJK.c:(.text+0x18fa): undefined reference to `sqrt'
../lib/libopenGJKlib.a(openGJK.c.o): In function `gjk':
openGJK.c:(.text+0x4191): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status
make[2]: *** [example1_c/demo] Error 1
make[1]: *** [example1_c/CMakeFiles/demo.dir/all] Error 2
make: *** [all] Error 2

This can be fixed by linking against the math library in openGJK/lib/example1_c/CMakeLists.txt, but changing the linking directive to target_link_libraries(demo openGJKlib "-lm").

MattiaMontanari commented 4 years ago

Thank you for the raising the issue and checking all this. I'm thinking of includind Cmocka for testing, and that requires CMake 3.5. So, I may not be able to downgrade that, but all the rest I'll get it fixed. Thank you!

MattiaMontanari commented 2 years ago

Finally closed in #24