smtplan編譯

win10環境 smtplan編譯

耗時一個星期,經理各種版本,各種編譯錯誤,各種工具鏈,各種環境,經過重重困難終於編譯成功,記錄一下。

準備環境

1 切記至關重要,如果工具鏈太新,代碼太老,都會造成編譯不通過.
2 開發環境: win10 工具鏈mingw(x86_64-7.3.0-release-posix-seh-rt_v5-rev0.7z)主要使用其中 > mingw32-make.exe 管理工具,沒有使用其中提供的交叉工具鏈。使用其工具鏈編譯會出現錯誤。
3 cywgin64 採用 setup-x86_64.exe 安裝的。gcc 7.4 版本 g++ 7.4 版本
4 smtplan 選擇 master 版本,依賴項mppp-v0.9版本 ,prianha選擇master版本它中指定了mppp版本爲0.9 ,z3選擇master版本
boost 1.58.0 版本,boost超過1.60.0版本經編譯測試不通過.
cygwin64 需要安裝bison ,flex2.6.4 ,gmp 浮點運算庫,mpfr浮點運算庫,python3 庫 下載,主要不要下載mingw相關的庫

查看環境

cygwin64環境 ,經過好幾個版本的測試,最終選擇此版本.
在這裏插入圖片描述

在這裏插入圖片描述

1 配置編譯mppp庫

mppp+ 需到github上下載 需選擇v0.9版本,因爲在piranha中指定了此版本號.
https://github.com/bluescarni/mppp

在這裏插入圖片描述
在這裏插入圖片描述

mppp-v0.9_build_1目錄下執行 mingw32-make
在這裏插入圖片描述

2 配置編譯boost1.58.0 庫

打開 cygwin64終端
在這裏插入圖片描述
選擇 boost_1_58_0.tar.bz2 版本,zip與tar後綴版本有細微區別
export CC=gcc
export CXX=g++

./bootstrap.sh
./b2
./b2 install  

默認安裝到
在這裏插入圖片描述

3 配置編譯prianha庫

bluescarni/piranha@7e42042 使用此特定版本
git clone https://github.com/bluescarni/piranha

在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述

4 配置編譯z3庫

注意點python環境必須是cygwin64中安裝的自帶的python環境纔可以.
從終端進入源碼目錄執行下面操作

For a 64 bit build (from Cygwin64), configure Z3's sources with

