0% found this document useful (0 votes)
111 views

Cross Compile Cool Prop

This document provides steps to cross compile the CoolProp library for ARM systems like STM32. It involves cloning the CoolProp git repository, installing prerequisites like Python and CMake, configuring CMake to use the ARM toolchain, disabling dynamic libraries and shared pointers not supported on ARM, adding ARM compiler options, and modifying CoolProp source code files to support ARM compilation.

Uploaded by

Laksono Budi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views

Cross Compile Cool Prop

This document provides steps to cross compile the CoolProp library for ARM systems like STM32. It involves cloning the CoolProp git repository, installing prerequisites like Python and CMake, configuring CMake to use the ARM toolchain, disabling dynamic libraries and shared pointers not supported on ARM, adding ARM compiler options, and modifying CoolProp source code files to support ARM compilation.

Uploaded by

Laksono Budi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Cross Compile Cool Prop

Reference:

http://www.coolprop.org/

https://dev.to/younup/cmake-on-stm32-the-beginning-3766

1) git clone https://github.com/CoolProp/CoolProp --recursive


2) git submodule update
3) Install Python minimum versi 2.7
4) Download Cmake installer
5) Download MINGW Installation Manager
6) Install semua yang berkaitan dengan GCC

7) Toolchain samain dengan yang di STM32CubeIDE


8) Tambahkan path info lokasi toolchain arm-none-eabi-gcc & g++

9) Di source code CoolProp “CMakeLists.txt” tambahin di bagian awal

cmake_minimum_required(VERSION 2.8.11)

#LAKSONO
#include(CheckIncludeFileCXX)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR ARM)

if(MINGW OR CYGWIN OR WIN32)


set(UTIL_SEARCH_CMD where)
elseif(UNIX OR APPLE)
set(UTIL_SEARCH_CMD which)
endif()

set(TOOLCHAIN_PREFIX arm-none-eabi-)

execute_process(
COMMAND ${UTIL_SEARCH_CMD} ${TOOLCHAIN_PREFIX}gcc
OUTPUT_VARIABLE BINUTILS_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

get_filename_component(ARM_TOOLCHAIN_DIR ${BINUTILS_PATH} DIRECTORY)


set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)

set(CMAKE_OBJCOPY ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}objcopy CACHE


INTERNAL "objcopy tool")
set(CMAKE_SIZE_UTIL ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}size CACHE INTERNAL
"size tool")

set(CMAKE_FIND_ROOT_PATH ${BINUTILS_PATH})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

10) Konfigurasikan “CMakeLists.txt” untuk tidak menggunakan dynamic shared lib pada CoolProp,
karena compiler tidak support.
#LAKSONO
#if(CMAKE_DL_LIBS)
if(0)
find_package (${CMAKE_DL_LIBS} REQUIRED)
endif()

11) Matikan fungsi shared pointer, ada kaitannya dengan fungsi ini dengan dynamic shared lib

#######################################
# SHARED POINTER #
#-------------------------------------#
# In this section we define the #
# flags needed to use shared_ptr #
# reliably #
#######################################

#LAKSONO
if(0)
include("${CMAKE_CURRENT_SOURCE_DIR}/dev/cmake/Modules/FindSharedPtr.cmake")
FIND_SHARED_PTR()
if(NOT SHARED_PTR_FOUND)
message(FATAL_ERROR "Must be able to find shared_ptr")
else()
if (SHARED_PTR_TR1_MEMORY_HEADER)
add_definitions("-DSHARED_PTR_TR1_MEMORY_HEADER")
endif()
if (SHARED_PTR_TR1_NAMESPACE)
add_definitions("-DSHARED_PTR_TR1_NAMESPACE")
endif()
endif()
endif()

12) Jalankan perintah

cmake . -G "MinGW Makefiles" -DCOOLPROP_STATIC_LIBRARY=ON -DCMAKE_DL_LIBS==OFF


-DCMAKE_BUILD_TYPE=Release

13) WARNING!!! Jika mau config ulang gunakan command ini


rm CMakeCache.txt
rm -rf CMakeFiles/

14) Matikan fungsi opsi compiler untuk x86 pada “CMakeLists.txt”, tambahkan opsi arm
CXX_FLAGS = -O3 -DNDEBUG -mfloat-abi=hard -mcpu=cortex-m7
if ( NOT MSVC )
#LAKSONO
#set_target_properties (COOLPROP_EES PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-
m32")
elseif ( MSVC )
Matikan fungsi opsi compiler untuk x86, di file ini

..\CoolProp\dev\buildbot\master\master.cfg

if checkID(buildID, teID="010", strict=False):


cmake_args.append('-DFORCE_BITNESS_32=ON')
#LAKSONO
#bitflag = "-m32"

15) Tambahkan define arm pada file src/CPfilepaths.cpp baris 71


#elif defined(__ANDROID__) || defined(__powerpc__) || defined(__arm__)

16) Ganti baris code pada file , jika tidak maka akan error.
..\CoolProp\externals\rapidjson\include\rapidjson\internal\regex.h

//LAKSONO
//stateSet_ = static_cast<unsigned*>(allocator_->Malloc(GetStateSetSize()));
stateSet_ = static_cast<uint32_t*>(allocator_->Malloc(GetStateSetSize()));

17) Tambahkan opsi untuk arm


#ifdef __ANDROID__
#undef _A
#undef _B
#undef _C
#undef _D
#endif

#ifdef __arm__
#undef _A
#undef _B
#undef _C
#undef _D
#endif

18) Hilangkan REFPROP di CmakeLists.txt


# These backends will be compiled in
set(COOLPROP_ENABLED_BACKENDS Cubics IF97 Helmholtz REFPROP Incompressible Tabular
PCSAFT)
Kita definisikan STM32 seperti __RPI_LINUX__.
Tambahkan opsi untuk arm pada file berikut.

..\CoolProp\externals\REFPROP-headers\REFPROP_lib.h

// Get the platform identifiers, some overlap with "PlatformDetermination.h" from CoolProp's
main repo
// See also http://stackoverflow.com/questions/5919996/how-to-detect-reliably-mac-os-x-ios-
linux-windows-in-c-preprocessor
#if defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) || defined(__WIN64__)
# define __RPISWINDOWS__
#elif defined(__APPLE__)
# define __RPISAPPLE__
#LAKSONO
#elif defined(__linux) || defined(__unix) || defined(__posix) || defined(__arm__)
# define __RPISLINUX__

19) Sepertinya kita tidak membutuhkan fungsi ini jadi kita nonaktifkan saja karena akan muncul
banyak error pada compiler STM32.
..\CoolProp\include\miniz.h

// If MINIZ_NO_TIME is specified then the ZIP archive functions will not be able to get the
current time, or
// get/set file times, and the C run-time funcs that get/set times won't be called.
// The current downside is the times written to your archives will be from 1979.
//LAKSONO
#define MINIZ_NO_TIME

..\CoolProp\src\CPfilepaths.cpp

#LAKSONO
#elif defined(__ANDROID__) || defined(__powerpc__) || defined(__arm__)
// Android doesn't have ftw.h, also doesn't accept not having this file
unsigned long long CalculateDirSize(const std::string &path){
return 0;
}
#else
20) Bikin Project pake C++

Compiling in windows
g++ test.cpp -L../CoolProp -I../CoolProp/include -I../CoolProp/externals/fmtlib
-lCoolProp

coba matiin dl
undefined reference to `CoolProp::force_unload_REFPROP()'
REFPROPMixtureBackend::version();

You might also like