You missed to define a destructor function for your Logger
class:
Logger::~Logger()
{
}
Either omit the declaration for it (the compiler creates a default version), or do as shown above.
Question
I was following http://msdn.microsoft.com/en-us/library/ms235627.aspx to create a static library and use it in other projects located in the same solution. It works fine with static functions; However, when I try to create a constructor, it gives me error LNK2019: unresolved symbol
and error LNK1120
. Am I not allow to create a constructor in static library??
Loogger.h
namespace logger
{
class Logger
{
public:
Logger(int i);
~Logger();
}
}
Logger.cpp
namespace logger
{
Logger::Logger(int i)
{
clog << "In the constructor" << i << endl;
}
}
Main.cpp: (in a separate project)
int main(void)
{
Logger log(3);
return 0;
}
Error:
Solution
You missed to define a destructor function for your Logger
class:
Logger::~Logger()
{
}
Either omit the declaration for it (the compiler creates a default version), or do as shown above.