Hi
I am using Acados on windows with MATLAB R2020b and going to cross compile Acados to library, which will be used for the build of my Simulink model on DS1401 by ConfigurationDesk. I adapted the Toolchain-dSpaceDS1401.cmake according to the path on my PC and it didn’t work with the error:
Linking C static library cmTC_152f6.lib
CMAKE_AR-NOTFOUND qc cmTC_152f6.lib CMakeFiles/cmTC_152f6.dir/isa_test.c.obj
Error running link command: Das System kann die angegebene Datei nicht finden
, which I think means that it cannot find the ar.exe for cmake. Then I add the path manually in the Toolchain-dSpaceDS1401.cmake as below:
SET(CMAKE_AR "C:/Program Files/dSPACE RCPHIL 2020-B/Compiler/Linux440_550/target/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ar.exe" CACHE FILEPATH "Archiver")
Then the cross compiling worked. However, the libraries generated are all .lib files, which I thought should be .a libraries for embedded system. When I replace the headers and libraries with the results of cross-compiling, set the custom code and built my Simulink model by ConfigurationDesk, I got the error saying
c:/program files/dspace rcphil 2020-b/compiler/linux440_550/target/arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.5.0/../../../../arm-linux-gnueabihf/bin/ld.exe: \acados\lib\acados.lib(ocp_nlp_common.c.obj): Relocations in generic ELF (EM: 20)
acados.lib: error adding symbols: File in wrong format
I don’t know which step is wrong in my cross-compiling process, which led to the generation of libs with wrong format. I would appreciate it if someone can give me a hint on how to handle this error.
This is the cmake file I am using now:
SET(CMAKE_SYSTEM_NAME "dSpaceDS1401")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
SET(CMAKE_SYSTEM_PROCESSOR "ppc")
SET(CMAKE_AR "C:/Program Files/dSPACE RCPHIL 2020-B/Compiler/Linux440_550/target/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ar.exe" CACHE FILEPATH "Archiver")
file(TO_CMAKE_PATH "C:/ProgramData/dSPACE/A8EFD7E5-F405-47E4-9A8A-DE544031D1F0" DSPACE_TOOLS)
set(DSPACE_RTLIB "C:/Program Files/dSPACE RCPHIL 2020-B/DS1401/RTLib")
set(DSPACE_PPCTOOLS "${DSPACE_TOOLS}/Compiler/PPCTools")
# C Compiler
find_program(CMAKE_C_COMPILER NAMES ${DSPACE_PPCTOOLS}/bin/mccppc.exe)
# C++ Compiler -- not used
find_program(CMAKE_CXX_COMPILER NAMES ${DSPACE_PPCTOOLS}/bin/mccppc.exe)
# Assembler
find_program(CMAKE_ASM_COMPILER NAMES ${DSPACE_PPCTOOLS}/bin/asmppc.exe)
set(CMAKE_RANLIB ":")
find_program(CMAKE_MAKE_PROGRAM NAMES "C:/Program Files/dSPACE RCPHIL 2020-B/Exe/DSMAKE.EXE")
SET(CMAKE_FIND_ROOT_PATH ${DSPACE_PPCTOOLS})
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
add_definitions(-D__MABX2__ -D__DSPACE__)
# Compiler flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -H -J{DSPACE_RTLIB}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -H -J{DSPACE_RTLIB}")
set(CMAKE_C_FLAGS "-Ot -Oi -Or -Ox -D_INLINE" CACHE STRING "" FORCE)
# set(CMAKE_C_FLAGS "-D_INLINE" CACHE STRING "" FORCE)
# acados flags
set(BLASFEO_TARGET "GENERIC" CACHE STRING "BLASFEO Target architecture")
set(HPIPM_TARGET "GENERIC" CACHE STRING "HPIPM Target architecture")
set(BUILD_SHARED_LIBS OFF CACHE STRING "Build shared libraries")
set(BLASFEO_EXAMPLES OFF CACHE BOOL "Examples disabled")
set(EXT_DEP OFF CACHE BOOL "Compile external dependencies in BLASFEO")
set(ACADOS_INSTALL_DIR "install" CACHE PATH "Installation path to ACADOS_INSTALL_DIR")
# import from platform folder
set(CMAKE_IMPORT_LIBRARY_PREFIX "")
set(CMAKE_SHARED_LIBRARY_PREFIX "")
set(CMAKE_SHARED_MODULE_PREFIX "")
set(CMAKE_STATIC_LIBRARY_PREFIX "")
set(CMAKE_EXECUTABLE_SUFFIX ".exe")
set(CMAKE_IMPORT_LIBRARY_SUFFIX ".lib")
set(CMAKE_SHARED_LIBRARY_SUFFIX ".lib")
set(CMAKE_SHARED_MODULE_SUFFIX ".lib")
set(CMAKE_STATIC_LIBRARY_SUFFIX ".lib")
set(CMAKE_C_FLAGS "\"-J${DSPACE_RTLIB}\"")
set(CMAKE_INCLUDE_FLAG_C "-J")
set(CMAKE_INCLUDE_FLAG_CXX "-J")
# add_definitions(-D__MABX2__)
remove_definitions(-DLINUX)
remove_definitions(-DOS_WINDOWS)
remove_definitions(-D__LINUX__)
Thanks in advance!