Combine multiple VS2010 Projects to one .lib file
I want to combine a number of Win32 C-Projects to one .lib file.
OS: Windows XP Sp3 IDE/Comipler: Visual Studio 2010
Now I have one parent project that references all the other projects. But all the functions and globals from the referenced projects are not included or not public, so I get an "unresolved external" error when using the library. Functions within the parent project function correctly.
What can I do?
There are some options for referencing projects but none of them seem to solve my problem
Even开发者_C百科 the /INCLUDE option in link.exe does not affect anything...
Finally I made it by defining the lib command as a make event (Post-Build Event). lib /out:out.lib in1.lib lin2.lib ...
It is poorly portable but fits my requirements Thanks @ Stan
Referencing one project from another simply forces one project to be built as a dependency of another, it does not explicitly link the output of one with another.
You should configure the project dependencies so that the libraries are compiled first, then you must explicitly add the output of those projects (the static library, or the export library if the are DLL projects) to the linker "additional libraries" list.
You can as you suggest combine multiple libraries into one using the Microsoft Library Manager, but that in itself is not a solution to your problem; you will still need to explicitly link the library as above to create an executable - there will just be one of them instead of several - I really cannot see there is much point in that unless the functionality is closely related, and if that were the case why are they not one project in the first instance?
If you are using the command line tools, then the /INCLUDE linker option will not help, that simply forces otherwise unreferenced object code to be included in the link.
精彩评论