linking and crashing

Nakate

27-11-2007 18:33:43

Hello everyone. I've been fighting back and forth with this all day now and I'm happy to say I finally got it installed and running. All of the included demos work without any trouble, but I've run into a few problems in getting my own program to work.

I have a previously created project I'm using, so the files and such for it are in a completely different directory if that matters. I looked through the demos to see how things were implemented, including and linking what I thought necessary. I #include "OgreAL.h" at the beginning, and can create a SoundManager without any trouble. The problem is that as soon as I create a sound via OgreAL::Sound *s = soundManager->createSound, the game crashes on startup. Above that, if I try to alter any of the sound's settings, such as setGain or setRelativeToListener, I get linking errors preventing me from running at all.

Using Basic_Demo as a reference, I set the project to include $(OPENAL_SDK)/include, \ogg\include, \vorbis\include, and \OgreAL-Eihort\include. (full pathnames were used, but left out here) I also set the project to link $(OPENAL_SDK)/libs/Win32, and \OgreAL-Eihort\lib\$(ConfigurationName)

The linking errors I get seem to be paired with each sound setting I try to alter, so with setGain and setRelativeToListener implimented I get:
NekoSentai.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall OgreAL::Sound::setRelativeToListener(bool)" (__imp_?setRelativeToListener@Sound@OgreAL@@QAEX_N@Z)
NekoSentai.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __thiscall OgreAL::Sound::setGain(float)" (__imp_?setGain@Sound@OgreAL@@QAEXM@Z)
bin\Debug\NekoSentai.exe : fatal error LNK1120: 2 unresolved externals

The demos work, so I'm sure I'm either doing something wrong or not implementing something. Any help at all would be greatly appreciated, I've hit a bit of a brick wall, myself.

CaseyB

27-11-2007 18:56:24

Have you also put OpenAL.lib and OgreAL.lib in the linker->input settings of the project properties?

Nakate

27-11-2007 23:26:52

That got rid of the linking errors, thank you. I put in OpenAL32.lib and OgreAL_d.lib and it compiled without error. When running, it then gave me a "cannot find OgreAL_d.dll" I tried pointing everything I could at it, but to no avail. I ended up copying the file to my OgreSDK/bin/debug folder where the executable is and it stopped giving that error. Now, though, it still crashes when the game starts.

Simply declaring an object of type OgreAL::Sound doesn't crash it, but giving it a value with soundManager->createSound does. I imagine it only crashes at start because I'm calling it in createScene, but I still have no idea why it's crashing.

I hate to be a bother and keep asking for help. I'd try to solve this on my own, but I don't really have any clues to go by...

CaseyB

28-11-2007 01:36:13

I hate to be a bother and keep asking for help.
No worries! That's what these forums are for!!

As for the dll's the app has to be able to find them, it's going to look in it's own directory and then in the System Path, so either of those place is fine.

For the crash when the game starts, what does the Ogre.log say? Can you tell which line is crashing it?

Nakate

28-11-2007 02:45:18

It doesn't appear to have any useful information in it, but then I guess I'm not one to judge. The only error I see is:

21:40:12: OGRE EXCEPTION(2:InvalidParametersException): Parameter called lightSpecularColor does not exist. in GpuProgramParameters::_findNamedConstantDefinition at e:\projects\ogrecvs\branches\eihort_vc8_clean\ogrenew\ogremain\src\ogregpuprogram.cpp (line 883)
21:40:12: Error at line 29 of deferred_post_minilight.hlsl.program: Invalid param_named_auto attribute - Parameter called lightSpecularColor does not exist.

That seems to be an unrelated issue, though. The last few lines, at least what I'd tend to think are important, seem to be fine:

