Cross Compile Cool Prop
Cross Compile Cool Prop
Reference:
http://www.coolprop.org/
https://dev.to/younup/cmake-on-stm32-the-beginning-3766
cmake_minimum_required(VERSION 2.8.11)
#LAKSONO
#include(CheckIncludeFileCXX)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR ARM)
set(TOOLCHAIN_PREFIX arm-none-eabi-)
execute_process(
COMMAND ${UTIL_SEARCH_CMD} ${TOOLCHAIN_PREFIX}gcc
OUTPUT_VARIABLE BINUTILS_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)
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()
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
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()));
#ifdef __arm__
#undef _A
#undef _B
#undef _C
#undef _D
#endif
..\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();