views:

47

answers:

1

I'm a little new to c++ in visual studio, and I'm trying to compile a massive C++ project with Visual Studio. I've gone through and added all source and header files to my project and also updated all of the include paths in the project properties.

If I have the type of project set to "Static Library (.Lib)" the project will compile without error and I'll have a nice fatty .lib file.

If I change the project over to a "Dynamic Library (.dll)" The project no longer compiles and fails on linking errors.

Here's an example of one:

Error   27  error LNK2001: unresolved external symbol "char const * __cdecl Project::toString(enum Project::compMode)" (?toString@Project@@$$FYAPBDW4compMode@1@@Z) H:\repo.project\user\tool\component.obj tool

Any help or background on what might be happening here?

+4  A: 

Check if you defined the following member function

char const* Project::toString(Project::compMode)

When you compile as a static library an unresolved symbol is not an error, because it can be resolved later when you link with other code.

You may have forgotten to add some .cpp file to your project.

vitaut
I did indeed! But question is, why would it compile as a lib but not a dll if I was missing .cpp files?
Nick
Static library is just a collection of object files, it may contain symbols that you are using, but have not defined. DLLs and exectutables on the other hand should have all the symbols except those with dllimport attribute resolved (roughly speaking).
vitaut