Linkage of namespace functions
- by user144182
I have a couple of methods declared at the namespace level within a header for a class:
// MyClass.h
namespace network {
int Method1(double d);
int Method2(double d);
class MyClass
{
//...
}
}
then defined in
//MyClass.cpp
int
Method1(double d)
{ ... }
int
Method2(double d)
{ ... }
This project compiles cleanly and is a dependency for a ui project which uses MyClass. The functions were previously member functions of MyClass, but were moved to namespace since it was more appropriate.
My problem is the ui project complains when it gets to the linker:
1network.lib(MyClass.obj) : error LNK2001: unresolved external symbol "int __cdecl network::Method1(double)" (?INT@ds@sim@@YAHN@Z)
1network.lib(MyClass.obj) : error LNK2001: unresolved external symbol "int __cdecl network::Method2(double)" (?CINT@ds@sim@@YAHN@Z)
What am I doing wrong?