【发布时间】:2011-03-05 03:45:09
【问题描述】:
我编写了以下简单程序:
#include "stdafx.h"
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <ostream>
int _tmain(int argc, char* argv[])
{
google::InitGoogleLogging(argv[0]);
LOG(INFO) << "Found";
return 0;
}
我从这里查看了 google-glog:http://code.google.com/p/google-glog/source/checkout
我已经从这里查看了 google-gflags:http://code.google.com/p/google-gflags/
我在 Visual Studio 2010 Express 中拥有所有这三个项目,都在同一个解决方案下:
- 解决方案
- GoogleLibsTest
- libgflags
- libglog
当我编译它时,我得到以下错误:
1>------ Build started: Project: GoogleLibsTest, Configuration: Debug Win32 ------
1>GoogleLibsTest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall google::LogMessage::~LogMessage(void)" (__imp_??1LogMessage@google@@QAE@XZ) referenced in function _wmain
1>GoogleLibsTest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall google::LogMessage::stream(void)" (__imp_?stream@LogMessage@google@@QAEAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@XZ) referenced in function _wmain
1>GoogleLibsTest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall google::LogMessage::LogMessage(char const *,int)" (__imp_??0LogMessage@google@@QAE@PBDH@Z) referenced in function _wmain
1>GoogleLibsTest.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl google::InitGoogleLogging(char const *)" (__imp_?InitGoogleLogging@google@@YAXPBD@Z) referenced in function _wmain
1>C:\Users\leeand00\Desktop\glogNgflagsTest\GoogleLibsTest\Debug\GoogleLibsTest.exe : fatal error LNK1120: 4 unresolved externals
========== Build: 0 succeeded, 1 failed, 2 up-to-date, 0 skipped ==========
我已经做了几件事来尝试解决这个问题,包括:
在解决方案属性页面中选择公共属性项目>依赖项并将 GoogleLibsTest 设置为依赖于其他两个项目。
-
在 GoogleLibsTest 属性页面中
将 libgflags-debug.lib libglog_static.lib 添加到 Configuration Properties>Linker>Input>Additional Dependencies 列表。
在配置属性>VC++ 目录中,我将包含 libgflags-debug.lib 和 libglog_static.lib 的目录添加到库目录列表中。
在 Configuration Properties>C/C++>General>Additional Include Directories 中添加了
\src\windows 的路径(因为这是 glog 的头文件所在的位置) 在 Configuration Properties>C/C++>General>Additional Include Directories 中添加了
\src\windows 的路径(因为这是 gflags 的头文件所在的位置)
由于某种原因,它正在寻找一个 dll 文件(我不知道这是为什么)
我还有什么遗漏的吗?
【问题讨论】:
-
我正在尝试将 glog 与 Visual Studio 2012 一起使用,并且遇到了同样的问题。我尝试使用静态库和 dll,但我真的不知道出了什么问题。你成功了吗?
标签: visual-c++ visual-studio-2010