C++ Visual Studio 2005项目依赖关系问题
我正在开发一个数据管理项目,该项目定期删除特定文件夹中的文件。 该解决方案包含三个项目,其中一个是应用程序,另外两个是静态库。 现在我想再添加一个项目,它是一个用于日志记录的静态库。 日志记录静态库项目有一个应用程序项目引用的头文件。 当我构建解决方案时,由于找不到头文件而出现错误。 当我添加日志记录静态库项目时,我还通过检查项目依赖项中适当的 bix 使应用程序项目依赖于它。 谁能帮帮我吗?
I am working on a dataManagement project that periodically deletes files in a specific folder. The solution has three projects of which, one is the application and the other two are static libraries. Now I want to add one more project which is a static library used for logging. The logging static library project has a header file which the application project refers. When I build the solution, I am getting error as the header file is not found. When I added the logging static library project, I also made the application project dependent on it by checking the appropriate bix in the project dependencies.
Can anyone please help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它需要一个额外的包含文件路径来引用头文件目录...
项目->属性->配置属性->C/C++->其他包含目录
它不会自动拾取头文件路径,它只知道如何链接到项目......它完全未定义头文件应该在哪里。 或者即使您有头文件,如果您愿意,您也可以转发引用其他项目中的内容!
It needs an additional include file path to reference the header file directory...
Project->Properties->Config Properties->C/C++->Additional Include Directories
it doesn't auto pick up the header file paths, it just knows how to link to the project.... Its completely undefined where the header file should be. or even if you have a header file, you can forward reference the thing in the other project if you like!
要让静态链接库在 VS 中工作,您需要做两件事。 编译器需要能够找到您引用的符号的声明,并且链接器需要能够解析完整的定义。 当您将 .lib 文件添加到 VS 项目时,这满足了第二个义务。 为了满足第一个要求,您必须在第一个引用之前将标头包含在源层次结构中的某个位置,并且还必须告诉项目在哪里可以找到标头文件。 VS 中的依赖项设置仅设置构建顺序 - 它们在这里没有帮助。 您需要确保头文件所在的文件夹已添加到项目属性中的“其他包含目录”设置中,或者是主 VS 选项中的全局包含目录之一。 您还必须确保 .lib 已添加到链接器的“附加依赖项”设置中。
There are two things you need to do to get a statically linked library working in VS. The compiler needs to be able to find the declaration for the symbols that you're referencing and the linker needs to be able to resolve the full definition. When you add the .lib file to the VS project this meets the second obligation. To meet the first you must include the header somewhere in your source hierarchy before the first reference and you must also tell the project where to find the header files. The dependency settings in VS only set the build order - they will not help here. You need to make sure that the folder that your header files are in is added to the "Additional Include Directories" setting in the project properties, or is one of the global include directories in the main VS Options. You must also make sure that the .lib is added to the linker's "Additional Dependencies" setting.