views:

33

answers:

1

I'm working on a solution file (VS 2005) which contains multiple projects.

There are two projects of my concern right now - one called core and another called log.

The core project is the startup project and the log project has core ticked in its project dependencies.

I have two files in core project - AB.h(declarations) and AB.cpp(definitions)

Many other cpp files from the core project refer to AB.h and has no issues finding the definitions in AB.cpp.

Now comes the issue. I have a cpp file called CD.cpp in the log project which requires referring to AB.h. I have added the include directory of AB.h to both the core and log projects (AB.cpp also resides in same folder)

In addition the log project has $(OutDir) in its "Additional Library Directories" parameter in the Linker part of project settings. Also have added "core.lib" to the Additional Dependencies field in Properties->Linker->Input

The core project compiles into a dll but there is also a core.lib in the same folder amongst other junk. Solution compiled as the Release version.

In CD.cpp, when I right click the #include "AB.h" line, it takes me to .h file in the core folder. So far everything is fine. However when I try to compile the solution, the log project does not build properly, showing these two linker errors.

log.obj : error LNK2001: unresolved external symbol "class myNamespace::myClass myInstance" (?myInstance@@3VmyClass@myNamespace@@A)

log.obj : error LNK2001: unresolved external symbol "bool infFlag" (?infFlag@@3_NA)

The class is part of an h file included in AB.h (instance declared in AB.cpp and included as extern in CD.cpp. infFlag is declared in AB.cpp and declared in CD.cpp as extern.

What do I do to let log build properly? Thanks


OK. You guys need more details. Sure.

One Solution file. Multiple Projects.

[Core]

includes AB.h and AB.cpp

-AB.h

--includes EF.h from external lib (functions from this lib is working properly for files within the same core project).

--declares some functions

-AB.cpp

--defines those functions which was declared in AB.h

-some other cpp files which can use those functions from AB.h without issues

[/Core]

[Log -> Project Dependencies -> Core]

-No h files

-CD.cpp

--requires AB.h to work. Is included with a #include command and its linked properly (I can right click and click "open file" to open the real .h file)

--uses functions from AB.h

[/Log]

Hopefully this will better let you guys understand the project structure in my solution.

Issue comes when compiling Log project. It always comes up with a link error for any references to functions in AB.h saying "unresolved external symbol". I guess this comes because it cannot find the definitions for the functions declared in AB.h (probably because it is a different project). Since log is dependent on core, and core will have compiled as of then, I added in $(OutputDir) to Library directories (both core and log build into the same directory) so that it can find core.lib and also added "core.lib" to "Additional Dependencies" under Input tab under Linker (in project properties).

So there you go. Any ideas?


A: 

In addition the log project has $(OutDir) in its "Additional Library Directories" parameter in the Linker part of project settings.

Probably wrong. It should be that dir where "core.lib" resides, the $(OutDir) is where the log will be put.

The class is part of an h file included in AB.h (instance declared in AB.cpp and included as extern in CD.cpp. infFlag is declared in AB.cpp and declared in CD.cpp as extern.

So where are definitions?

adf88
Please refer back to the original question. I have added more details under the original question.
Glenstorm