glewInit and building dll
glewInit and building dll
我正在开发爱好opengl3引擎,我决定对它进行一个新的.dll构建。它使用 GLEW 从 GPU 获取 opengl3 函数。大约 5 个月前我已经成功构建了它,但现在我已经改变了很多,它不想工作。
所以.dll构建完美(windows7,mingw(。 我做了一个简单的程序,它在第一次调用由mylib.dll的代码运行的glCreateProgram
时崩溃。
在伪代码中:
#include "mylib.hpp"
int main(){
std::cout << (void*)glCreateProgram << "n";
// displays 0 as glCreateProgram haven't been loaded yet
myspace::Window* = new SDL2BasedWindow(...);
//this constructor is from my .dll and calls glewInit() which returns GLEW_OK
std::cout << (void*)glCreateProgram << "n";
//this displays proper address
int testGLEW= glCreateProgram();
std::cout << "glCreateProgram from main: " << testGLEW<< "n";
//this displays 1 which means valid call to glCreateProgram
window->runApplication(new Application(...));
//Application is user-defined class, it further creates myspace::ShaderProgram
//which is imported from my .dll (part of my engine) which then calls
//glCreateProgram in it's initialisation
//(it is first call to any function which should be initialized by GLEW if we count only code imported from mylib.dll)
}
//in ShaderProgram constructor:
std::cout << "trying to call glCreateProgram, address: ";
std::cout << (void*)glCreateProgram << "n"; //this displays 0 (!)
int id = glCreateProgram(); //this ends execution with SIGSEGV
printf("created program: %dn", id); //so this one is never called
所以我的问题是,为什么 GLEW 只能在不是从我的.dll导入的代码中工作,我该如何解决它?
顺便说一句,我已经检查了它包含glCreateProgram
和其他 glew 依赖函数nm mylib.dll
蚁,我也在使用此.dll的.dll和程序中使用#define GLEW_STATIC
感谢您的帮助!
#define GLEW_STATIC
用于构建静态库或可执行文件。
要构建.dll
请改用#define GLEW_BUILD
。
相关文章:
- 挂起和取消挂起一个文件DLL
- std::threads可以从Windows DLL中的全局变量创建/销毁吗?
- 导入库可以跨dll版本工作吗
- 从C++dll访问C#中的一行主要参数
- 链接到自行创建的dll失败
- 为什么使用 P/Invoke 调用 dll 时,某些计算机中的 LoadLibrary 失败?
- 在调用FreeLibrary后,释放动态链接到具有相同版本的CRT堆的DLL的内存
- 如何指定我希望我的LIB链接到的DLL文件?-Visual Studio 2019
- 如何将图像传输到c++(dll)中的缓冲区,然后在c#的缓冲区中读/写
- C++:将外部库链接到dll库
- 在 Windows 上,是否可以让 dll 在不使用 PATH 环境变量的情况下在另一个文件夹中查找依赖项?
- 不同的Visual Studio版本中缺少.dll
- 从DLL中删除类的实例
- 如何包装第三方DLL在R中使用
- 使用c#访问c++dll中带有char*参数的函数时发生AccessViolationException
- 系统.将数组移交给c#中动态加载的c++DLL时发生AccessViolationException
- 为什么导入Mixed native/CLR lib.dll的本机C++应用程序没有在Mixed lib.dll中的外部变
- 当我使用 C++ 中的 C# dll 来使用 Selenium 时,存在异常处理问题
- Python ctypes:不会按预期加载 dll
- glewInit and building dll