Jump to content
  • Advertisement
MarcusAseth

Visual studio 2017 - Reference to a Project inside the same Solution

This topic is 454 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

Image below, as you can see my "Init Direct3D" Demo project has a reference to "Direct3D Framework", and yet I cannot #include "D3DApp.h" ... what am I doing wrong? x_x

HOAc0kP.png

Edited by MarcusAseth

Share this post


Link to post
Share on other sites
Advertisement

What's the error you get when you try?

Adding a "reference" to a native project like that isn't necessarily going to set up the include paths correctly; probably the only thing it's doing for you is ensuring the referenced project builds before the referring project. Depending on how you set it up, it may also be automatically linking in the static library output of the referenced project.

Chances are, you need to go into the project settings for your main project and find the include search paths option, and modify it to include a relative path from your project to the directory containing the D3DApp.h source code.

Or, frankly, not bother with a separate project for this and just lump it all into your main project. 

Share this post


Link to post
Share on other sites

I think you where right about the paths, after adding include,reference and source path the intellisense now highlight all my classes and give no errors, but still it won't compile, image below x_x (apologize, my VS is not in english unfortunately)

 

hAt1pyL.png

Share this post


Link to post
Share on other sites

Finally solved x_x

I had to go into my framework project and change it into a Static Library configuration from the project setting, it was set as an application before x_x

Share this post


Link to post
Share on other sites

The static library configuration issue will have fixed those Linker errors (LNK1120).

However the initial problem, of being unable to #include a file, is all down to setting the correct include directories (i.e. in "Directory di inclusione").

These 2 concepts are (unfortunately) quite separate in C++, and with any application using multiple projects you typically have to do both things - make sure the #includes are visible, and make sure the .lib files are linked in to your final project or library correctly.

Share this post


Link to post
Share on other sites
6 minutes ago, Kylotan said:

The static library configuration issue will have fixed those Linker errors (LNK1120).

However the initial problem, of being unable to #include a file, is all down to setting the correct include directories (i.e. in "Directory di inclusione").

These 2 concepts are (unfortunately) quite separate in C++, and with any application using multiple projects you typically have to do both things - make sure the #includes are visible, and make sure the .lib files are linked in to your final project or library correctly.

Yes, I ended up touching the include directories as well even though I didn't mentioned it.

Imo it's kind of ridiculous that something as simple as that requires turning all that knobs and pulling all that levers, but maybe is just me doing it wrong or being spoiled :D

Edited by MarcusAseth

Share this post


Link to post
Share on other sites

This is how C++ works unfortunately. The system that operates the #includes (the preprocessor) is a completely different system to the one that links the compiled code together (the linker).

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!