I have two projects in my solution; one which builds a static lib, another which uses it and tests it.
I’ve got these linkers errors (2019) when using this function in my test app… yet I can link other declared stuff (soley classes) without problem.
The test-app is dependent on the static lib, and it has reference to it as well so it should link (I only get that linker error as well)
Why is this? Am I missing something? I can’t think of anything else that couldve gone wrong.
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 requires Winmm.lib library, so you have to specify it among additional dependencies.
Configuration Properties -> Linker -> Input -> Additional Dependencies.