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?
我正在开发一个dataManagement项目,它定期删除特定文件夹中的文件。该解决方案有三个项目,其中一个是应用程序,另外两个是静态库。现在我想再添加一个项目,它是一个用于记录的静态库。日志记录静态库项目有一个应用程序项目引用的头文件。当我构建解决方案时,由于找不到头文件,我收到错误。当我添加了日志记录静态库项目时,我还通过检查项目依赖项中的相应bix使应用程序项目依赖于它。谁能帮帮我吗?
2 个解决方案
#1
It needs an additional include file path to reference the header file directory...
它需要一个额外的包含文件路径来引用头文件目录...
Project->Properties->Config Properties->C/C++->Additional Include Directories
项目 - >属性 - >配置属性 - > C / C ++ - >其他包含目录
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!
它不会自动获取头文件路径,它只知道如何链接到项目....它完全未定义头文件应该在哪里。或者即使你有一个头文件,如果你愿意,也可以转发引用另一个项目中的东西!
#2
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.
要使静态链接库在VS中工作,您需要做两件事。编译器需要能够找到您引用的符号的声明,并且链接器需要能够解析完整定义。将.lib文件添加到VS项目时,这符合第二个义务。要满足第一个参考,您必须在第一个引用之前在源层次结构中的某处包含标题,并且还必须告诉项目在何处查找头文件。 VS中的依赖项设置仅设置构建顺序 - 它们在此处没有帮助。您需要确保头文件所在的文件夹已添加到项目属性中的“其他包含目录”设置中,或者是主VS选项中的全局包含目录之一。您还必须确保将.lib添加到链接器的“附加依赖项”设置中。
#1
It needs an additional include file path to reference the header file directory...
它需要一个额外的包含文件路径来引用头文件目录...
Project->Properties->Config Properties->C/C++->Additional Include Directories
项目 - >属性 - >配置属性 - > C / C ++ - >其他包含目录
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!
它不会自动获取头文件路径,它只知道如何链接到项目....它完全未定义头文件应该在哪里。或者即使你有一个头文件,如果你愿意,也可以转发引用另一个项目中的东西!
#2
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.
要使静态链接库在VS中工作,您需要做两件事。编译器需要能够找到您引用的符号的声明,并且链接器需要能够解析完整定义。将.lib文件添加到VS项目时,这符合第二个义务。要满足第一个参考,您必须在第一个引用之前在源层次结构中的某处包含标题,并且还必须告诉项目在何处查找头文件。 VS中的依赖项设置仅设置构建顺序 - 它们在此处没有帮助。您需要确保头文件所在的文件夹已添加到项目属性中的“其他包含目录”设置中,或者是主VS选项中的全局包含目录之一。您还必须确保将.lib添加到链接器的“附加依赖项”设置中。