Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何调用vs生成的dll,新手求救! #297

Closed
alibabazzz999 opened this issue Mar 15, 2024 · 1 comment
Closed

如何调用vs生成的dll,新手求救! #297

alibabazzz999 opened this issue Mar 15, 2024 · 1 comment

Comments

@alibabazzz999
Copy link

alibabazzz999 commented Mar 15, 2024

编译项目后,在文件夹:“C:\Users\Administrator\Desktop\3Dtiles\3dtiles\vs\x64\Release”下生成了4个文件:“3dtile.dll, 3dtile.lib, 3dtile.exp, 3dtile.pdb ”。
截图1

我写了控制台应用代码去调用dll:

#include <iostream>
#include <windows.h>

int main()
{
    std::cout << "Hello World!\n";
    HINSTANCE hDll; // DLL 句柄
    hDll = LoadLibrary(L"3dtile.dll"); // 动态获取 dll 文件的路径
    if (hDll != nullptr)
    {
        std::cout << "DLL loaded successfully!" << std::endl;
        FreeLibrary(hDll);
    }
    else
    {
        // 加载 DLL 失败,打印错误信息
        DWORD dwError = GetLastError();
        std::cerr << "Failed to load DLL: " << dwError << std::endl;
    }
    return 0;
}

输出:Failed to load DLL: 126
为何不能调用dll呢。 求解,困扰我两天了。
可是项目中,dll真的存在呀。
截图2

@fanvanzh
Copy link
Owner

可能没找到 dll 依赖的其他运行库, 最好引用 lib 进行编译,这样比较简单

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants