64位系统上的32位库
如果我在 64 位系统上使用 32 位库会导致任何问题吗?
可能存在哪些不兼容之处?
我知道这个问题太模糊了。一个例子:
我尝试在 Windows 7 64 位上使用 VS2010 设置 FreeGlut 32 位库。一开始有很多问题。因此,我一直在寻找 64 位 FreeGLUT,认为 32 位 FreeGlut 可能会与 64 位 Windows 发生冲突。但后来我成功地在 64 位 Windows 上运行 32 位 FreeGlut,没有出现任何问题。
问题是,程序中是否有什么东西是我们在使用那些与系统不匹配的库时应该检查的? (64 位操作系统上的 32 位库)
Can it cause any problem if I use 32-bit library on a 64-bit system?
What could be the incompatibilities?
I know this question is too vague. An example :
I tried to setup FreeGlut 32-bit library with VS2010 on Windows 7 64-bit. There were a lot of issues at first. So, I was looking for 64-bit of FreeGLUT, thinking 32-bit FreeGlut might conflict with 64-bit Windows. But later on I managed to run my 32-bit FreeGlut with my 64-bit Windows without any problem.
Question is, if there are any thing in the program, that we should look into while using those libraries which doesn't match with the system? (32-bit library on 64-bit OS)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
64 位 Windows 完全能够运行 32 位应用程序。事实上,Visual C++ 的默认配置是构建 x86 应用程序,无论它运行在什么操作系统上。
有一些陷阱 a> 在 64 位 Windows 上运行 32 位应用程序时必须注意。例如,有 注册表重定向(为了避免这种情况,您将
KEY_WOW64_64KEY
传递给例如RegOpenKeyEx
)。还有文件系统重定向。例如,当您阅读系统配置值时,请记住这些重要事项。另请注意,不能在同一进程中混合使用 32 和 64 位。您的 32 位应用程序无法使用 64 位 DLL 或静态库。
64 bit Windows is fully capable of running 32 bit applications. In fact, the default configuration for Visual C++ is to build an x86 application regardless of the operating system it is running on.
There are some gotchas you have to be aware of when running a 32bit app on 64bit Windows. For instance, there's registry redirection (to avoid it you pass
KEY_WOW64_64KEY
to e.g.RegOpenKeyEx
). There's filesystem redirection, too. These are important things to have in mind when you are reading system configuration values, for example.Also, be aware that you can't mix 32 and 64 bitness in the same process. Your 32bit app can't use 64bit DLLs or static libraries.
Visual Studio 可以根据项目设置编译为 32 位或 64 位。
也许,您想问的问题是关于将 32 位库链接到 64 位程序
答案是:
您无法直接链接到 64 位程序内的 32 位代码。
唯一的选择是编译一个可以在 64 位平台上运行的 32 位(独立)程序(使用 ia32),然后使用进程间通信从 64 位程序与其进行通信。
Visual studio can compile for 32 bit or 64 bit based on the project setting.
Probably, Question you mean to ask is about Linking 32-bit library to 64-bit program
The answer is:
You can't directly link to 32bit code inside of a 64bit program.
The only option is to compile a 32bit (standalone) program that can run on your 64bit platform (using ia32), and then use inter-process communication to communicate to it from your 64bit program.
这与操作系统无关 - Windows 不关心您的代码是 32 位还是 64 位。重要的是,您的进程与其需要加载的所有库具有相同的位数,并且它们都必须具有相同的位数。
It's not about the operating system- Windows doesn't care if your code is 32bit or 64bit. It matters that your process is the same bitness as all libraries it cares to load- and they must all be the same bitness.
您可能对此链接感兴趣解释移植到 64 位时的常见编译器错误。它可能会帮助您解决您的问题。
为了更直接地回答你的问题,有些事情可能会使 32 位库在 64 位环境中崩溃,但在 SO 答案中分享的信息太多了。
此链接是与 MSDN 索引相关的64 位系统的开发,您可能也会感兴趣。
You might be interested in this link explaining common compiler errors when porting to 64-bit. It might help you solve your problem.
To try to answer your question more directly, there are things that might make 32 bit libraries break in a 64 bit environment, but that's too much information to share in a SO answer.
This link is the MSDN index related to development for 64 bit systems and might interest you as well.
您的问题可能是如何开发可在 64 位和 32 位硬件上本机运行的特定代码。 此处提供了相关信息。特别是,您必须按照此处的说明启用 64位构建工具。
如果您正在构建 64 位二进制文件,则需要链接 64 位库。请注意,32 位二进制文件应该可以在 64 位 Windows 上正常运行,因此您可能不需要遇到这个麻烦。
Your question could be about how to develop specifically code that will run natively on 64-bit versus 32-bit hardware. There is info on that here. In particular you would have to follow the instructions here to enable 64-bit build tools.
If you are building 64-bit binaries, you will need to link with 64-bit libraries. Note that 32-bit binaries should run just fine on 64-bit Windows, so you may not need to go to this trouble.