Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Night Elf

Sharing code between projects in Visual C++

This topic is 5650 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have two projects in a Visual C++ .NET solution: One is my 3d engine and the other is a test program for it. The test program has references to the .H files in the engine project, so it compiles OK. But, if I don''t add all the .CPP files of the engine in the test program, I get linker errors of unresolved external symbols (LNK2001). Well, I added all the .CPPs, but now whenever I make changes in the shared code and build the test project, those shared files get compiled twice: First for the engine project and then for the test program. Is there any way the linker can use the output .OBJs of the engine project build for the test program and not recompile all again? Thanks for any help you can give me.

Share this post


Link to post
Share on other sites
Advertisement
Try building into the same directory (So that the exe files produced by both projects show up in the same spot).

Share this post


Link to post
Share on other sites
Two more options..

Import your 3d engine project workspace into your app workspace, and set the app project dependency to be dependent on the 3d engine.

In the app workspace..
1. Click "Tools->Insert Project Into Workspace" and find your 3d engine workspace.
2. Right click your app project in the class view and "set as active project"
3. Click "Project->Dependencies" to make your app dependent on your 3d engine.

The beauty of this approach is that you can modify the 3d engine code as well as the app, and vc will build as necessary.

Option 2, Make the 3d engine a static library project and make debug and release libs. Then you have to include the headers (not the .cpp's, no building required) and link to the libs in your app project.

- Matt

--[Edit]--
This is assuming all works the same in .Net as it does in good old VC++ 6.0

[edited by - matibee on April 2, 2003 1:10:24 PM]

Share this post


Link to post
Share on other sites
Thanks for your help.

Deyja: I tried your way, and it worked. It''s the way i''m using now. I thought there was a way of doing it whithout having to change any directories, especially since both projects are inside the same Solution...

matibee: Your first approach was what I did first. It seems as the perfect way. But it didn''t work. Maybe I did something wrong... I don''t know. Maybe I''ll use the LIB approach you mention. It''s an interesting way.

Thank you all again.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!