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过程省略,具体运行结果如下

在这里插入图片描述

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