且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在visual-studio和gcc-linux中导出/导入变量?

更新时间:2023-11-08 16:26:04

您是什么意思在DLL端进行更改"?您执行什么代码来获取变量然后对其进行更改?
How do you mean "change it on the DLL side"? What code do you execute to get the variable and then to change it?


让我们尝试查看事件的顺序:
Let''s try looking at the sequence of events:

  1. 清理两个项目(确保输出目录为空).
  2. 使用上述代码构建DLL.这将产生两个文件name.lib和name.dll(name是您为项目指定的名称).
  3. 在EXE项目的输入链接器属性"的其他依赖项"部分中添加"name.lib"
  4. 将name.lib文件的目录路径添加到EXE项目中常规链接器属性"的其他库目录"部分.
  5. 构建EXE项目.
  6. 将name.dll文件复制到EXE项目的目标文件中,即包含目标.exe文件的目录
  7. 运行程序并检查结果.

  1. Clean both projects (ensure output directories are empty).
  2. Build the DLL using the code as shown above. This should produce two files name.lib and name.dll (name is the name you give the project).
  3. Add "name.lib" to the Additional Dependencies section of the Input Linker Properties in the EXE project.
  4. Add the directory path of the name.lib file to the Additional Library Directories section of the General Linker Properties in the EXE project.
  5. Build the EXE project.
  6. Copy the name.dll file into the target firectory of the EXE project, i.e the directory that contains the target .exe file
  7. Run the program and check results.