Skip to content

Commit dd57247

Browse files
authored
Merge pull request #12 from renkun-ken/release/linux
Release/linux
2 parents 4bade86 + db80fce commit dd57247

14 files changed

Lines changed: 107 additions & 12 deletions

File tree

.gitignore

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ publish/
127127
# Publish Web Output
128128
*.[Pp]ublish.xml
129129
*.azurePubxml
130-
# TODO: Comment the next line if you want to checkin your web deploy settings
130+
# TODO: Comment the next line if you want to checkin your web deploy settings
131131
# but database connection strings (with potential passwords) will be unencrypted
132132
*.pubxml
133133
*.publishproj
@@ -230,3 +230,13 @@ $RECYCLE.BIN/
230230

231231
# Windows shortcuts
232232
*.lnk
233+
234+
# Linux objects
235+
*.so
236+
*.o
237+
238+
# Misc files
239+
*.userprefs
240+
241+
# VSCode files
242+
.vscode

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
all:
2+
$(MAKE) -C common/Queue all
3+
$(MAKE) -C apis/CTP all
4+
$(MAKE) -C tests/CPP all
5+
6+
clean:
7+
$(MAKE) -C common/Queue clean
8+
$(MAKE) -C apis/CTP clean
9+
$(MAKE) -C tests/CPP clean
10+

Makefile.global

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CXX=clang++
2+
IFLAGS=-I../../ -I../../include/ -I../ -I./
3+
CFLAGS=$(IFLAGS)-std=c++11 -O3 -fPIC -pthread -Bsymbol
4+
5+
all: $(ALL)
6+
7+
%.o: %.cpp
8+
$(CXX) $(CFLAGS) -c $^ -o $@
9+
10+
clean:
11+
rm -rf *.so *.o $(DEPS)

README.linux

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
1. modify conf.sh according to your setting
2+
2. source ~/.conf.sh
3+
3. make clean && make
4+
4. run CPP_TEST

apis/CTP/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ALL=libQuantBox_CTP_Quote.so libQuantBox_CTP_Trade.so
2+
include ../../Makefile.global
3+
4+
DEPS=../../include/toolkit.o \
5+
../../include/ApiProcess.o
6+
7+
LFLAGS=-Wl,-rpath,\$$ORIGIN -ldl -L../../include/CTP/linux64 -L../../common/Queue -lQueue
8+
9+
libQuantBox_CTP_Quote.so: Quote/main.cpp Quote/MdUserApi.cpp TypeConvert.cpp $(DEPS)
10+
$(CXX) --shared $(IFLAGS) $(LFLAGS) $(CFLAGS) -lthostmduserapi -I../CTP_Quote -o $@ $^
11+
libQuantBox_CTP_Trade.so: Trade/main.cpp Trade/TraderApi.cpp TypeConvert.cpp $(DEPS)
12+
$(CXX) --shared $(IFLAGS) $(LFLAGS) $(CFLAGS) -lthosttraderapi -I../CTP_Trade -o $@ $^
13+

apis/CTP/Trade/TraderApi.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
#include <cstring>
1919
#include <assert.h>
2020
#include <cfloat>
21+
#if defined(_MSC_VER) || defined(_WIN32)
2122
#include <direct.h>
23+
#endif
2224

2325
#ifdef ENABLE_LICENSE
2426
#include "../../common/License/License.h"
@@ -1499,7 +1501,7 @@ int CTraderApi::_ReqQrySettlementInfo(char type, void* pApi1, void* pApi2, doubl
14991501
CThostFtdcQrySettlementInfoField body = { 0 };
15001502
strncpy(body.BrokerID, m_RspUserLogin.BrokerID, sizeof(TThostFtdcBrokerIDType));
15011503
strncpy(body.InvestorID, m_RspUserLogin.UserID, sizeof(TThostFtdcInvestorIDType));
1502-
sprintf_s(body.TradingDay, "%d", pQuery->DateStart);
1504+
sprintf(body.TradingDay, "%d", pQuery->DateStart);
15031505

15041506
return m_pApi->ReqQrySettlementInfo(&body, ++m_lRequestID);
15051507
}

apis/CTP/TypeConvert.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "stdafx.h"
22
#include "TypeConvert.h"
3-
3+
#include <cstring>
44
#include <stdio.h>
55

66

@@ -352,4 +352,4 @@ void CThostFtdcOrderField_2_OrderField_0(OrderIDType OrderID,CThostFtdcOrderFiel
352352
pOut->ExecType = CThostFtdcOrderField_2_ExecType(pIn);
353353
strcpy(pOut->OrderID, pIn->OrderSysID);
354354
strncpy(pOut->Text, pIn->StatusMsg, sizeof(Char256Type));
355-
}
355+
}

common/Queue/Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
include ../../Makefile.global
2+
3+
LFLAGS=-Wl,-rpath,\$$ORIGIN -ldl
4+
ALL=libQueue.so
5+
6+
all: $(ALL)
7+
8+
libQueue.so: main.o MsgQueue.o RemoteQueue.o $(DEPS)
9+
$(CXX) --shared $(IFLAGS) $(CFLAGS) -I../CTP_Quote -o $@ $^
10+
11+

conf.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/Workspaces/XAPI2/common/Queue:~/Workspaces/XAPI2/apis/CTP:~/Workspaces/XAPI2/include/CTP/linux64
2+
export MALLOC_CHECK_=0

include/toolkit.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ void GetOnFrontDisconnectedMsg(int ErrorId, char* ErrorMsg)
470470
}
471471
}
472472

473+
#if defined _WIN32 || WIN32 || _WINDOWS
473474
void GetDllPathByFunctionName(const char* szFunctionName, char* szPath)
474475
{
475476
HMODULE hModule = nullptr;
@@ -508,3 +509,4 @@ void GetNewPathInSameDirectory(const char* szPath, const char* szFname, const ch
508509
_splitpath(szPath, drive, dir, fname, ext);
509510
_makepath(szFileName, drive, dir, szFname, szExt);
510511
}
512+
#endif

0 commit comments

Comments
 (0)