```bash
幫助文檔給出提示
CXX=x86_64-w64-mingw32-g++ CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar python scripts/mk_make.py
按自己實際情況進行修改,執行完畢源碼目錄下會自動生成build目錄.
CXX=g++ CC=gcc AR=gcc-ar python3 scripts/mk_make.py

cd build
mingw32-make
mingw32-make install

在這裏插入圖片描述

將生成的libz.dll庫拷貝到 bin目錄下,否則後續運行時找不到庫

在這裏插入圖片描述

4 編譯smtplan程序

修改CMakeLists.txt 文件,由於找不到boost庫,不知道爲什麼,故對cmake文件進行修改

cmake_minimum_required(VERSION 2.8.3)
project(SMTPlan)

## Version number
set (SMTPlan_VERSION_MAJOR 0)
set (SMTPlan_VERSION_MINOR 9)

##-----------##
## Configure ##
##-----------##

set(CMAKE_CXX_FLAGS "-std=c++0x")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules" "${CMAKE_SOURCE_DIR}/cmake_modules/yacma")
set (PROJECT_SOURCE_DIR src)

## configure a header file for CMake settings
configure_file (
  "${PROJECT_SOURCE_DIR}/SMTPlanConfig.h.in"
  "${PROJECT_BINARY_DIR}/SMTPlanConfig.h"
)
 
## add the binary tree to the include files so that we will find SMTPlanConfig.h
include_directories("${PROJECT_BINARY_DIR}")


##################################################################################
# add by xhome516
set(BOOST_ROOT "D:/1softInstall/cygwin64/usr/local")
include_directories(${BOOST_ROOT})

include_directories("D:/1softInstall/cygwin64/usr/local/include")
link_directories("D:/1softInstall/cygwin64/usr/local/lib")

include_directories("D:/1softInstall/cygwin64/usr/include")
link_directories("D:/1softInstall/cygwin64/lib")

include_directories("D:/1softInstall/cygwin64/usr/include")
link_directories("D:/1softInstall/cygwin64/usr/lib")

#mppp
include_directories("C:/Program Files (x86)/mp++/include")
link_directories("C:/Program Files (x86)/mp++/lib")
#piranha
include_directories("C:/Program Files (x86)/piranha/include")
link_directories("C:/Program Files (x86)/piranha/lib")

# python 使用cygwin64中python庫,個人認爲不要使用windows安裝的python庫.
set(PYTHON_INCLUDE_DIR "D:/1softInstall/cygwin64/usr/include/python3.6m")
set(PYTHON_LIBRARY   "D:/1softInstall/cygwin64/bin/python3.6m")

set(GMP_INCLUDE_DIR "D:/1softInstall/cygwin64/usr/include")
set(GMP_LIBRARIES "D:/1softInstall/cygwin64/lib/libgmp.dll.a")

# mpfr
set(MPFR_INCLUDE_DIR "D:/1softInstall/cygwin64/include")
set(MPFR_LIBRARIES "D:/1softInstall/cygwin64/lib/libmpfr.dll.a")

##########################################################################################

##-------##
## Build ##
##-------##

## required
find_package(FLEX REQUIRED)
find_package(PythonLibs REQUIRED)
FIND_PACKAGE(GMP REQUIRED)
MESSAGE(STATUS "GMP library found.")
MESSAGE(STATUS "GMP include dir is: ${GMP_INCLUDE_DIR}")
MESSAGE(STATUS "GMP library is: ${GMP_LIBRARIES}")
FIND_PACKAGE(MPFR REQUIRED)
MESSAGE(STATUS "MPFR library found.")
MESSAGE(STATUS "MPFR include dir is: ${MPFR_INCLUDE_DIR}")
MESSAGE(STATUS "MPFR library is: ${MPFR_LIBRARIES}")

## by xhome 註釋掉,由於boost庫找不到,按照此方法進行
#find_package(Boost REQUIRED thread)

## include directories
include_directories (include)
include_directories (src/VALfiles)
include_directories (src/VALfiles/src)
include_directories (src/VALfiles/include)
include_directories(${PYTHON_INCLUDE_DIRS})
include_directories(${SYMENGINE_INCLUDE_DIRS})
include_directories(${GMP_INCLUDE_DIR})
include_directories(${MPFR_INCLUDE_DIR})

## val sources
set(VAL_SOURCES
	src/VALfiles/src/DebugWriteController.cpp
	src/VALfiles/src/FastEnvironment.cpp
	src/VALfiles/src/FuncAnalysis.cpp
	src/VALfiles/src/SimpleEval.cpp
	src/VALfiles/src/TIM.cpp
	src/VALfiles/src/TimSupport.cpp
	src/VALfiles/src/TypedAnalyser.cpp
	src/VALfiles/src/instantiation.cpp
	src/VALfiles/src/pddl+.cpp
	src/VALfiles/src/ptree.cpp
	src/VALfiles/src/typecheck.cpp)

## SMTPLAN sources
set(SMTPLAN_SOURCES
	src/SMTPlan.cpp
	src/Algebraist.cpp
	src/EncoderHappening.cpp
	src/EncoderFluent.cpp)

## Declare cpp executables

add_executable(SMTPlan ${SMTPLAN_SOURCES} ${VAL_SOURCES})
#target_link_libraries(SMTPlan ${Boost_LIBRARIES} z3 ${Boost_LIBRARIES} ${GMP_LIBRARIES} ${MPFR_LIBRARIES})

# 被修改 by xhome
target_link_libraries(SMTPlan ${Boost_LIBRARIES} z3 -lboost_thread -lpthread ${GMP_LIBRARIES} ${MPFR_LIBRARIES})
## Uncomment to solve undefined reference to symbol 'pthread'
## target_link_libraries(SMTPlan ${Boost_LIBRARIES} pthread)

#add_executable(test_python src/test_python.cpp)
#target_link_libraries(test_python ${Boost_LIBRARIES} ${GMP_LIBRARIES} ${MPFR_LIBRARIES})

# add the install targets
install (TARGETS SMTPlan DESTINATION bin)
install (FILES "${PROJECT_BINARY_DIR}/SMTPlanConfig.h" DESTINATION include)

cmake-gui 配置生成make過程省略,具體運行結果如下

在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章