lts api linux ok

This commit is contained in:
tirole 2016-05-15 01:58:46 -07:00
parent 4da668f9e1
commit 2c05e0a8d4
12 changed files with 165 additions and 4 deletions

View File

@ -9,7 +9,9 @@ if [ ! -f $BUILDDIR ]; then
fi fi
pushd $BUILDDIR pushd $BUILDDIR
cmake .. cmake ..
make VERBOSE=1 -j 2 make VERBOSE=1 -j 1
ln -fs `pwd`/lib/libvnctpmd.so ../vnctpmd/test/vnctpmd.so ln -fs `pwd`/lib/vnctpmd.so ../vnctpmd/test/vnctpmd.so
ln -fs `pwd`/lib/libvnctptd.so ../vnctptd/test/vnctptd.so ln -fs `pwd`/lib/vnctptd.so ../vnctptd/test/vnctptd.so
cp ../vnctpmd/test/vnctpmd.* ../../vn.trader/ctpGateway/
cp ../vnctptd/test/vnctptd.* ../../vn.trader/ctpGateway/
popd popd

113
vn.lts/CMakeLists.txt Normal file
View File

@ -0,0 +1,113 @@
cmake_minimum_required(VERSION 2.8)
project(vn_lts_api)
set(CMAKE_BUILD_TYPE "Release")
if (CMAKE_COMPILER_IS_GNUC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++11")
endif ()
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
option(USE_64BITS "comiple 64bits" ON)
if (USE_64BITS)
add_definitions(-DUSE_64BITS)
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
endif()
if (WIN32)
set(LTSAPI_PATH ltsapi)
elseif (UNIX)
message("Under unix: " ${CMAKE_SIZEOF_VOID_P})
#if (CMAKE_SIZEOF_VOID_P MATCHES "8")
set(LTSAPI_PATH ltsapi)
#endif()
endif()
include_directories(${LTSAPI_PATH})
message(${LTSAPI_PATH})
set(LTSAPI_LIBRARY )
find_library(LTSAPI_MD_LIBRARY
NAMES securitymduserapi
PATHS ${LTSAPI_PATH})
message(${LTSAPI_MD_LIBRARY})
find_library(LTSAPI_TD_LIBRARY
NAMES securitytraderapi
PATHS ${LTSAPI_PATH})
find_library(LTSAPI_QRY_LIBRARY
NAMES securityqueryapi
PATHS ${LTSAPI_PATH})
set (vnltsmd )
set (vnltstd )
set (vnltsqry )
option(BUILD_LTS_MD "build lts md" ON)
if (BUILD_LTS_MD)
add_definitions(-DBUILD_LTS_MD)
set(LTS_MD_PATH vnltsmd/vnltsmd)
include_directories(LTS_MD_PATH)
set(VN_LTS_MD_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/vnltsmd/vnltsmd/vnltsmd.cpp)
add_library(vnltsmd SHARED ${VN_LTS_MD_SOURCE})
endif()
option(BUILD_LTS_TD "build lts td" ON)
if (BUILD_LTS_TD)
add_definitions(-DBUILD_LTS_TD)
set(LTS_TD_PATH vnltstd/vnltstd)
include_directories(LTS_TD_PATH)
set(VN_LTS_TD_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/vnltstd/vnltstd/vnltstd.cpp)
add_library(vnltstd SHARED ${VN_LTS_TD_SOURCE})
endif()
option(BUILD_LTS_QRY "build lts qry" ON)
if (BUILD_LTS_QRY)
add_definitions(-DBUILD_LTS_QRY)
set(LTS_QRY_PATH vnltsqry/vnltsqry)
include_directories(LTS_QRY_PATH)
set(VN_LTS_QRY_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/vnltsqry/vnltsqry/vnltsqry.cpp)
add_library(vnltsqry SHARED ${VN_LTS_QRY_SOURCE})
endif()
set(PYTHON_LIBRARY )
if (WIN32)
set(PYTHON_INCLUDE_PATH C:/Python27/include)
find_library(PYTHON_LIBRARY
NAMES python27
PATHS C:/Python27/libs)
include_directories(${PYTHON_INCLUDE_PATH})
else()
set(PYTHON_INCLUDE_PATH /usr/include/python2.7/)
find_library(PYTHON_LIBRARY
NAMES python2.7
PATHS /usr/lib/x86_64-linux-gnu)
include_directories(${PYTHON_INCLUDE_PATH})
endif()
# boostanaconda
if (WIN32)
set(Boost_USE_STATIC_LIBS ON) #boost
endif()
set(Boost_USE_MULTITHREADED ON)
find_package(Boost 1.55.0 COMPONENTS python thread date_time system chrono REQUIRED) # boost否者message(${Boost_LIBRARIES})
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
endif()
# solib
set_target_properties(vnltsmd PROPERTIES PREFIX "")
target_link_libraries(vnltsmd ${Boost_LIBRARIES} ${PYTHON_LIBRARY} ${LTSAPI_MD_LIBRARY})
set(MD_DLL "${LIBRARY_OUTPUT_PATH}/Release/vnltsmd.dll")
if (EXISTS ${MD_DLL})
file(RENAME ${MD_DLL} ${LIBRARY_OUTPUT_PATH}/Release/vnltsmd.pyd)
endif()
set_target_properties(vnltstd PROPERTIES PREFIX "")
target_link_libraries(vnltstd ${Boost_LIBRARIES} ${PYTHON_LIBRARY} ${LTSAPI_TD_LIBRARY})
set(TD_DLL ${LIBRARY_OUTPUT_PATH}/Release/vnltstd.dll)
if (EXISTS ${TD_DLL})
file(RENAME ${TD_DLL} ${LIBRARY_OUTPUT_PATH}/Release/vnltstd.pyd)
endif()
set_target_properties(vnltsqry PROPERTIES PREFIX "")
target_link_libraries(vnltsqry ${Boost_LIBRARIES} ${PYTHON_LIBRARY} ${LTSAPI_QRY_LIBRARY})
set(QRY_DLL ${LIBRARY_OUTPUT_PATH}/Release/vnltsqry.dll)
if (EXISTS ${QRY_DLL})
file(RENAME ${QRY_DLL} ${LIBRARY_OUTPUT_PATH}/Release/vnltsqry.pyd)
endif()

19
vn.lts/build.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
# Written by Suzhengchun on 20160213
set -e
BUILDDIR=build
rm -rf $BUILDDIR
if [ ! -f $BUILDDIR ]; then
mkdir -p $BUILDDIR
fi
pushd $BUILDDIR
cmake ..
make VERBOSE=1 -j 1
ln -fs `pwd`/lib/vnltsmd.so ../vnltsmd/test/vnltsmd.so
ln -fs `pwd`/lib/vnltstd.so ../vnltstd/test/vnltstd.so
ln -fs `pwd`/lib/vnltsqry.so ../vnltsqry/test/vnltsqry.so
cp ../vnltsmd/test/vnltsmd.* ../../vn.trader/ltsGateway/
cp ../vnltstd/test/vnltstd.* ../../vn.trader/ltsGateway/
cp ../vnltsqry/test/vnltsqry.* ../../vn.trader/ltsGateway/
popd

View File

@ -0,0 +1 @@
securitymduserapi.so

View File

@ -0,0 +1 @@
securityqueryapi.so

View File

@ -0,0 +1 @@
securitytraderapi.so

View File

@ -1,7 +1,9 @@
// MdApi.cpp : 定义 DLL 应用程序的导出函数。 // MdApi.cpp : 定义 DLL 应用程序的导出函数。
// //
#ifdef WIN32
#include "stdafx.h" #include "stdafx.h"
#endif
#include "vnltsmd.h" #include "vnltsmd.h"
@ -48,7 +50,11 @@ void getChar(dict d, string key, char *value)
const char *buffer = s.c_str(); const char *buffer = s.c_str();
//对字符串指针赋值必须使用strcpy_s, vs2013使用strcpy编译通不过 //对字符串指针赋值必须使用strcpy_s, vs2013使用strcpy编译通不过
//+1应该是因为C++字符串的结尾符号不是特别确定不加这个1会出错 //+1应该是因为C++字符串的结尾符号不是特别确定不加这个1会出错
#ifdef WIN32
strcpy_s(value, strlen(buffer) + 1, buffer); strcpy_s(value, strlen(buffer) + 1, buffer);
#else
strncpy(value, buffer, strlen(buffer) + 1);
#endif
} }
} }
}; };
@ -663,4 +669,4 @@ BOOST_PYTHON_MODULE(vnltsmd)
.def("onRspUnSubMarketData", pure_virtual(&MdApiWrap::onRspUnSubMarketData)) .def("onRspUnSubMarketData", pure_virtual(&MdApiWrap::onRspUnSubMarketData))
.def("onRtnDepthMarketData", pure_virtual(&MdApiWrap::onRtnDepthMarketData)) .def("onRtnDepthMarketData", pure_virtual(&MdApiWrap::onRtnDepthMarketData))
; ;
}; };

