Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/157.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何实现JIT c++;通过LLVM使用具有虚拟函数的类的代码?_C++_Clang_Llvm_Jit - Fatal编程技术网

C++ 如何实现JIT c++;通过LLVM使用具有虚拟函数的类的代码?

C++ 如何实现JIT c++;通过LLVM使用具有虚拟函数的类的代码?,c++,clang,llvm,jit,C++,Clang,Llvm,Jit,我有点困惑。我试图用LLVM和CLAN:< /P>来引用这个原始C++代码。 class Test { int _v; public: Test() : _v(0) { } ~Test() { } void Set(int v) { _v = v; } int Get() { return _v; } }; extern "C" Test* CreateTest() { return new Tes

我有点困惑。我试图用LLVM和CLAN:< /P>来引用这个原始C++代码。
class Test {
    int _v;
public:
    Test() : _v(0) { }
    ~Test() { }
    void Set(int v) {
        _v = v;
    }
    int Get() {
        return _v;
    }
};

extern "C" Test* CreateTest() {
    return new Test;
}

extern "C" void DestroyTest(Test** o) {
        delete *o;
        *o = 0;
}
我得到llvm::Module是clang::CompilerInstance调用的结果。当我将该模块传递到llvm::ExecutionEngine时,我可以获得指向“CreateTest”和“DestroyTest”例程的正确指针,并且一切正常

但是,如果我在类规范中设置“Test::Set”和“Test::Get”为虚拟的,则任何llvm::ExecutionEngine::getFunctionAddress()都会在RuntimeDyldImpl::ResolveExternalSymbols()中失败

它报告一个致命错误,类似于“程序使用的外部函数???u 7type_info@@6B@无法解析”,并终止我的主机进程

如何解决链接问题

顺便问一下,是否有任何链接技巧可以从jit代码调用libc函数,如malloc、printf等