参考静态库项目在Visual Studio

Reference static library project in Visual Studio

本文关键字:Visual Studio 项目 静态 参考      更新时间:2023-10-16

TL;DR:如何使一个项目依赖于visual studio中的另一个静态库项目

我想做一个小的c++项目,使用这个库:http://finitetransform.sourceforge.net/

库包含两个项目。NTTW和FRTW,其中FRTW依赖于NTTW。我的项目应该依赖于FRTW。NTTW和FRTW以及相对较小和简单的库,没有任何外部依赖(除了c标准库)

现在我是Visual studio中c++开发的新手,但我已经在谷歌上搜索了好几天,想知道如何设置这个。

这就是我想要的:我想要一个解决方案在visual studio中,我可以建立NTTW, FRTW和他们我自己的游乐场应用程序,在那里我可以玩库。我想从源代码构建这两个库,因为我可能想要编辑它们。

这就是我所拥有的:我已经在Visual Studio中创建了一个具有我想要的结构的解决方案。我已经创建了我自己的项目(一个c++控制台应用程序),一个NTTW项目和一个FRTW项目-两者都创建了一个"静态库"。

由于库是用C编写的,我已经禁用了预编译头文件,以便使它们构建。然后我添加了NTTW作为FRTW的依赖项,FRTW作为我的游乐场项目的依赖项。

工作原理:NTTW build just fine。然而,FRTW没有,因为它不能连接到NTTW。当我试图构建它时,我得到这些错误告诉我它无法从NTTW

找到头文件
1>------ Build started: Project: FRTW, Configuration: Debug Win32 ------
1>  array_complex.c
1>  fourier.c
1>  ghosts.c
1>  mojette.c
1>  noise.c
1>  radon.c
1>  vector.c
1>u:ctnewprojectfromsourcefrtwghosts.c(26): fatal error C1083: Cannot open include file: 'nttw/image.h': No such file or directory
1>u:ctnewprojectfromsourcefrtwradon.c(27): fatal error C1083: Cannot open include file: 'nttw/image.h': No such file or directory
1>u:ctnewprojectfromsourcefrtwvector.h(29): fatal error C1083: Cannot open include file: 'nttw/array.h': No such file or directory (compiling source file vector.c)
1>u:ctnewprojectfromsourcefrtwfourier.h(25): fatal error C1083: Cannot open include file: 'fftw3.h': No such file or directory (compiling source file fourier.c)
1>u:ctnewprojectfromsourcefrtwarray_complex.h(30): fatal error C1083: Cannot open include file: 'fftw3.h': No such file or directory (compiling source file array_complex.c)
1>u:ctnewprojectfromsourcefrtwnoise.h(45): fatal error C1083: Cannot open include file: 'nttw/global.h': No such file or directory (compiling source file noise.c)
1>u:ctnewprojectfromsourcefrtwmojette.c(29): fatal error C1083: Cannot open include file: 'nttw/prime.h': No such file or directory
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

我不确定从这里该做什么。任何帮助都将不胜感激。由于

查看您的错误,我认为FRTW项目的调试配置设置需要Additional Include Directories设置更新以包括nttw目录的父目录。如果打开FRTW项目的属性页,可以在Configuration Properties -> C/C++ -> General下找到Additional Include Directories

不要忘记Debug和Release有不同的设置,你可以在Debug下更改Release设置和构建。

您可能还需要更新FRTW项目,以包括NTTW通过Configuration Properties -> Librarian -> General生成的静态库文件,并将静态库将输出到Additional Library Directories的目录和静态库的名称添加到Additional Dependencies。您可能需要执行类似于Playground应用程序项目的操作来导入FRTW可能生成的静态库。