无法链接静态库C++

jef*_*yer 3 c++ linker static

我已经想出如何设置VC++来将代码编译成.lib文件而不是.exe,但是我无法将lib与我的其他.obj文件链接在一起.

这是我如何设置库和应用程序文件夹.(我不确定这是不对的)

AppFolder
  App.sln
  App.ncb
  *.h
  *.cpp
  Debug
    *.obj
    App.exe
Run Code Online (Sandbox Code Playgroud)

和硬盘上的其他地方......

LibraryFolder
  lib
    Library.lib
  include
    LibrarySolutionFolder
      Library.sln
      Library.ncb
      *.h
      *.cpp
      Debug
        *.obj
        Library.lib
Run Code Online (Sandbox Code Playgroud)

我一直在#include我的应用程序的cpp文件中的库*.h文件,一切都编译得很好.只是当它链接时,我得到一个正在搜索的所有.lib文件的列表,并且即使我在VC++目录中列出了Library.lib,它也不在那里.我怎样才能将其链接起来?(我是否正确构建了库文件夹?)

180*_*ION 10

关于项目属性:

配置属性 - >链接器 - >输入 - >附加依赖项

在那里添加它.

或者,在库的.h文件中,添加:

#pragma comment(lib, "Library")
Run Code Online (Sandbox Code Playgroud)

这将自动为您完成.