在Visual Studio中引用静态库项目

时间:2015-09-24 09:07:57

标签: c++ c visual-studio-2013 msbuild static-libraries

TL; DR:我如何制作项目取决于visual studio中的另一个静态库项目

我正在尝试创建一个使用此库的小型C ++项目:http://finitetransform.sourceforge.net/

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

现在我是Visual Studio中C ++开发的新手,但是我一直在谷歌搜索有关如何设置它的运气好几天。

这就是我想要的:我想在Visual Studio中找到一个解决方案,我可以在其中构建NTTW,FRTW以及我自己的Playground应用程序,我可以在这里使用这些库。我想从源代码构建两个库,因为我可能想要编辑它们。

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

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

什么有效:NTTW构建得很好。但是,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:\ct\newproject\fromsource\frtw\ghosts.c(26): fatal error C1083: Cannot open include file: 'nttw/image.h': No such file or directory
1>u:\ct\newproject\fromsource\frtw\radon.c(27): fatal error C1083: Cannot open include file: 'nttw/image.h': No such file or directory
1>u:\ct\newproject\fromsource\frtw\vector.h(29): fatal error C1083: Cannot open include file: 'nttw/array.h': No such file or directory (compiling source file vector.c)
1>u:\ct\newproject\fromsource\frtw\fourier.h(25): fatal error C1083: Cannot open include file: 'fftw3.h': No such file or directory (compiling source file fourier.c)
1>u:\ct\newproject\fromsource\frtw\array_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:\ct\newproject\fromsource\frtw\noise.h(45): fatal error C1083: Cannot open include file: 'nttw/global.h': No such file or directory (compiling source file noise.c)
1>u:\ct\newproject\fromsource\frtw\mojette.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 ==========

我很不确定该怎么做。任何帮助将不胜感激。感谢

1 个答案:

答案 0 :(得分:0)

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

不要忘记Debug和Release有不同的设置,您可能正在更改Release设置并在Debug下构建。

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