0

I had a solution named fun.sln with a project called fun.vcxproj.

I created a whole bunch of name spaces ready to be used.

I made another project called no_more_fun.vcxproj.

I added the includes directory for fun.vcxproj to the configuration of no_more_fun.vcxproj.

I added this to no_more_fun.cpp

#include "candy.h"

void main(void)
{

candy::get();
return;

}

candy.h is in the default directory for fun.vcxproj(which was added to the config)

But I get...

LNK2001 unresolved external symbol "int __cdecl candy::get(unsigned long)" (?get@candy@@YAHK@Z) .....

Visual Studio shows no error before compiling.

The "candy" namespace works fine in the "fun" project so idn...

Is there a guide or something so that i can understand how i can go about sharing code efficiently among different projects within ONE solution?

swayz
  • 65
  • 7
  • 1
    Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Ken White Mar 25 '16 at 01:34

2 Answers2

0

This is a linker error. You didn't get any error at compile time, because the compiler found the candy::get() method in candy.h header, but the implementation (which I suppose is in a candy.cpp file) is not found by the linker. Just add candy.cpp too to no_more_fun.vcxproj.

ps. I didn't observe but in the error message you can see that the function waits a parameter. call it like this:

unsigned long foo = 0;
candy::get(foo);
b18
  • 1
  • 2
0

This is going to sounds stupid but...i just dragged the files in to visual studio so that the no_more_fun project had the "files" in its "directory" too.

wow... I shouldn't need to do that...Am I wrong?(sarcasm).

swayz
  • 65
  • 7