C++ 如何在 64 位 Windows 中制作 OpenGL 应用程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1236670/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make OpenGL apps in 64-bit Windows?
提问by Ruben Trancoso
My project compiles, link and run in xp32 then I tried to cross compile it to x64 and I came across a lot of questions:
我的项目在 xp32 中编译、链接和运行,然后我尝试将其交叉编译为 x64,但遇到了很多问题:
- There's no native x64 instalable OpenGL SDK so I link against what?
- I saw someone saying that x64 apps use 32bits opengl dll. I tryied to run my compiled 64-bits app in a xp64 with drivers to my video card (radeon 4850), the same I use on xp32 and I got that typical error "bla bla bla, maybe reinstalling you application will resolve the problem"
- If I use video card drivers how to keep it working with another Cards, should I build a version for each? (no sense). Should I load an available library dinamicaly? (same no sense)
- Which is the reference implementation for x64? where do I find its libs to link against?
- 没有本机 x64 可安装的 OpenGL SDK,所以我链接什么?
- 我看到有人说 x64 应用程序使用 32 位 opengl dll。我尝试在 xp64 中运行我编译的 64 位应用程序,并在我的视频卡(radeon 4850)上运行我的驱动程序,我在 xp32 上使用的相同,我遇到了典型的错误“bla bla bla,也许重新安装您的应用程序会解决问题”
- 如果我使用显卡驱动程序如何让它与其他显卡一起工作,我应该为每个显卡构建一个版本吗?(没有意义)。我应该动态加载一个可用的库吗?(同样没有意义)
- 哪个是 x64 的参考实现?我在哪里可以找到要链接的库?
I'm really lost on that matter. I did a lot of searchs and found nothing that helped me understant till the momment.
在这件事上我真的很迷茫。我做了很多搜索,但没有发现任何可以帮助我理解的东西,直到那一刻。
So, what is the path? What I want to know to make native x64 OpenGL apps?
那么,路径是什么?我想知道什么来制作原生 x64 OpenGL 应用程序?
回答by bk1e
The 64-bit OpenGL import library is included in the Windows SDKand gets installed to %ProgramFiles%\Microsoft SDKs\Windows\<version>\Lib\x64\OpenGL32.lib
. The corresponding DLL is named opengl32.dll
and is located in %SystemRoot%\system32
. The 32-bit version is also named opengl32.dll
and is located in %SystemRoot%\syswow64
on 64-bit Windows.
64 位 OpenGL 导入库包含在Windows SDK 中并安装到%ProgramFiles%\Microsoft SDKs\Windows\<version>\Lib\x64\OpenGL32.lib
. 相应的 DLL 被命名opengl32.dll
并位于%SystemRoot%\system32
. 32 位版本也被命名opengl32.dll
并位于%SystemRoot%\syswow64
64 位 Windows 上。
You can't load 32-bit DLLs in a 64-bit process, so whatever you read about x64 apps using the 32-bit OpenGL DLL was incorrect. There is definitely a 64-bit OpenGL DLL, but it has "32" in its name, presumably to make porting easier.
您无法在 64 位进程中加载 32 位 DLL,因此无论您阅读有关使用 32 位 OpenGL DLL 的 x64 应用程序的任何内容都是不正确的。肯定有一个 64 位 OpenGL DLL,但它的名称中有“32”,大概是为了使移植更容易。
回答by LastBlow
The OpenGL static and dynamic libraries OpenGL32.lib
and opengl32.dll
for 32-bit or 64-bit applications come with the OS and are now respectively in the Windows directories listed below. Just keep in mind that the 32-bit and the 64-bit OpenGL (and glew) libraries are named the same for historical reasons.
OpenGL 静态和动态库OpenGL32.lib
以及opengl32.dll
32 位或 64 位应用程序随操作系统一起提供,现在分别位于下面列出的 Windows 目录中。请记住,由于历史原因,32 位和 64 位 OpenGL(和 glew)库的名称相同。
If you are using Visual Studio in Windows, no need to copy the opengl32.dll
library in your Debug
or Release
directories where is your .exe
or the path to OpenGL32.lib
in Visual Studio - only add "Opengl32.lib" in Properties
, Linker
, Input
, then Additional Dependencies
.
如果您在 Windows 中使用 Visual Studio,则无需复制opengl32.dll
您Debug
或Visual Studio 中的路径或Release
目录中的库- 只需在、、、 中添加“Opengl32.lib” 。.exe
OpenGL32.lib
Properties
Linker
Input
Additional Dependencies
C:\Program Files (x86)\Windows Kits\Lib.0.14393.0\um\x86
C:\Windows\System32
C:\Program Files (x86)\Windows Kits\Lib.0.14393.0\um\x64
C:\Windows\SysWOW64