Sign in to follow this  

Multiple Project, Single Solution Problem

This topic is 4302 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 2 projects in the same visual studio .net solution (C++), all my code compiles but when one project tries to call a function in another project i get a linker error for undefined symbol. Its the same error as if you #include a file but dont add it to the project. I set the dependency in the solution so that of my 2 projects : MyGameProj_Editor MyGameProj The editor project has a dependency on MyGameProj but this still does not help, the editor project gets a linker error every time it tries to call a function in MyGameProj. Any ideas? Thanks

Share this post


Link to post
Share on other sites
Possibly it isn't looking for header files in the two different folders.

your folder structure is probably:
VSProjects->Project1
VSProjects->Project2

Make sure Project1 has in it's properties that it is to look in the Project 2 folder and vice-versa.

I'm not certain this is your issue, I have limited experience with your situation.

Share this post


Link to post
Share on other sites
The dependency settings only change the order of the build. You need to actually link it. Two solutions: Build the common code into a sperate library and have both projects link to it, or just stick all the files the editor needs in that project too.

Share this post


Link to post
Share on other sites
So if you have two projects in a single solution they cannot reference each other? I MUST compile one to a lib and link to it or merge into one project. That seems rather shit.

Share this post


Link to post
Share on other sites
That's what multiple projects are for. If you can't smoothly divide two components into seperate libraries, they shouldn't be seperate projects. In your case, it seems you might have a problem in how you've structured your projects. You should by rights have at least three projects, one for your game engine, one for your game itself, and one for your game editor, with the game editor and game projects building executables, and the game engine building a static or dynamic library which the other two link to.

You shouldn't share source files between projects. All sharing should be done by including the header files from the other project which you need, and linking to the compiled source files contained in either a dynamic or a static library.

Share this post


Link to post
Share on other sites
jonbell,

I ran into the same problem just recently and got the same advice.
You should link the one project which you are referencing to be built as a lib.
See this thread.

mcp

Share this post


Link to post
Share on other sites
Ok I now compile it to a lib and link to it. The problem i now have is that when i try and step into any of the functions from the lib, vis studio tells me that only assembly code is availabe. How do I get it to debug correctly.

Thanks

Share this post


Link to post
Share on other sites
Quote:
Original post by jonbell
So if you have two projects in a single solution they cannot reference each other? I MUST compile one to a lib and link to it or merge into one project. That seems rather shit.


No, you don't. And yes, that would be rather crappy.

Quote:
Original post by jonbell
Ok I now compile it to a lib and link to it. The problem i now have is that when i try and step into any of the functions from the lib, vis studio tells me that only assembly code is availabe. How do I get it to debug correctly.


How do you compile the project to a lib?
If it is inside the multi-project solution, the code should be visible from within the other projects, that were linking to the lib.

Share this post


Link to post
Share on other sites
I have just selected lib from the project solution and compile both projects in one step. However when i try and step into a function in the lib i get the 'only assembly code available' window. Suggestions?

Share this post


Link to post
Share on other sites
Hm, I guess there's something more you're not teling us.

Making it work requires a few steps:
- creating a solution
- creating a project (or more than one) that is supposed to be a library
- creating a project that is an entry point to the future executable
- setting lib-projects cofiguration to static-lib
- setting exe-project to compile as an exe app[grin]
- set dependencies in solution properties - exe depends on libs
- stay in debug mode (not release) if you want to debug it thoroughly

If you're already doing all of these, the only thing I would suggest is trying to make a new test solution with two projects (exe+lib), as simple as possible. It would help you figure the problem out without any unnecessary complications.

Share this post


Link to post
Share on other sites

This topic is 4302 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this