21:40:16: Parsing script Shadows.overlay
21:40:16: Finished parsing scripts for resource group General
21:40:16: Parsing scripts for resource group Internal
21:40:16: Finished parsing scripts for resource group Internal
21:40:16: Creating viewport on target 'OGRE Render Window', rendering from camera 'SceneCamera', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0
21:40:16: Texture: TaharezLook.tga: Loading 1 faces(PF_A8R8G8B8,256x256x1) with 0 generated mipmaps from Image. Internal format is PF_A8R8G8B8,256x256x1.
21:40:17: Texture: clouds.jpg: Loading 1 faces(PF_R8G8B8,256x256x1) with hardware generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
21:40:17: WARNING: Texture instance 'RttTex' was defined as manually loaded, but no manual loader was provided. This Resource will be lost if it has to be reloaded.
21:40:17: Creating viewport on target 'rtt/2342528', rendering from camera 'RttCam', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0

Edit: I just tested it with the trouble line commented out, and the above error is still there. The next few lines, the ones it doesn't get to are:

21:47:42: *** Initializing OIS ***
21:47:42: *** Initializing OIS ***
21:47:42: Texture: _cegui_ogre_0: Loading 1 faces(PF_A8R8G8B8,256x256x1) with 0 generated mipmaps from Image. Internal format is PF_A8R8G8B8,256x256x1.
21:47:44: Unregistering ResourceManager for type BspLevel
21:47:44: Render Target 'rtt/2345568' Average FPS: 99.4036 Best FPS: 99.4036 Worst FPS: 99.4036

Nakate

28-11-2007 14:15:53

Sorry for the double-post. Seeing as the next thing the program tried to do before crashing was initialize an OIS, I looked at CEGUI.log. When it crashes, the last line displayed in the log is:

28/11/2007 09:02:44 (InfL1) Attempting to create Imageset 'RttImageset' with texture only.

RttImageset being an imageset containing an image I import to display in a StaticImage. I'd prefer not, but I can do without that, so I comment out its initialization, just to see if it gets and further. It does, but now the last error line is:

Attempting to create Imageset 'BlueHighway-12_auto_glyph_images_ ' with texture only.

Which is the skin for the GUI, and something I can't exactly do without. Uncommenting all of it, and commenting out the OgreAL::Sound, then taking a look at the CEGUI.log again, I see:

---- Successfully completed loading of GUI layout from 'title.layout' ----
28/11/2007 09:02:44 (InfL1) Attempting to create Imageset 'RttImageset' with texture only.
28/11/2007 09:02:44 (InfL1) Attempting to create Imageset 'BlueHighway-12_auto_glyph_images_ ' with texture only.
28/11/2007 09:02:46 (InfL1) ---- Begining CEGUI System destruction ----
28/11/2007 09:02:46 (InfL1) ---- Begining cleanup of GUI Scheme system ----

So OgreAL appears to be conflicting with CEGUI, specifically, when creating Imagesets. If not for those, it looks like it might work. I'd try removing the CEGUI to check, but it's so well integrated at this point I'd be here forever just trying to not get errors...

CaseyB

28-11-2007 20:09:22

BlueHighway is actually a font, CEGUI is using it to make a texture so it can blit the characters to the screen. Can you post your resources.cfg because it's looking like it might be having trouble finding things.

As for the ImageSet, that is a CEGUI construct. They don't exist it Ogre or OgreAL so there has to be another problem since they can't really conflict.

Nakate

28-11-2007 21:29:21

Do you mean the resources.cfg for OgreSDK, or OgreAL? Maybe it's erroring because I'm trying to open "Zero Factor - Untitled.ogg" in its default location and it can't find it? The resources for OgreAL is:

# Resource locations to be added to the default path
[General]
FileSystem=../../Media
FileSystem=../../Media/Audio
FileSystem=../../Media/Gui
FileSystem=../../Media/Materials/Scripts
FileSystem=../../Media/Materials/Textures
FileSystem=../../Media/Models
Zip=../../Media/Materials/Textures/cubemapsJS.zip
Zip=../../Media/Materials/bguires.zip

and for OgreSDK is:

