Original Post
So what I'm trying to do I'm not sure it can totally be done. It's been awhile since I've done any C++. Anyway, I have created a DLL application project in Visual Studio C++ 2008 Express Edition. In the project, I have a class, say: And the implementation file: Then when I create another regular Win32 Project within the same Solution and call the bar() method like so (I'm using UnitTest++ in this project): Then I get the following error: However, if I move the implementation of the bar method into the Foo header, everything works. Then Foo looks like so: I suspect that, if this is even possible, it is a Linker option issue. I've tried adding project that contains Foo's Debug folder to the "Additional Library Dependences" option in the Linker -> Input settings for the project using this class, but this has not worked. Is this even possible to do? When creating a DLL in C++, am I allowed to use implementation files? Is there missing code or additional setup required within the DLL project? Another example of the steps I used to create the DLL are here. I appreciate any insight that anyone can offer on this. Thanks!
// Foo.h
#ifndef FOO_H
#define FOO_H
#include "stdafx.h"
using namespace std;
class Foo {
public:
Foo(void) {}
~Foo(void) {}
void bar();
};
#endif
// Foo.cpp
#include "stdafx.h"
void Foo::bar() {
// ...
}
// FooTest.h
#include "UnitTest++.h"
#include "Foo.h"
TEST(TestLinker) {
Foo foo;
foo.bar();
}
error LNK2001: unresolved external symbol "public: void __thiscall Foo::bar(void)" (?bar@Foo@@QAEXXZ)
// Foo.h
class Foo {
public:
Foo(void) {}
~Foo(void) {}
void bar() {
// ...
}
};