C++ help

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
zeno60
Posts: 342
Joined: Sun May 21, 2006 2:48 am
Location: NC, USA
Contact:

Post by zeno60 »

Yeah, DevCpp, although technically beta is a great compiler.

But if you are sticking with VC++, I found that the Hello World tutorial contains a tutorial.html file which goes through "Setting up your IDE" and the first section is "If you use Version 6.0 MSVC." Perhaps you could give this a read?

Comes with screenshots, so i'd definetly take a look, but this is what it says:
If you use Version 6.0, select the Menu Extras -> Options. Select the directories tab, and select the 'Include' Item in the combo box. Add the \include directory of the Irrlicht Engine folder to the list of directories. Now the compiler will find the Irrlicht.h header file. We also need the location of irrlicht.lib to be listed, so select the 'Libraries' tab and add the \lib\VisualStudio directory.
But if you decide to go ahead with dev, the Irrlicht/DevCpp Tutorial will get you up and coding in no time. Good luck.
abecks
Posts: 19
Joined: Fri Jul 21, 2006 2:38 am
Location: British Columbia, Canada
Contact:

Post by abecks »

Well actually I cant get anything to compile on Dev C++... to I guess nevermind that one.

The tutorial on the Irrlicht website for DevC++ is extremely out of date, alot of the files are different.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The link error is because you are #including driver.cpp into main.cpp. The symbol is defined in both the main.obj and driver.obj compiled modules, and the linker doesn't know which one to choose.

Normally you would make a driver.h that would have the declaration for you getDriver function. Then driver.cpp would have the definition.

Travis
abecks
Posts: 19
Joined: Fri Jul 21, 2006 2:38 am
Location: British Columbia, Canada
Contact:

Post by abecks »

Think you can give me a hand setting that up? Im thinking I include the header file from main.cpp but I am not sure what to declare inside the header file and what to remove from the other files.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The function declaration goes in a header...

Code: Select all

// driver.h
#ifndef _DRIVER_H_INCLUDED__
#define _DRIVER_H_INCLUDED__
#include <irrlicht.h>
irr::video::E_DRIVER_TYPE askDriver();
#endif // _DRIVER_H_INCLUDED__
The function definition goes in a source file...

Code: Select all

// driver.cpp
#include <driver.h>
irr::video::E_DRIVER_TYPE askDriver() 
{ 
   printf("Please select the driver you want for this example:\n"\
   //...
}
You include the header, and you link the two .obj or .o files that are generated when you compile the source files...

Code: Select all

// main.cpp
#include <irrlicht.h> 
#pragma comment(lib, "Irrlicht.lib") 

#include "driver.h" 

using namespace irr; 

int main() 
{
  //...
}
For something as simple as you are doing, you're sure making it difficult. The simple solution would be to just put the askDriver() function definition just above main().
abecks
Posts: 19
Joined: Fri Jul 21, 2006 2:38 am
Location: British Columbia, Canada
Contact:

Post by abecks »

Thanks for all the help. :) I was just doing it because I know my main.cpp file is going to end up being a mile long, and Im trying to avoid that. Im used to programming in C for MUDs, and the file seperation for all the various tasks. But thank you so much for taking the time to help.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

But it's the very same in C :!: Only difference is that class definitions may contain code in .h files as this only becomes active upon instantiation. But all the rest is really the same.
Post Reply