# Resource locations to be added to the 'boostrap' path
# This also contains the minimum you need to use the Ogre example framework
[Bootstrap]
Zip=../../media/packs/OgreCore.zip
# Resource locations to be added to the default path
[General]
FileSystem=../../media
FileSystem=../../media/fonts
FileSystem=../../media/materials/programs
FileSystem=../../media/materials/scripts
FileSystem=../../media/materials/textures
FileSystem=../../media/models
FileSystem=../../media/overlays
FileSystem=../../media/particle
FileSystem=../../media/gui
FileSystem=../../media/DeferredShadingMedia
Zip=../../media/packs/cubemap.zip
Zip=../../media/packs/cubemapsJS.zip
Zip=../../media/packs/dragon.zip
Zip=../../media/packs/fresneldemo.zip
Zip=../../media/packs/ogretestmap.zip
Zip=../../media/packs/skybox.zip

CaseyB

29-11-2007 00:46:03

I mean whichever resources.cfg you are loading. The resources.cfg tells Ogre where to find everything, so you should have a piece of code in your app that looks like this: ConfigFile cf;
cf.load("resources.cfg");

// Go through all sections & settings in the file
ConfigFile::SectionIterator seci = cf.getSectionIterator();

String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
ConfigFile::SettingsMultiMap *settings = seci.getNext();
ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
ResourceGroupManager::getSingleton().addResourceLocation(
archName, typeName, secName);
}
}

ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
This is where you tell Ogre about all of the places that it can look for things. If you have multiple resource.cfg files I can guarantee that not all of them are boing loaded so Ogre can find things you are asking for. Try consolidating all of the paths that you actually use into a single resources.cfg and making sure that is the one that gets loaded.

Nakate

29-11-2007 06:16:38

Okay, I think I'm making some progress. I figured out which resources.cfg I was using (as expected it was the OgreSDK one) Seeing as the OgreAL resources.cfg used files in a completely different location, I copied the entire media folder over next to the normal media folder, renaming it to MediaAL. I combined the two resources files (being sure to rename OgreAL's Media references to MediaAL) I also tried this using absolute pathnames to the original files and had the same result. I run it now and get the error:

OGRE EXCEPTION(4:ItemIdentityException): Resource with the name Ogre/Earring already exists. in ResourceManager::add at e:\projects\ogrecvs\branches\eihort_vc8_clean\ogrenew\ogremain\src\ogreresourcemanager.cpp (line 133)

Ogre.log says the same thing. I'm having trouble figuring out where this error is in relation to the previous error, though. Since the error says something already exists, I figured some files in MediaAL may be doubles of already existing files in media. I looked through and deleted what doubles I could find and ran it, but it didn't help any.

CaseyB

29-11-2007 06:32:05

In this case there are two materials called "Ogre/Earring" because Ogre uses it in their demos and I use it in mine. It might be easiest for you just to add in the stuff that you need so you can minimize the places that could cause problems.

Nakate

29-11-2007 13:38:41

Are there any files I need other than the .ogg files I'll be using? I assumed all I need is the .ogg file, but if I delete everything else (both the actual files and from resources.cfg) than I'm right back to it crashing on startup. Ogre.log says:

08:30:35: Creating viewport on target 'OGRE Render Window', rendering from camera 'SceneCamera', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0
08:30:35: Texture: TaharezLook.tga: Loading 1 faces(PF_A8R8G8B8,256x256x1) with 0 generated mipmaps from Image. Internal format is PF_A8R8G8B8,256x256x1.
08:30:36: Texture: clouds.jpg: Loading 1 faces(PF_R8G8B8,256x256x1) with hardware generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
08:30:36: WARNING: Texture instance 'RttTex' was defined as manually loaded, but no manual loader was provided. This Resource will be lost if it has to be reloaded.
08:30:36: Creating viewport on target 'rtt/2376896', rendering from camera 'RttCam', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0

and CEGUI.log says:

29/11/2007 08:30:36 (InfL1) Attempting to create Imageset 'RttImageset' with texture only.

