如何在MSVS2015 for x64中使用静态库?

时间:2017-02-17 18:37:34

标签: c++ visual-studio-2015 static-libraries

此代码

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    return 0;
}

不在MSVS2015Enterprise for Debug或Release x64中编译:

1>------ START COMPILING: PROJECT: SFML_Test, CONFIGURATION: Release x64 ------
1>  Source.cpp
1>LINK : fatal error LNK1181: FILE "sfml-graphics.lib" NOT FOUND
========== BUILD: SUCCESSFULLY: 0, WITH ERRORS: 1, UNCHANGED: 0, SKIPPED: 0 ==========

发布x64,LINK:致命错误LNK1181

但目录D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\sfml-graphics.lib

我该如何解决?

对于包含字符串#pragma comment(lib, "MyLib.lib")的所有源文件都是如此!

1 个答案:

答案 0 :(得分:0)

发生此error是因为链接器无法找到sfml-graphics.lib库。我猜您在链接器选项中指定其他库目录,而路径周围没有引号。适当的价值应该是:

"D:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib"