Visual Studio 2010 - 独立功能中的链接器错误
问题描述:
我的解决方案中有两个项目;一个构建静态库,另一个使用它并对其进行测试。Visual Studio 2010 - 独立功能中的链接器错误
在我的测试应用程序中使用此函数时,我得到了这些链接器错误(2019)...但我可以没有问题地链接其他声明的东西(soley类)。
的测试应用程序依赖于静态库,它有参考它,以及因此它应该链接(我只能得到连接错误以及)
这是为什么?我错过了什么吗?我想不出任何可能出错的事情。
PortableTime.h
#ifndef _PORTABLE_TIME_H
#define _PORTABLE_TIME_H
#if defined _WIN32 || _WIN64
#include <WinSock2.h>
#else
#include <time.h>
#endif
#include <stdint.h>
uint64_t GetTimeSinceEpoch();
#endif
PortableTime.cpp
#include "PortableTime.h"
uint64_t GetTimeSinceEpoch()
{
#if defined _WIN32 || _WIN64
return (uint64_t)timeGetTime();
#else
struct timeval tv;
gettimeofday(&tv, 0);
return (((uint64_t)tv.tv_sec)*(uint64_t)1000) + (((uint64_t)tv.tv_usec)/(uint64_t)1000);
#endif
}
答
timeGetTime function需要WINMM.LIB库,让你有额外的依赖关系中指定。
配置属性 - >链接器 - >输入 - >其他依赖项。
+0
啊哈!钉牢它,谢谢! – KaiserJohaan 2012-02-02 19:56:06
+0
不客气;) – LihO 2012-02-02 19:58:03
你会得到什么错误? – 2012-02-02 19:49:54
'错误LNK2001:无法解析的外部符号__imp__timeGetTime @'我猜 – LihO 2012-02-02 19:54:59