View File

@ -1,7 +1,9 @@
//说明部分 //说明部分
//系统 //系统
#ifdef WIN32
#include "stdafx.h" #include "stdafx.h"
#endif
#include <string> #include <string>
#include <queue> #include <queue>

View File

@ -1,7 +1,9 @@
// MdApi.cpp : 定义 DLL 应用程序的导出函数。 // MdApi.cpp : 定义 DLL 应用程序的导出函数。
// //
#ifdef WIN32
#include "stdafx.h" #include "stdafx.h"
#endif
#include "vnltsqry.h" #include "vnltsqry.h"
@ -48,7 +50,11 @@ void getChar(dict d, string key, char *value)
const char *buffer = s.c_str(); const char *buffer = s.c_str();
//对字符串指针赋值必须使用strcpy_s, vs2013使用strcpy编译通不过 //对字符串指针赋值必须使用strcpy_s, vs2013使用strcpy编译通不过
//+1应该是因为C++字符串的结尾符号不是特别确定不加这个1会出错 //+1应该是因为C++字符串的结尾符号不是特别确定不加这个1会出错
#ifdef WIN32
strcpy_s(value, strlen(buffer) + 1, buffer); strcpy_s(value, strlen(buffer) + 1, buffer);
#else
strncpy(value, buffer, strlen(buffer) + 1);
#endif
} }
} }
} }

