I'm trying to resolve an unresolved external (link2019 error).There were already some posts on this issue and i try them, but I still could not figure it out.
The error is caused by my CreateFtdcMdApi function ( right?) but my understanding is that this is "resolved".
// testTraderApi.cpp : 定义控制台应用程序的入口点。
//
#include "MdSpi.h"
#include <iostream>
// UserApi对象
CThostFtdcMdApi* pUserApi = NULL;
// 配置参数
char FRONT_ADDR[] = "tcp://asp-sim2-md1.financial-trading-platform.com:26213"; // 前置地址
TThostFtdcBrokerIDType BROKER_ID = "***"; // 经纪公司代码
TThostFtdcInvestorIDType INVESTOR_ID = "0***"; // 投资者代码
TThostFtdcPasswordType PASSWORD = "*****"; // 用户密码
char *ppInstrumentID[] = { "***", "***" }; // 行情订阅列表
int iInstrumentID = 2; // 行情订阅数量
// 请求编号
int iRequestID = 0;
void main(void)
{
// 初始化UserApi
char file = 'F';
pUserApi = CThostFtdcMdApi::CreateFtdcMdApi(); // 创建UserApi
CThostFtdcMdSpi* pUserSpi = new CMdSpi();
pUserApi->RegisterSpi(pUserSpi); // 注册事件类
pUserApi->RegisterFront(FRONT_ADDR); // connect
pUserApi->Init();
pUserApi->Join();
// pUserApi->Release();
}
I truncated the code a bit, because it is verbose.
class MD_API_EXPORT CThostFtdcMdApi
{
public:
///创建MdApi
///@param pszFlowPath 存贮订阅信息文件的目录,默认为当前目录
///@return 创建出的UserApi
///modify for udp marketdata
static CThostFtdcMdApi *CreateFtdcMdApi(const char *pszFlowPath = "", const bool bIsUsingUdp=false, const bool bIsMulticast=false);
///获取API的版本信息
///@retrun 获取到的版本号
static const char *GetApiVersion();
}
Error:
1>------ Build started: Project: challenges, Configuration: Debug Win32 ------
1>challenges.obj : error LNK2019: unresolved external symbol "public: static class CThostFtdcMdApi * __cdecl CThostFtdcMdApi::CreateFtdcMdApi(char const *,bool,bool)" (?CreateFtdcMdApi@CThostFtdcMdApi@@SAPAV1@PBD_N1@Z) referenced in function _main
1>d:\documents\visual studio 2013\Projects\challenges\Debug\challenges.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========