C++ GetProcAddress可以';找不到函数

C++ GetProcAddress可以';找不到函数,c++,dll,C++,Dll,我尝试使用LoadLibrary和GetProcAddress加载库,以使用该库中的函数。然而,dll加载良好,但我没有得到函数 dll.h #ifndef TEST_DLL_H #define TEST_DLL_H void __declspec(dllexport) __stdcall tests(); #endif // TEST_DLL_H dll.cpp #include <iostream> #include "test_dll.h" void __declspe

我尝试使用
LoadLibrary
GetProcAddress
加载库,以使用该库中的函数。然而,dll加载良好,但我没有得到函数

dll.h

#ifndef TEST_DLL_H
#define TEST_DLL_H

void __declspec(dllexport) __stdcall tests();

#endif // TEST_DLL_H
dll.cpp

#include <iostream>
#include "test_dll.h"

void __declspec(dllexport) __stdcall tests() {
    std::cout << "tests" << std::endl;
}
typedef void(*f_funci)();

int main() {
    HMODULE hMod = LoadLibrary(L"plugins/test_dll.dll");
    if (!hMod)
        throw(std::runtime_error("failed to load dll"));

    f_funci f = (f_funci)GetProcAddress(hMod, "tests");
    if (!f) {
        std::cout << GetLastError() << "\n"; // code is 127 "The specified procedure could not be found."
        throw(std::runtime_error("could not locate function"));
    }

    f();
}
现在如果我尝试

f_funci f = (f_funci)GetProcAddress(hMod, "?tests@@YGXXZ");
它起作用了

所以我的问题是,为什么函数解析错误?

编辑: 我正在使用visual studio 2013 express


字符集未设置

除了“复制”帖子中给出的选项外,还有另一个选项。此选项涉及为dll创建.def文件

从 :

如果要导出C++文件中的函数,则必须将 .def文件中的修饰名称或定义导出的函数 使用外部“C”进行标准C链接


哈哈,我在谷歌上搜索了大约10分钟,但不是为了我自己的标题。我真丢脸。。。这正是正在发生的事情:D thx
f_funci f = (f_funci)GetProcAddress(hMod, "?tests@@YGXXZ");