diff --git a/vn.ctp/build.sh b/vn.ctp/build.sh index df869a70..83858574 100755 --- a/vn.ctp/build.sh +++ b/vn.ctp/build.sh @@ -9,7 +9,9 @@ if [ ! -f $BUILDDIR ]; then fi pushd $BUILDDIR cmake .. -make VERBOSE=1 -j 2 -ln -fs `pwd`/lib/libvnctpmd.so ../vnctpmd/test/vnctpmd.so -ln -fs `pwd`/lib/libvnctptd.so ../vnctptd/test/vnctptd.so +make VERBOSE=1 -j 1 +ln -fs `pwd`/lib/vnctpmd.so ../vnctpmd/test/vnctpmd.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 diff --git a/vn.lts/CMakeLists.txt b/vn.lts/CMakeLists.txt new file mode 100644 index 00000000..3466cb65 --- /dev/null +++ b/vn.lts/CMakeLists.txt @@ -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() + +# 链接boost库,anaconda +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() + +# 去掉生成的so文件名中前缀的lib +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() diff --git a/vn.lts/build.sh b/vn.lts/build.sh new file mode 100755 index 00000000..a0332792 --- /dev/null +++ b/vn.lts/build.sh @@ -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 diff --git a/vn.lts/ltsapi/libsecuritymduserapi.so b/vn.lts/ltsapi/libsecuritymduserapi.so new file mode 120000 index 00000000..9029341a --- /dev/null +++ b/vn.lts/ltsapi/libsecuritymduserapi.so @@ -0,0 +1 @@ +securitymduserapi.so \ No newline at end of file diff --git a/vn.lts/ltsapi/libsecurityqueryapi.so b/vn.lts/ltsapi/libsecurityqueryapi.so new file mode 120000 index 00000000..07ebcc23 --- /dev/null +++ b/vn.lts/ltsapi/libsecurityqueryapi.so @@ -0,0 +1 @@ +securityqueryapi.so \ No newline at end of file diff --git a/vn.lts/ltsapi/libsecuritytraderapi.so b/vn.lts/ltsapi/libsecuritytraderapi.so new file mode 120000 index 00000000..5f5cd4a8 --- /dev/null +++ b/vn.lts/ltsapi/libsecuritytraderapi.so @@ -0,0 +1 @@ +securitytraderapi.so \ No newline at end of file diff --git a/vn.lts/vnltsmd/vnltsmd/vnltsmd.cpp b/vn.lts/vnltsmd/vnltsmd/vnltsmd.cpp index af3d7deb..30d4b4b0 100644 --- a/vn.lts/vnltsmd/vnltsmd/vnltsmd.cpp +++ b/vn.lts/vnltsmd/vnltsmd/vnltsmd.cpp @@ -1,7 +1,9 @@ // MdApi.cpp : DLL Ӧóĵ // +#ifdef WIN32 #include "stdafx.h" +#endif #include "vnltsmd.h" @@ -48,7 +50,11 @@ void getChar(dict d, string key, char *value) const char *buffer = s.c_str(); //ַָ븳ֵʹstrcpy_s, vs2013ʹstrcpyͨ //+1ӦΪC++ַĽβţرȷ1 + #ifdef WIN32 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("onRtnDepthMarketData", pure_virtual(&MdApiWrap::onRtnDepthMarketData)) ; -}; \ No newline at end of file +}; diff --git a/vn.lts/vnltsmd/vnltsmd/vnltsmd.h b/vn.lts/vnltsmd/vnltsmd/vnltsmd.h index b7ebc928..65c12417 100644 --- a/vn.lts/vnltsmd/vnltsmd/vnltsmd.h +++ b/vn.lts/vnltsmd/vnltsmd/vnltsmd.h @@ -1,7 +1,9 @@ //˵ //ϵͳ +#ifdef WIN32 #include "stdafx.h" +#endif #include #include diff --git a/vn.lts/vnltsqry/vnltsqry/vnltsqry.cpp b/vn.lts/vnltsqry/vnltsqry/vnltsqry.cpp index 04b2e336..36709a05 100644 --- a/vn.lts/vnltsqry/vnltsqry/vnltsqry.cpp +++ b/vn.lts/vnltsqry/vnltsqry/vnltsqry.cpp @@ -1,7 +1,9 @@ // MdApi.cpp : DLL Ӧóĵ // +#ifdef WIN32 #include "stdafx.h" +#endif #include "vnltsqry.h" @@ -48,7 +50,11 @@ void getChar(dict d, string key, char *value) const char *buffer = s.c_str(); //ַָ븳ֵʹstrcpy_s, vs2013ʹstrcpyͨ //+1ӦΪC++ַĽβţرȷ1 + #ifdef WIN32 strcpy_s(value, strlen(buffer) + 1, buffer); + #else + strncpy(value, buffer, strlen(buffer) + 1); + #endif } } } diff --git a/vn.lts/vnltsqry/vnltsqry/vnltsqry.h b/vn.lts/vnltsqry/vnltsqry/vnltsqry.h index 7ca2fc1c..4dacebce 100644 --- a/vn.lts/vnltsqry/vnltsqry/vnltsqry.h +++ b/vn.lts/vnltsqry/vnltsqry/vnltsqry.h @@ -1,7 +1,9 @@ //˵ //ϵͳ +#ifdef WIN32 #include "stdafx.h" +#endif #include #include diff --git a/vn.lts/vnltstd/vnltstd/vnltstd.cpp b/vn.lts/vnltstd/vnltstd/vnltstd.cpp index ba301ea7..3f03ef7d 100644 --- a/vn.lts/vnltstd/vnltstd/vnltstd.cpp +++ b/vn.lts/vnltstd/vnltstd/vnltstd.cpp @@ -1,7 +1,9 @@ // MdApi.cpp : DLL Ӧóĵ // +#ifdef WIN32 #include "stdafx.h" +#endif #include "vnltstd.h" @@ -48,7 +50,11 @@ void getChar(dict d, string key, char *value) const char *buffer = s.c_str(); //ַָ븳ֵʹstrcpy_s, vs2013ʹstrcpyͨ //+1ӦΪC++ַĽβţرȷ1 + #ifdef WIN32 strcpy_s(value, strlen(buffer) + 1, buffer); + #else + strncpy(value, buffer, strlen(buffer) + 1); + #endif } } } diff --git a/vn.lts/vnltstd/vnltstd/vnltstd.h b/vn.lts/vnltstd/vnltstd/vnltstd.h index 4f1be5d1..eec20b26 100644 --- a/vn.lts/vnltstd/vnltstd/vnltstd.h +++ b/vn.lts/vnltstd/vnltstd/vnltstd.h @@ -1,7 +1,9 @@ //˵ //ϵͳ +#ifdef WIN32 #include "stdafx.h" +#endif #include #include