Page 1 of 1

Setting up a Visual Studio Project

Posted: Mon May 13, 2019 8:02 pm
by thegamechanger
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.

Re: Setting up a Visual Studio Project

Posted: Tue May 14, 2019 11:34 am
by Hrenli
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.

Re: Setting up a Visual Studio Project

Posted: Sat May 18, 2019 5:41 pm
by thegamechanger
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)

Re: Setting up a Visual Studio Project

Posted: Sun Jul 12, 2020 10:39 am
by cc9cii
This is rather old, but if you're still trying to get it working then the linker is complaining about code from the demos (which you don't normally want unless you actually intend to use parts of the demo)