Preface
Yesterday I see WonderTrader of star
, actually has 400 +, and it is a bit contrary to the author's surprise, after all WonderTrader never had formal promotion. The author would like to express my sincere thanks to every friend WonderTrader
From the WonderTrader to now, for various reasons, the Linux
under 061b6a932da829 have not kept up. Plus author Linux
limited experience in the development of the next, so Linux
version retained under a lot of problems. The Linux
use under gcc
compiled, at the time the link, and does not check whether all symbolic links are successful, resulting in many problems can only be checked out at run time.
Just recently, a friend wanted to change wtpy
to cython
version wtcy
. It needs mingw
environment, and there are also some requirements for the underlying adaptation. A long time ago, some users put forward the request of Clion
compilation to the author, but at that time, the author did not advance because of the busy work.
Some time ago, I took this opportunity to sort out all the codes related to cross-platform compilation. So there is the MinGW Environment Compilation WonderTrader Strategy ".
The main content of this paper is describes the process using MinGW compiled WonderTrader source code under Windows .
MinGW-w64
Environmental preparation
The first thing to install is MinGW-w64
MinGW-w64
official website of 061b6a932da95f and click to download- Select
MinGW-w64-build
and open - Then jump to
Sourceforge
start downloading - The pop-up download dialog box selects the path where the installation file is stored
- After the download is complete, run the installer
- Setting items should be noted: thread model
Threads
should selectposix
, otherwise the compilation ofboost
will fail. Then click "Next" to start downloading - After the installation is complete, open the installation library, double-click to run
mingw-w64.bat
In the opened console, execute the following command. If the version number of
GCC
MinGW
environment is successful$ gcc -v
Three party library compilation
WonderTrader has tried to reduce dependencies, there are still some indispensable dependent libraries. The author has provided pre-compiled dependency libraries vs2017
, ubuntu18.04
, centos7
and centos8
in the shared network disk before. But MinGW
is a new compilation environment, so the dependent library still needs to be recompiled.
The author's consistent style is: third-party library can be statically linked, never dynamic link . The advantage of this is that the final release package does not require so many additional dynamic libraries, and the disadvantage is that the final compiled file is relatively large. The compilation methods described below are all output static libraries.
Before compiling, and to MSVC
compiler environment, the need to create a new environment variable MyDependsGcc , and set the value of dependent libraries save directory, such as E: \ mingw9deps. include
subdirectory can directly copy include
directory of the MSVC
dependent library. The .a
lib
subdirectory needs to be compiled and generated according to the steps described below.
Compile boost 1.72.0
boost library for C++
developers does not need me to say much, boost
is actually more convenient. WonderTrader depends on the version 1.72.0
.
- First run
bootstrap.bat
b2.exe
program will be automatically generated. Then execute the command line in the
boost
$ b2.exe --build-type=minimal --with-chrono --with-date_time --with-filesystem --with-regex --with-thread toolset=gcc architecture=x86 address-model=64 variant=release link=static threading=multi stage
- After having compiled to
stage/lib
where you can see the generated.a
files - Finally, remove the tail "-mgw81-mt-x64-1_72" of the
.a
E:\mingw9deps\lib
directory
nanomsg 1.1.5
nanomsg is the WonderTrader , encapsulated in the WtMsgQue
module, as the core message queue component that WonderTrader WonderTrader uses the version 1.1.5
. Readers can download it by themselves or download it from a shared cloud disk.
- After decompression, open the
CMakeLists.txt
file - According to the screenshot below, change NN_STATIC_LIB to ON , and all other items to OFF
Use the
cmake
command to generatemakefile
$ cmake -G "MinGW Makefiles"
- Finally execute the
mingw32-make
command to generatenanomsg
- After completion of generation, will
libnanomsg.a
copied toE:\mingw9deps\lib
directory
curl 7.70
curl is a library that is very frequently used. WonderTrader itself does not rely on curl
, but the trading API of Yisheng, the author originally had a second authorization mechanism when docking foreign futures, which needed to be transferred through the mailbox. The second authorization code, so curl
is used. curl
API, you don’t actually need to compile 061b6a932dae2b. WonderTrader uses the version 7.70
.
curl
is relatively simple, you only need to enter thelib
, execute the following command, and wait for the compilation to end.$ mingw32-make -f Makefile.m32
- After having compiled the
lib
directorylibcurl.a
copied toE:\mingw9deps\lib
directory
dlfcn-win32 1.3.0
dlfcn is built-in under Linux
, which is the dl
module. But the dl
module is not built-in in the MinGW
environment, so you need to compile the implementation of Windows
dlfcn
Write
config.mak
fileBUILD_STATIC=yes CC=gcc AR=ar RANLIB=ranlib
- Execute the
mingw32-make
command to compile - The resulting
libdl.a
copied toE:\mingw9deps\lib
directory,dlfcn.h
copied toE:\mingw9deps\include
directory
Pre-compiled library download
After introducing the compilation method of each dependent library, the author also provides a pre-compiled package, which you can download by yourself according to your needs.
Shared network disk link:
https://pan.baidu.com/s/1Bdxh_PgjqHMzuGjl9ernhg
Extraction code: d6bh
Clion+MinGW configuration
Clion is 061b6a932db02a that has become popular in recent years and is IDE
by JetBrains
. In recent years, many people have started to use Clion
develop the C++
program. The author will briefly introduce how Clion
configures the MinGW
compilation environment to compile WonderTrader .Clion
, the author will not repeat it here. It is worth mentioning that Clion
is a commercial software for a fee, it provides free accounts for open source project participants. The author also applies for a free account in this way.
- Open WonderTrader source directory
src
,Clion
will automatically parseCMakeLists.txt
as a solution File
menu, selectSetting
to configure, and select the configurationToolchains
in the pop-up window.Clion
will automatically scan theMinGW
environment. IfMinGW
is not the default, move it to the first one and set it as the default so that the compilation environment ofMinGW
- Then configure the compilation mode in the
CMake
tab, the default isDebug
- After completing the above settings, select
Build Project
command in theBuild
menu to start generating the entire project
VSCode+MinGW configuration
Similarly, we can also in VSCode
use MinGW
compiled WonderTrader .
- First of all, we need
VSCode
, as shown in the figure below.CMake Tools
is a core plug-in, and the calling methods for subsequent compilation and configuration are provided by this plug-in. - After the plug-in is installed, an operation button will appear in the status bar. First, you need to select the compilation component, as shown in the figure below:
- After selecting the compilation components, configure the compilation mode to be
Debug
orRelease
- Finally, click the "
Build
" button to start building the entire project
Some tips
The previous MinGW
WonderTrader under the 061b6a932db2ae environment does not seem difficult, and it is actually the same. WonderTrader It turns out that many codes have some problems in cross-platform compatibility, so the author seemed very embarrassed when tossing, but at the same time, the author also learned a lot.
For example, originally
Windows
was developed only withMSVC
, but theGCC
compiler was only used onLinux
, so many conditional compilation instructions in the code such as:#IF _WIN32 //... #ELSE _UNIX //... #ENDIF
In the original WonderTrader, it can be equivalent to:
#IF _MSC_VER //... #ELSE _GNUC //... #ENDIF
After reorganizing this time, the conditional compilation related to the compiler is completely separated from the conditional compilation related to the platform.
GCC
compiled object file compared toMSVC
compiled object file to be much larger. The author estimates thatMinGW
is a simulatedLinux
environment after all, and cannot directly reference theWindows
, so many dependencies must all be compiled into the target file.MinGW
compilation speed ofMSVC
is much slower than that of 061b6a932db389, and the time spent is basically more than twiceMSVC
GCC
inWindows
when the link under, or to check whether dependency links all successful, so can you find some problems related dependencies during compilation.- In short, I still do not suggest that you
MinGW
environment compiled WonderTrader , after allMSVC
with them is not bad.
Concluding remarks
WonderTrader has been open source for about 20 months. The author is very happy that more and more people pay attention to WonderTrader , use WonderTrader , and more and more people participate in the 161b6a932db40 The author also met many new friends WonderTrader
Recently, many friends asked me commercialization plan of 161b6a932db429 WonderTrader , but the author did not think too much. WonderTrader is an open source project, and it is a quantitative platform that has already carried out large-scale real trading, and the core part is very stable. WonderTrader will improve the future direction of application scenarios, and it is difficult to reconstruct the core part. So I think that everyone should not worry about WonderTrader will erode the functions of the open source part if it is commercialized, because WonderTrader is no longer reserved.
Finally, another wave of ads
161b6a932db458 github
: https://github.com/wondertrader/wondertrader
WonderTrader official website address: https://wondertrader.github.io
161b6a932db489 github
: https://github.com/wondertrader/wtpy
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。