C++ 使用libssh2运行Embarcadero项目时出现异常

C++ 使用libssh2运行Embarcadero项目时出现异常,c++,exception,libssh2,C++,Exception,Libssh2,我面临以下问题: 在Embarcadero项目(exe或dll)中,当我调用libssh2_session_handshake()在两台主机之间建立和ssh通信时出现异常。 我在 > AccEdReRo RAD XE5 C++中构建了.exe(如果我构建DLL也会发生同样的情况)。 创建此.exe的项目静态链接了libssh2.lib库。 尝试运行exe时,它会动态加载libssh2.dll。 libssh2.lib和libssh2.dll是使用Visual Studio构建的。我用过各种版本的

我面临以下问题: 在Embarcadero项目(exe或dll)中,当我调用libssh2_session_handshake()在两台主机之间建立和ssh通信时出现异常。 我在<强> > AccEdReRo RAD XE5<强> C++中构建了.exe(如果我构建DLL也会发生同样的情况)。 创建此.exe的项目静态链接了libssh2.lib库。 尝试运行exe时,它会动态加载libssh2.dll。 libssh2.lib和libssh2.dll是使用Visual Studio构建的。我用过各种版本的。最后一个使用Visual Studio 2015从git hub构建了libssh2的最后一个代码

我的工作要求这些文件纳入Embarcadero项目

为了使libssh2.lib文件在Embarcadero中可用,我运行Embarcadero中的coff2omf.exe工具,该工具将.lib从Visual Studio转换为与Embarcadero兼容的文件

当Embarcadero项目中的代码调用libssh2_会话_握手时,它会不断引发异常: “地址00000000处的访问冲突。读取地址00000000”

下面的示例演示了如何在创建ssh连接后将文件发送到sftp服务器

谁能帮我修一下吗?你知道是什么引起的吗

谢谢你抽出时间

下面我给出了我的部分代码

rc = libssh2_init(0);
ShowMessage("rc = " + IntToStr(rc));
if(rc) {
    fprintf(stderr, "libssh2 initialization failed (%d)\n", rc);
    ShowMessage(AnsiString().sprintf("libssh2 initialization failed (%d)",rc));
    return 1;
}
sock = socket(AF_INET, SOCK_STREAM, 0);

//Connect to Remote Host
    //Prior that the ip of the remote host has been defined (sin)...
if(connect(sock, (struct sockaddr*)(&sin),
           sizeof(struct sockaddr_in)) != 0) {
    int wsaerr = WSAGetLastError();
    ShowMessage("Failed to connect " + IntToStr(wsaerr));
    //return -1;
}

try{
    rc = libssh2_session_handshake(session, sock);
    ShowMessage("libssh2_session_handshake rc: " + IntToStr(rc));
    if(rc) {
        ShowMessage("Failure establishing SSH session: " + IntToStr(rc));
        //return -1;
    }

}
catch(Exception &e){
    ShowMessage("exception raised " + e.Message());
}

一般来说,您不能将使用不同编译器生成的对象链接到同一个可执行文件中,并期望得到工作结果。C++不提供ABI保证,只有源级兼容性。那么,您是否使用与项目其余部分完全相同的编译器构建了ssh库代码?一般来说,您不能将使用不同编译器构建的对象链接到同一个可执行文件中,并期望工作结果。C++不提供ABI保证,只有源级兼容性。那么,您是否使用与项目其余部分完全相同的编译器构建了ssh库代码?