it sounds like the problem is with RttImage, but I haven't changed anything since I started with OgreAL, and never had any problems before...

Nakate

01-12-2007 15:08:05

Well, I tried a few things, but still no luck. In case Ogre didn't like it being buried deep down where I had OgreAL initially, I moved it up next to the Ogre folder. Re-ran the demos, and they still worked, my program still didn't. I copied one of the demos so I wouldn't alter the original, ran it and it worked, then copy-pasted my code in without even importing new files. If there was any difference in the includes and such, this would prove it, but I still got the same error, which tells me the problem is in my code. I messed with resources.cfg, and found it was either ../../Media/Materials/Scripts that caused the new error, so I removed that one line from the compilation, and still get the same old crash on startup. Since it's erroring when trying to deal with "RttImage" I figured since I'm using multiple viewports, and compressing one into an image set to be used in CEGUI, that process may cause some interference. I completely removed the other viewports, scenemanagers, and image set from CEGUI, and I still get the same error.

Everything goes fine until the *** Initializing OIS *** line. It never gets that far, and errors out just after:

Attempting to create Imageset 'BlueHighway-12_auto_glyph_images_ ' with texture only.

So it still looks like there's some conflict with either creating image sets, or the input system. This is a little upsetting that I can't get this to work, since this program really needs music to work right...

Nakate

02-12-2007 15:41:47

I woke up this morning with an epiphany. I knew the problem was in my code, just not where. As it turns out, I created the soundManager, and cleared it out with soundManager(0), but I never actually initialized it. I just added in soundManager = new OgreAL::SoundManager(); and suddenly it all works. Now I really feel like an idiot.

There are still a few bugs to work out, but at this point it's nothing to really worry about. For one, streaming doesn't work quite right. A number of others have had this problem, and I didn't really see a solution. While streaming, if the application has to stop and think for more than a second or so, the music stops, apparently thinking it's hit the end of the file. Also, while streaming, if I wait out the song it doesn't loop when it gets to the end, instead the entire application locks up. It does this in the demos as well, so it doesn't appear to be just my own code. As long as I don't stream everything works fine, so it's not all that important.

Thanks so much for the help CaseyB, everything's up and running as it should now!

CaseyB

02-12-2007 20:36:32

I was aware of the issue with long updates. This is because updating the stream is tied to the Ogre frame rate, so he the frame takes more than 1/4 of a second OpenAL runs out of data and stops. I have a couple ideas of how to work around this but I am not terribly happy with either of them.

I didn't know about the crash on loop while streaming. Thank you for bringing it to my attention, I'll look into it!

stickymango

03-12-2007 15:43:17

I can confirm the lockup when looping a streamed ogg file.

edit: I debugged this and it turns out its getting stuck in an infinite loop in OggSound::bufferData() in the section:

// Read only what was asked for
while(buffer.size() < size)
{
sizeRead = ov_read(&mOggStream, data, mBufferSize, 0, 2, 1, &section);
buffer.insert(buffer.end(), data, data + sizeRead);
}

Basically ov_read() is returning 0 bytes read so the no more data gets added to buffer. I changed it to this and it seems to work:
// Read only what was asked for
while(buffer.size() < size)
{
sizeRead = ov_read(&mOggStream, data, mBufferSize, 0, 2, 1, &section);
if ( sizeRead!=0 ) buffer.insert(buffer.end(), data, data + sizeRead); else break;
}


Hope this helps.

CaseyB

03-12-2007 20:50:17

Yeah, I spotted that last night. The fix will be in the next update too! A lot is going into this one! It will, hopefully be out in the next couple of days.

foxmulder900

04-01-2008 15:30:41


Everything goes fine until the *** Initializing OIS *** line. It never gets that far, and errors out just after:

Attempting to create Imageset 'BlueHighway-12_auto_glyph_images_ ' with texture only.


I am have this exact same problem, did anyone figure out what caused this? I tried it with multiple fonts and it always crashes out before it finishes making the Imageset.