Linkage of namespace functions

Posted by user144182 on Stack Overflow See other posts from Stack Overflow or by user144182
Published on 2010-05-18T18:46:52Z Indexed on 2010/05/18 18:50 UTC
Read the original article Hit count: 173

Filed under:
|
|

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:

1>network.lib(MyClass.obj) : error LNK2001: unresolved external symbol "int __cdecl network::Method1(double)" (?INT@ds@sim@@YAHN@Z)

1>network.lib(MyClass.obj) : error LNK2001: unresolved external symbol "int __cdecl network::Method2(double)" (?CINT@ds@sim@@YAHN@Z)

What am I doing wrong?

© Stack Overflow or respective owner

Related posts about c++

Related posts about visual-studio-2005