Setting up a Visual Studio Project

Get answers to all your basic programming questions. No Ogre questions, please!
Post Reply
thegamechanger
Gnoblar
Posts: 2
Joined: Mon May 13, 2019 7:52 pm

Setting up a Visual Studio Project

Post by thegamechanger » Mon May 13, 2019 8:02 pm

I've been trying to setup a Ogre2 project and am rather confused...

I've managed to build and compile using the guide that's stickied (viewtopic.php?f=10&t=84572) in Ogre2 and in x64 but now i'm confused at how to setup the project. By that i mean i initially setup my own visual studio project and wanted to add ogre to it, however from the guide i've wound up with hundreds of include folders and dll/libs. I'm rather new to setting up a project up on this scale, as usually i would type out every lib and point the Visual Studio project to them, with all the includes etc, but doing that with all these files i've wound up with seems like a pain.

I tried following the wiki guide for older versions of ogre, however i do not use the SDK as i cannot find an Ogre2 SDK (the website seemingly lists old versions of ogre, with ogre2 on bitbucket), with it telling me to set the base SDK directory as OGRE_HOME, but i'm not sure which directory i would use with what i've built as the guide makes me build dependencies + some other VCBuild stuff. I understand there's several solutions from building ogre3d, am i supposed to use them and just add my project to that solution? Again i'm rather new to this, and am just lost at this stage.
0 x

Hrenli
Halfling
Posts: 68
Joined: Tue Jun 14, 2016 12:26 pm
x 12

Re: Setting up a Visual Studio Project

Post by Hrenli » Tue May 14, 2019 11:34 am

Not sure where "hundreds of include folders and libs" are coming from. You don't need all of them to start a project. Most probably just the core lib and a couple of HLMSs would be enough, and even if we speak all libraries it's about ten, not hundred.

Anyway, let's say $OGRE_HOME is an envirionemnt variable pointing to target directory of Ogre's build (which has bin, include, lib and media subfolders with all the files, I think it's usually sdk subfolder of cmake's target folder).

In VC project properties (I mean a fresh separate project here, not Ogre solution):

C/C++->Additional include directories:
$(OGRE_HOME)/include/OGRE
$(OGRE_HOME)/include/OGRE/Hlms/Pbs
$(OGRE_HOME)/include/OGRE/Hlms/Unlit

(or if you use #include <OGRE/subfolder/includefile.h> in your code then just single $(OGRE_HOME)/include should be enough I suppose)


Linker -> General -> Additional Library Directories:
$(OGRE_HOME)/lib/$(Configuration)


Linker -> Input -> Additional dependencies:
OgreMain.lib
OgreHlmsPbs.lib
OgreHlmsPbsUnlit.lib

(or *_d.lib for debug)


Should be enough to start a project Ogre-wise. If you need SDL2 add it in a similar fashion.
0 x

thegamechanger
Gnoblar
Posts: 2
Joined: Mon May 13, 2019 7:52 pm

Re: Setting up a Visual Studio Project

Post by thegamechanger » Sat May 18, 2019 5:41 pm

Alright, i've managed to link everything with correct includes, my issue was with my ogre directory in general, i've got files all over the place for some reason, for instance my OGRE_HOME seemingly is impossible to do with my current structure, as these are my includes:

  • D:\Documents\Code\Ogre3D2.1\OgreMain\include
    D:\Documents\Code\Ogre3D2.1\Samples\2.0\Common\include
    D:\Documents\Code\Ogre3D2.1\Components\Hlms\Pbs\include
    D:\Documents\Code\Ogre3D2.1\Samples\2.0\Tutorials\EmptyProject\include
    D:\Documents\Code\Ogre3D2.1\Components\Hlms\Common\include
    D:\Documents\Code\Ogre3D2.1\Components\Overlay\include
    D:\Documents\Code\Ogre3D2.1\Dependencies\ogredeps\include\SDL2
    D:\Documents\Code\Ogre3D2.1\VCBuild\include

and my libs (Debug - I have ensured the libs are in the following folders and linked on input):
  • $(OGRE_HOME)\lib\$(Configuration)
    D:\Documents\Code\Ogre3D2.1\VCBuild\Dependencies\src\ois\Debug
    D:\Documents\Code\Ogre3D2.1\VCBuild\lib\Debug
I only included the OGRE_HOME linker input because the tutorial says, however i've no idea what libs folder it's referring to, as i have many.

I've been following the wiki tutorial for setting up a project, hence the tutorial includes.

I assumed OGRE_HOME would be my Ogre3D2.1 folder, but setting it didn't work (my project couldn't find any of the headers).

Despite everything linked and included correctly from what i can tell, i've wound up with 30 link errors, all LNK2001, and am not really sure how to fix it.
  • unresolved external symbol public: static int __cdecl Demo::MainEntryPoints::mainAppSingleThreaded(struct HINSTANCE__ *,struct HINSTANCE__ *,char *,int)" (?mainAppSingleThreaded@MainEntryPoints@Demo@@SAHPEAUHINSTANCE__@@0PEADH@Z)

    unresolved external symbol "protected: virtual class Ogre::CompositorWorkspace * __cdecl Demo::GraphicsSystem::setupCompositor(void)" (?setupCompositor@GraphicsSystem@Demo@@MEAAPEAVCompositorWorkspace@Ogre@@XZ)

    unresolved external symbol "public: virtual void __cdecl Demo::TutorialGameState::keyPressed(struct SDL_KeyboardEvent const &)" (?keyPressed@TutorialGameState@Demo@@UEAAXAEBUSDL_KeyboardEvent@@@Z)

    (there is a lot more of course, but i haven't pasted them in)

i'm not sure if this is because i messed up some configuration details? The tutorial i followed from the wiki specifies:

Debugging Configuration Properties
Command:

$(OGRE_HOME)\Bin\$(Configuration)\$(ProjectName).exe

Working Directory:

$(OGRE_HOME)\Bin\$(Configuration)
Build events - Post build events
copy "$(OutDir)\$(TargetFileName)" "$(OGRE_HOME)\Bin\$(Configuration)"
however, i'm not sure because of my directory setup it works as intended? Although i'm not sure if this influences my Linker errors...


Essentially, i'm not sure why i'm getting linker errors, and if my configuration properties work with my directory setup (from following the tutorial i listed in my initial post)
0 x

Post Reply