Reputation: 1852
I have a .cpp and a header in another project that I'd like to link to. I've added the header and placed the .lib file in the Linker/ Input/ Additional Dependencies but I get an unresolved external. From what I read this could be because the lib is part of a dll project. All I want to do is link to the obj of that class, but it doesn't appear to want to let me do that. I can link to another lib file in the same directory so it's not a path issue.
I could probably export the class as part of a DLL, but I don't want the worry of memory leaks as I would have to pass a pointer to the object, whereas if I link directly, I don't have to worry about it at all.
How's the best way to diagnose if I can link to the lib file.
Is there any particular reason VS2010 won't let me go directly to the obj file? This would seem to be the easiest option.
Thanks, James
Upvotes: 2
Views: 2233
Reputation: 2773
You can create a new configuration where the project you link to is a static library instead of a DLL.
Add the project as a dependency of your new project and alter the configuration manager settings so it uses the static library configuration instead of the DLL configuration.
Upvotes: 1
Reputation: 3030
If you want to link directly to the .obj file of the class, you will have to add the .cpp file of the class to your project. This, however easier it may seem, is not a solution to your problem, only a workaround. I cannot think of how to solve the problem, though.
Upvotes: 0