[英]Visual Studio 2010 - linker errors in stand-alone functions
我的解决方案中有两个项目; 一个构建静态库,另一个使用它并测试它。
在我的测试应用程序中使用此函数时,我有这些链接器错误(2019)...但我可以链接其他声明的东西(soley类)没有问题。
test-app依赖于静态lib,它也引用了它,所以它应该链接(我只得到那个链接器错误)
为什么是这样? 我错过了什么吗? 我想不出任何可能出错的事情。
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函数需要Winmm.lib库,因此您必须在其他依赖项中指定它。
配置属性 - >链接器 - >输入 - >附加依赖项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.