I have a ROS node that contains code generated by Matlab coder. This code has been generated to make use of the NEON instruction set on ARM Cortex A CPUs. I want to compile this code on a Hardkernel Odroid XU4 (which runs on a Samsung Exynos5422 Cortex™-A15 2Ghz and Cortex™-A7 Octa core CPU). However I am not successful in compiling/linking my code.
I have added the the following compiler flags in the packages CMakeLists.txt:
-mfloat-abi=softfp -mfpu=neon -O2.
Yet, during compilation I get the following error message:
/usr/lib/gcc/arm-linux-gnueabihf/4.8/include/arm_neon.h:32:2: error:
#error You must enable NEON instructions (e.g. -mfloat-abi=softfp -mfpu=neon) to use arm_neon.h
This is followed by many more errors about unknown types:
/home/odroid/catkin_ws/src/vio_ros/src/codegen/mw_neon.c:12:2: error: unknown type name ‘float32x4_t’
/home/odroid/catkin_ws/src/vio_ros/src/codegen/mw_neon.c:36:2: error: unknown type name ‘int32x4_t’
...
And many more. All of these types seem to be defined in arm_neon.h
What do I need to do to be able to compile my code?
Thanks for your help
I have figured out what the problem was. Since some of the code being compiled in this C++ project was C code, I also have to set the compiler flags for C. Including the following in the CMakeLists.txt makes the code compile:
set(NEON_FLAGS "-DENABLE_NEON -mfloat-abi=hard -mfpu=neon-vfpv4 -mcpu=cortex-a15 -Ofast")
set(CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS} -Wno-format-security ${NEON_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NEON_FLAGS}")