C++ API VS2019下同样的代码,DEBUG编译运行报错,Release编译运行通过

//代码如下

#include "include\DolphinDB.h"

#include "include\Util.h"

#include <iostream>

#include <string>


using namespace dolphindb;

using namespace std;


int main(int argc, char* argv[]) {


    string host = "192.168.2.114";

    int port = 8848;

    string username = "admin";

    string password = "123456";

    DBConnection conn;

    ConstantSP vector;

    int size=0;


    std::cout << "Connecting DolphinDB: [" << host << ":" << port << "]  Username:[" << username << "] Password:[" << password << "]" << endl;

    bool ret = conn.connect(host, port,username,password);

    if (!ret) {

        cout << "Failed to connect to the server" << endl;

        //getchar();

        //return 0;

        goto END_APP;

    }

    else

    {

        cout << "Had connected to DolphinDB server [" << host << ":" << port << "] Username=["<<username<<"]\n";

    }

    //ConstantSP vector = conn.run("`IBM`GOOG`YHOO");

    vector = conn.run("today();now()");

    size = vector->rows();

    for (int i = 0; i < size; ++i)

        cout << vector->getString(i) << endl;


END_APP: getchar();

    return 0;

}


//报错显示: 有未经处理的异常: Microsoft C++ 异常: std::bad_alloc,位于内存位置 0x000000B29C97EE30 处。

请问问题出在什么地方?
谢谢

请先 登录 后评论

1 个回答

Boye

现在用的库是release版本的。若project用debug,库也需要用debug版本编译。

请先 登录 后评论