库、DLL 和 .h 文件

Libs ,DLLs and .h files

我是一个 C# 人,所以我在这里迷路了,这个项目声称已经为 Windows https://soildgeo.codeplex.com/releases/view/108738

编译了那个库

文件夹自带Include、Lib64和Bin64文件夹。如果我没记错的话,我只需要将 .lib 文件复制到 VC/lib 文件夹,并将 include 中的文件夹复制到 VC/include 文件夹,这样我就可以开始针对这些 API 进行编码,它们出现在#include<> intellisense 但随后它们无法编译。我的问题是,我对整个过程的假设是否正确?如果不是,正确的步骤是什么?最后,我是否需要随时使用 Bin64 文件夹中的 Dll?

我正在使用 VS2013 提前致谢

编辑

1>------ 构建开始:项目:PhysBAMTest,配置:调试 x64 ------ 1> main.cpp 1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\PhysBAM_Tools\Log\LOG.h(163):错误 C2146:语法错误:缺少“;”在标识符“属性”之前 1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\PhysBAM_Tools\Log\LOG.h(163): error C2530: 'PhysBAM::LOG::anonymous-namespace'::cout' : references must be initialized 1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\PhysBAM_Tools\Log\LOG.h(163): error C2065: 'unused' : undeclared identifier 1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\PhysBAM_Tools\Log\LOG.h(163): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\PhysBAM_Tools\Log\LOG.h(163): error C2143: syntax error : missing ';' before '=' 1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\PhysBAM_Tools\Log\LOG.h(164): error C2146: syntax error : missing ';' before identifier '__attribute__' 1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\PhysBAM_Tools\Log\LOG.h(164): error C2530: 'PhysBAM::LOG::anonymous-namespace'::cerr' : 必须初始化引用 1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\PhysBAM_Tools\Log\LOG.h(164): error C2065: 'unused' : 未声明的标识符 1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\PhysBAM_Tools\Log\LOG.h(164):错误 C4430:缺少类型说明符 - 假定为 int。注意:C++ 不支持 default-int 1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\PhysBAM_Tools\Log\LOG.h(164): 错误 C2374: 'PhysBAM::LOG::anonymous-namespace'::__attribute__' : redefinition; multiple initialization 1> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\PhysBAM_Tools\Log\LOG.h(163) : see declaration of 'PhysBAM::LOG::anonymous-namespace':: 属性' 1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\PhysBAM_Tools\Log\LOG.h(164): error C2143: 语法错误:缺少 ';'在“=”之前 ========== 构建:0 次成功,1 次失败,0 次更新,0 次跳过 ==========

编辑

根据下面的答案添加了 WIN32 宏后,我这次遇到了链接器错误

Error 1 error LNK2019: 未解析的外部符号"class std::basic_ostream > & __cdecl PhysBAM::LOG::cout_Helper(void)" (?cout_Helper@LOG@PhysBAM@@YAAEAV?$basic_ostream@DU?$char_traits@D @std@@@std@@XZ) 在函数中引用 "void __cdecl PhysBAM::LOG::anonymous namespace'::dynamic initializer for 'cout''(void)" (??__Ecout@?A0x5bbeb782@LOG@PhysBAM@@YAXXZ) C:\Users...\Documents\Visual Studio 2013\Projects\PhysBAMTest\PhysBAMTest\main.obj PhysBAMTest

另外,您对 .lib 和 .h 所做的操作,您需要将 .dll 保存在 System32 目录中,或者保存在与 exe 相同的目录中。

this question 的回答可能会帮助您更好地理解。

所有这些 attributeunused__attribute__ 都是某些人所说的 GNU-ishms,即特定于 GCC 兼容编译器(GCC 本身、Clang、ICC 和其他)。但是 MS VC 并不针对 GCC 兼容性,所以它们根本不起作用。

移植到 Windows 的人设法通过使用一些预编译器技巧删除了这些构造,我认为在文件 Utilities/PHYSBAM_OVERRIDE.h 中。但是要使它们起作用,您必须定义宏 WIN32。在项目 "C/C++ Preprocessor Settings" 页面中执行此操作,而不是在代码中执行此操作,因此它将立即为所有源文件定义。

或者,这个 IMO 将是正确的解决方案,修补源代码,并将每次出现的 #ifdef WIN32#if defined(WIN32) 替换为 #ifdef _WIN32。宏 _WIN32always predefined in Win32 and Win64,但 WIN32 不是。

嗯,从技术上讲,如果问题是关于 Windows 系统还是关于 MSVC 编译器(有一个 GCC 编译器用于 Windows).然后对系统依赖项使用 _WIN32,对编译器依赖项使用 _MSC_VER

然后,如果您愿意,请将补丁发送到 Codeplex 项目。

更新

关于链接器错误,应该很容易修复:只需将必要的“*.lib”文件添加到项目中即可。您可以将它们添加到项目的 Linker Property Page