【发布时间】:2012-02-25 11:55:30
【问题描述】:
我的解决方案中有两个项目;一个构建静态库,另一个使用并测试它。
在我的测试应用程序中使用此函数时,我遇到了这些链接器错误 (2019)……但我可以毫无问题地链接其他声明的东西(单独的类)。
test-app 依赖于静态库,它也引用了它,所以它应该链接(我也只得到那个链接器错误)
这是为什么?我错过了什么吗?我想不出还有什么可能出错的地方。
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
}
【问题讨论】:
-
error LNK2001: unresolved external symbol __imp__timeGetTime@我猜
标签: c++ visual-studio-2010 visual-c++ linker static-libraries