windows编译bitshares
- 前提:安装好vs2013-update5、cmake、git工具、doxygen工具(非必须),环境变量PATH有对应的EXE
目录结构
1
2
3
4
5
6
7
8
9
10
11
12
13- D:\_workdir\source
- bitshares
- bitshares-core
- dependencies
- boost_1_57_0
- source
- openssl-1.0.1u
- zlib-1.2.11
- curl-7.59.0
- bin
- include
- lib
- ssl编译openssl
- 下载安装activePerl,注意环境变量PATH
- 下载安装nasm,注意环境变量PATH
- 下载openssl源码,版本最好选择1.0.1,切勿选择大于1.0.2的版本
- 打开vs2013 x64 本机工具命令提示,输入
1
2
3
4
5cd D:\_workdir\source\dependencies\source\openssl-1.0.1u
perl Configure VC-WIN64A --prefix=D:\_workdir\source\dependencies
ms\do_win64a
nmake -f ms\nt.mak
nmake -f ms\nt.mak install
编译zlib
- 下载zlib源码,选择的是1.2.11版本
- 打开“contrib\vstudio\vc12\zlibvc.sln”,选择release和x64进行编译
- 编译成功后把“contrib\vstudio\vc12\x64\ZlibStatRelease\zlibstat.lib”复制到“dependencies\lib\zlib.lib”,把“D:_workdir\source\dependencies\source\zlib-1.2.11”的头文件“zlib.h、zconf.h”复制到“dependencies\include”目录
编译curl
- 下载curl源码,选择的是7.59.0版本
打开vs2013 x64 本机工具命令提示,输入
1
2cd D:\_workdir\source\dependencies\source\curl-7.59.0\winbuild
nmake /f Makefile.vc mode=static VC=12 WITH_DEVEL=D:\_workdir\source\dependencies WITH_SSL=static WITH_ZLIB=static MACHINE=x64编译成功后把“dependencies\source\curl-7.59.0\builds\libcurl-vc12-x64-release-static-ssl-static-zlib-static-ipv6-sspi”的所有目录copy到“dependencies”下,libcurl.lib更名为curl.lib
修改curl.h头文件,在第109行加入
1
#define CURL_STATICLIB
编译boost
- 下载1.57版本
- 打开vs2013 x64 本机工具命令提示,输入
1
2
3cd D:\_workdir\source\dependencies\boost_1_57_0
.\bootstrap.bat
b2 stage --address-model=64 --toolset=msvc-12.0 --threading=muti --link=static
编译bitshares
下载源码,切换到最新版本。打开vs2013 x64 本机工具命令提示,输入
1
2
3
4
5
6cd D:\_workdir\source\bitshares
git clone https://github.com/bitshares/bitshares-core
cd bitshares-core
git submodule update --init --recursive
rem git checkout 2.0.180425
rem 注释掉这句,这个版本缺少一个文件重启系统,确保以上的PATH都生效
设置环境脚本setenv_x64.bat,放到bitshares-core目录
1
2
3
4
5
6
7
8@echo off
set GRA_ROOT=D:\_workdir\source\bitshares\bitshares-core
set OPENSSL_ROOT=D:\_workdir\source\dependencies
set OPENSSL_ROOT_DIR=%OPENSSL_ROOT%
set OPENSSL_INCLUDE_DIR=%OPENSSL_ROOT%\include
set BOOST_ROOT=D:\_workdir\source\dependencies\boost_1_57_0
set PATH=%BOOST_ROOT%\stage\lib;%PATH%为了兼容windows版本,进行相应修改,见以下内容
打开vs2013 x64 本机工具命令提示,输入
1
2
3cd D:\_workdir\source\bitshares\bitshares-core
setenv_x64.bat
cmake-gui配置cmake工程,
- 设置source目录为:D:_workdir\source\bitshares\bitshares-core
- 设置输出目录为:D:_workdir\source\bitshares\bitshares-core\x64
- 点击Configure,在弹出框中,
- 第一个下拉框 Specify the generator for this project 选 Visual Studio 12 2013 Win64
- 第二个输入框 Optional toolset to use (argument to -T) 留空
- 下面的单选框,选 Use default native compilers
- 点 Finish ,然后等一会, Generate 按钮会亮起
- 点 Generate ,然后等一会, Open Project 按钮会亮起
- 点 Open Project ,会打开 Visual Studio
- 开始编译,有可能遇到bigobj问题,再进行相应修改
为兼容windows版本,需对bitshares源码进行以下相关修改
bitshares源码修改
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5e91e80b..e11f4c20 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,10 @@
project( BitShares )
cmake_minimum_required( VERSION 2.8.12 )
+if(POLICY CMP0054)
+ cmake_policy(SET CMP0054 NEW)
+endif()
+
set( BLOCKCHAIN_NAME "BitShares" )
set( CLI_CLIENT_EXECUTABLE_NAME graphene_client )
diff --git a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp b/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp
index 2d381308..0d18e8b8 100644
--- a/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp
+++ b/libraries/chain/include/graphene/chain/protocol/fee_schedule.hpp
@@ -54,7 +54,7 @@ namespace graphene { namespace chain {
FC_ASSERT( itr != parameters.end() );
return itr->get<account_create_operation::fee_parameters_type>();
}
- typename account_create_operation::fee_parameters_type& get(flat_set<fee_parameters>& parameters)const
+ account_create_operation::fee_parameters_type& get(flat_set<fee_parameters>& parameters)const
{
auto itr = parameters.find( account_create_operation::fee_parameters_type() );
FC_ASSERT( itr != parameters.end() );
diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp
index b78bb835..a8a11023 100644
--- a/tests/cli/main.cpp
+++ b/tests/cli/main.cpp
@@ -38,8 +38,12 @@
#include <fc/rpc/websocket_api.hpp>
#include <fc/rpc/cli.hpp>
+#if defined _WINDOWS_ || defined WIN32
+#include "winsock2.h"
+#else
#include <sys/socket.h>
#include <netinet/ip.h>
+#endif
#include <sys/types.h>
#include <boost/filesystem/path.hpp>
@@ -109,9 +113,14 @@ int get_available_port()
sin.sin_family = AF_INET;
sin.sin_port = 0;
sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
- if (bind(socket_fd, (struct sockaddr*)&sin, sizeof(struct sockaddr_in)) == -1)
+ if (::bind(socket_fd, (struct sockaddr*)&sin, sizeof(struct sockaddr_in)) == -1)
return -1;
+
+#if defined _WINDOWS_ || defined WIN32
+ int len = sizeof(sin);
+#else
socklen_t len = sizeof(sin);
+#endif
if (getsockname(socket_fd, (struct sockaddr *)&sin, &len) == -1)
return -1;
return sin.sin_port;fc 源码修改
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36diff --git a/CMakeLists.txt b/CMakeLists.txt
index c5ed733..4c957fe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,6 +4,10 @@
PROJECT( fc )
CMAKE_MINIMUM_REQUIRED( VERSION 2.8.12 )
+if(POLICY CMP0054)
+ cmake_policy(SET CMP0054 NEW)
+endif()
+
MESSAGE(STATUS "Configuring project fc located in: ${CMAKE_CURRENT_SOURCE_DIR}")
SET( CMAKE_AUTOMOC OFF )
diff --git a/src/asio.cpp b/src/asio.cpp
index 1313ed7..f22da17 100644
--- a/src/asio.cpp
+++ b/src/asio.cpp
@@ -106,11 +106,11 @@ namespace fc {
{
fc::thread::current().set_name("asio");
- BOOST_SCOPE_EXIT(void)
- {
- fc::thread::cleanup();
- }
- BOOST_SCOPE_EXIT_END
+ //BOOST_SCOPE_EXIT(void)
+ //{
+ // fc::thread::cleanup();
+ //}
+ //BOOST_SCOPE_EXIT_END
while (!io->stopped())
{以下cpp文件添加“/bigobj”编译属性,可能不同机器不一样,最终按编译提示来处理
- 项目app_test
- bitshares-core\tests\app\main.cpp
- 项目chain_bench
- bitshares-core\tests\common\database_fixture.cpp
- 项目chain_test
- bitshares-core\tests\common\database_fixture.cpp
- 项目cli_test
- bitshares-core\tests\cli\main.cpp
- 项目cli_wallet
- bitshares-core\programs\cli_wallet\main.cpp
- 项目performance_test
- bitshares-core\tests\common\database_fixture.cpp
- 项目witness_node
- bitshares-core\programs\witness_node\main.cpp
- 项目app_test