如何为所有 Windows 10 64 位系统创建一个 DLL?
我最近使用 g++ 创建了一个用 C++ 编写的 DLL。目的是从 LabVIEW 构建的 EXE 中调用它,这工作得很好。然后,我将 LabVIEW EXE 及其支持代码(包括 DLL)复制到一台新 PC(已预装了必要的 LabVIEW 支持)。在新 PC 上,LabVIEW EXE 无法加载 DLL。我在新PC上重建了DLL,替换了旧的DLL,然后LabVIEW EXE可以加载DLL并再次正常运行。
我的问题是:为什么我需要在新 PC 上重建 DLL?是因为硬件不同吗?如何为所有 Windows 10 64 位系统创建一个 DLL?
有关设置的一些信息:
- 两台电脑都运行 Windows 10 64 位
- DLL 是基本的,仅使用
和
库 - PC 1 是 DELL XPS
- Intel NUC
- PC 2 是内置 LabVIEW 2021 64 位的
- LabVIEW EXE两台 PC 上均安装了 LabVIEW 2021 64 位运行时
- DLL为 64 位构建
我知道有时在 Visual Studio 中构建的 DLL 需要 C++ 可再发行组件包,但我一直无法找到对 g++ 可再发行组件的引用。这就是我需要的吗?
我对 C++ 比较陌生,所以也许我只是没有寻找正确的东西。
I recently created a DLL written in C++ using g++. The intent was to call it from a LabVIEW-built EXE, and this worked just fine. I then copied the LabVIEW EXE and its support code (including the DLL) over to a new PC (which was already pre-installed with the necessary LabVIEW support). On the new PC, the LabVIEW EXE could not load the DLL. I rebuilt the DLL on the new PC, replaced the old DLL, and then the LabVIEW EXE could load the DLL and run just fine again.
My questions are: Why did I need to rebuild the DLL on the new PC? Is it because of different hardware? How do I create one DLL for all Windows 10 64-bit systems?
Some information about the setup:
- Both PCs are running Windows 10 64-bit
- The DLL is basic and only uses the
<math.h>
and<iostream>
libraries - PC 1 is a DELL XPS
- PC 2 is an Intel NUC
- LabVIEW EXE built in LabVIEW 2021 64-bit
- LabVIEW 2021 64-bit runtime is installed on both PCs
- DLL built for 64-bit
I understand that sometimes a DLL built in Visual Studio requires a C++ Redistributable Package, but I haven't been able to find a reference to a redistributable for g++. Is that what I need?
I am relatively new to C++, so perhaps I am just not searching for the right things.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论