View File

@ -1,7 +1,9 @@
//说明部分 //说明部分
//系统 //系统
#ifdef WIN32
#include "stdafx.h" #include "stdafx.h"
#endif
#include <string> #include <string>
#include <queue> #include <queue>

View File

@ -1,7 +1,9 @@
// MdApi.cpp : 定义 DLL 应用程序的导出函数。 // MdApi.cpp : 定义 DLL 应用程序的导出函数。
// //
#ifdef WIN32
#include "stdafx.h" #include "stdafx.h"
#endif
#include "vnltstd.h" #include "vnltstd.h"
@ -48,7 +50,11 @@ void getChar(dict d, string key, char *value)
const char *buffer = s.c_str(); const char *buffer = s.c_str();
//对字符串指针赋值必须使用strcpy_s, vs2013使用strcpy编译通不过 //对字符串指针赋值必须使用strcpy_s, vs2013使用strcpy编译通不过
//+1应该是因为C++字符串的结尾符号不是特别确定不加这个1会出错 //+1应该是因为C++字符串的结尾符号不是特别确定不加这个1会出错
#ifdef WIN32
strcpy_s(value, strlen(buffer) + 1, buffer); strcpy_s(value, strlen(buffer) + 1, buffer);
#else
strncpy(value, buffer, strlen(buffer) + 1);
#endif
} }
} }
} }

View File

@ -1,7 +1,9 @@
//说明部分 //说明部分
//系统 //系统
#ifdef WIN32
#include "stdafx.h" #include "stdafx.h"
#endif
#include <string> #include <string>
#include <queue> #include <queue>