Google

_SDL_main-runtime error using xcode

Problems building or running the engine, queries about how to use features etc.

Moderators: OGRE Team, Moderators

_SDL_main-runtime error using xcode

Postby hedefalk » Sun Feb 13, 2005 7:28 pm

I put this question in a new topic since I don't think it fits in the old one anymore...

So, I've gotten so far as to have built the Ogre framework in xcode and been able to run most of the examples as well.

I've been trying to make my own project from scratch. I followed the instructions in README_MacOSX.txt and did some comparing to the samples project file.

I succeed in building my project, but when running it i get this error:

ZeroLink: unknown symbol '_SDL_main'

It's actually inside the main() in SDLMain.m the error occures. I haven't really understood how the whole SDL thing with two main-functions works, but does the "applicationDidFinishLaunching" mean that everything went fine, just that my app doesn't really do anything? But, still, the examples doesn't exit with a signal 6 (SIGABRT)...

Here's the trace from the debugger:

#0 0x900429ac in kill
#1 0x9009eb1c in abort
#2 0x7fdf0cb8 in undefinedHandler
#3 0x8fe0a398 in __dyld_check_and_report_undefineds
#4 0x8fe11690 in __dyld_link_in_need_modules
#5 0x8fe1124c in __dyld_bind_lazy_symbol_reference
#6 0x8fe01340 in __dyld_stub_binding_helper_interface
#7 0x0007e704 in -[SDLMain applicationDidFinishLaunching:] at SDLMain.m:196
#8 0x909f7184 in _nsnote_callback
#9 0x901aa5c0 in __CFXNotificationPost
#10 0x901aefd0 in _CFXNotificationPostNotification
#11 0x909f4fd0 in -[NSNotificationCenter postNotificationName:object:userInfo:]
#12 0x92ee3e70 in -[NSApplication _postDidFinishNotification]
#13 0x92ee3d5c in -[NSApplication _sendFinishLaunchingNotification]
#14 0x92ee3f8c in -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:]
#15 0x90a4a544 in -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:]
#16 0x90a50c6c in _NSAppleEventManagerGenericHandler
#17 0x91674a10 in AEPutParamDesc
#18 0x91677858 in AECreateList
#19 0x91674c50 in aeProcessAppleEvent
#20 0x928c4338 in AEProcessAppleEvent
#21 0x92dd301c in _DPSNextEvent
#22 0x92de98c8 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
#23 0x92dfdc30 in -[NSApplication run]
#24 0x0007e650 in CustomApplicationMain at SDLMain.m:174
#25 0x0007ea70 in main at SDLMain.m:275
hedefalk
Newcomer
 
Posts: 17
Joined: Thu Feb 10, 2005 8:00 pm

Postby hedefalk » Sun Feb 13, 2005 7:55 pm

When building without ZeroLink, I see that it is the temas's home directory error again. GAH! WHERE do they get this path? And how come it doesn't find _SDL_main just because it can't find the zzip framework?



ld: Undefined symbols:
_SDL_main
_zzip_dir_close referenced from Ogre expected to be defined in /Users/temas/Library/Frameworks/zzip.framework/Versions/A/zzip
_zzip_dir_open referenced from Ogre expected to be defined in /Users/temas/Library/Frameworks/zzip.framework/Versions/A/zzip
_zzip_dir_read referenced from Ogre expected to be defined in /Users/temas/Library/Frameworks/zzip.framework/Versions/A/zzip
_zzip_dir_stat referenced from Ogre expected to be defined in /Users/temas/Library/Frameworks/zzip.framework/Versions/A/zzip
_zzip_error referenced from Ogre expected to be defined in /Users/temas/Library/Frameworks/zzip.framework/Versions/A/zzip
_zzip_file_close referenced from Ogre expected to be defined in /Users/temas/Library/Frameworks/zzip.framework/Versions/A/zzip
_zzip_file_open referenced from Ogre expected to be defined in /Users/temas/Library/Frameworks/zzip.framework/Versions/A/zzip
_zzip_file_read referenced from Ogre expected to be defined in /Users/temas/Library/Frameworks/zzip.framework/Versions/A/zzip
_zzip_seek referenced from Ogre expected to be defined in /Users/temas/Library/Frameworks/zzip.framework/Versions/A/zzip
_zzip_tell referenced from Ogre expected to be defined in /Users/temas/Library/Frameworks/zzip.framework/Versions/A/zzip
hedefalk
Newcomer
 
Posts: 17
Joined: Thu Feb 10, 2005 8:00 pm

Postby hedefalk » Sun Feb 13, 2005 8:03 pm

Hm. Maybe it seems that I just post here without really trying hard myself, but I assure that this is not the case. It's just that for some reason I realize things just after writing here...

I just noticed that I didn't have the zzip framework in my project since I tried to immitate the samples project where it wasn't present. Adding zzip makes it just boil down to:

ld: Undefined symbols:
_SDL_main

It seems I will never understand this xcode ide.
hedefalk
Newcomer
 
Posts: 17
Joined: Thu Feb 10, 2005 8:00 pm

Postby Mecha » Sun Feb 13, 2005 10:32 pm

zzip is only required to be in the Ogre framework itself. The Samples don't have it because their actual code isn't using zzip.

What I did to set up a generic project(using the Camera Track code, and assuming that you built the framework successfully and got the Samples to build and run):
1. Make a new Cocoa Application project. I then defined a "CameraT" target and copied the CameraTrack.cpp file into its group.
2. Delete ALL generated files--any .m files, any nibs, and the .pch file. Remove the Prefix Header entry on your target's Info panel, which is set to AppKit by default.
3. Copy files as the readme tells you. I set up groups so that a "Common" group holds the Example* and SDLMain files, just like the Samples project. Note that XCode may think that zip files are libraries, so check your target and make sure they are in "Bundle Resources".
4. Add SDL and Ogre frameworks.
4a. The generated Ogre.framework doesn't have a few of the Ogre header files(like OgreArchive.h), but they are still present in the source directory. Make sure your project has header search paths to both the framework headers directory, and the OgreMain headers.
5. If you've compiled the Ogre framework for Development(which is the default), you need to pay attention to step 7 or suffer ZeroLink runtime errors. Add the -DDEBUG flags to your target's Other C Flags/Other C++ Flags.
6. Copy plugins.cfg/resources.cfg(making sure to change the paths). Note that the GuiElements plugin isn't built in this release, so disable it in your plugins file.

You should now be able to build and run the project.
Mecha
Newcomer
 
Posts: 11
Joined: Sun Feb 22, 2004 10:20 pm
Location: Greater Pacific Northwest

Postby hedefalk » Mon Feb 14, 2005 6:18 am

Ah! That helped somewhat! I realized SDLmain.m was put in Sources instead of Bundled Resources.

Now I get this runtime error instead:


Testing libpng version 1.2.5
with zlib version 1.1.4

libpng version 1.2.5 - October 3, 2002
Copyright (c) 1998-2002 Glenn Randers-Pehrson
Copyright (c) 1996-1997 Andreas Dilger
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
library (10205): libpng version 1.2.5 - October 3, 2002 (header)
pngtest (10205): libpng version 1.2.5 - October 3, 2002 (header)
sizeof(png_struct)=1312, sizeof(png_info)=288
Testing pngtest.png:Could not find input file pngtest.png
Testing pngtest.png: FAIL
Testing pngtest.png:Could not find input file pngtest.png
Testing pngtest.png: FAIL
Testing pngtest.png:Could not find input file pngtest.png
FAIL
Current memory allocation: 0 bytes
Maximum memory allocation: 0 bytes
Total memory allocation: 0 bytes
Number of allocations: 0
libpng FAILS test

Executable “Tutorial1” has exited with status 1.
hedefalk
Newcomer
 
Posts: 17
Joined: Thu Feb 10, 2005 8:00 pm

Postby Mecha » Mon Feb 14, 2005 8:22 am

I don't know which tutorial you are using, does the tutorial directly use libpng somehow? Otherwise, I'd say that you should check that you are using the 1.0RC1 zipfile of frameworks when you compile the framework.
Mecha
Newcomer
 
Posts: 11
Joined: Sun Feb 22, 2004 10:20 pm
Location: Greater Pacific Northwest

Postby Dr Dave » Mon Feb 14, 2005 11:23 am

This error has been covered here before. I think the answer is that you have to include SDLmain.h (can't remember the exact file name) from your source file that contains your main function. If you don't include that header in that particular file then it will try to execute SDL's main, or libpng's main.
Dr Dave
Newcomer
 
Posts: 9
Joined: Wed Jan 26, 2005 3:28 pm

Postby hedefalk » Mon Feb 14, 2005 1:23 pm

Mecha, what zip-files are you reffering to in step 3?
hedefalk
Newcomer
 
Posts: 17
Joined: Thu Feb 10, 2005 8:00 pm

Postby hedefalk » Mon Feb 14, 2005 2:04 pm

Oh, I forgot to answer the question: No, the tutorial is not using libpng. It was the Humble Beginnings tutorial.

Now I tried to do exactly like you're suggesting, Mecha, using CameraTrack.cpp. If I don't

#include "STDMain.h"

I can compile and link but get the same old

Testing libpng version 1.2.5
with zlib version 1.1.4

libpng version 1.2.5 - October 3, 2002
Copyright (c) 1998-2002 Glenn Randers-Pehrson
Copyright (c) 1996-1997 Andreas Dilger
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
library (10205): libpng version 1.2.5 - October 3, 2002 (header)
pngtest (10205): libpng version 1.2.5 - October 3, 2002 (header)
sizeof(png_struct)=1312, sizeof(png_info)=288
Testing pngtest.png:Could not find input file pngtest.png
Testing pngtest.png: FAIL
Testing pngtest.png:Could not find input file pngtest.png
Testing pngtest.png: FAIL
Testing pngtest.png:Could not find input file pngtest.png
FAIL
Current memory allocation: 0 bytes
Maximum memory allocation: 0 bytes
Total memory allocation: 0 bytes
Number of allocations: 0
libpng FAILS test

Executable “CameraT” has exited with status 1.


runtime error. If I do include it, I get 2050 compile errors, most in Foundation framework:


Native Build of Target "CameraT"

CompileC build/Space.build/CameraT.build/Objects-normal/ppc/CameraTrack.o CameraTrack.cpp normal ppc c++ com.apple.compilers.gcc.3_3
cd /Users/viktor/Documents/Ogre/Space
/usr/bin/gcc-3.3 -x c++ -arch ppc -pipe -Wno-trigraphs -fasm-blocks -fpascal-strings -g -O0 -mtune=G4 -Wmost -Wno-four-char-constants -Wno-unknown-pragmas -fmessage-length=0 -ffix-and-continue -fzero-link -F/Users/viktor/Documents/Ogre/Space/build -F/System/Library/Frameworks -F/Users/viktor/Library/Frameworks -F/Library/Frameworks -I/Users/viktor/Documents/Ogre/Space/build/include -I/Developer/ogrenew/OgreMain/include -I/Users/viktor/Library/Frameworks/Ogre.frameworks/Headers -I/Users/viktor/Documents/Ogre/Space/build/Space.build/CameraT.build/DerivedSources -Wp,-header-mapfile,/Users/viktor/Documents/Ogre/Space/build/Space.build/CameraT.build/CameraT.hmap -DDEBUG -c /Users/viktor/Documents/Ogre/Space/CameraTrack.cpp -o /Users/viktor/Documents/Ogre/Space/build/Space.build/CameraT.build/Objects-normal/ppc/CameraTrack.o
In file included from /System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:9,
from /System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h:12,
from /Users/viktor/Documents/Ogre/Space/SDLMain.h:8,
from /Users/viktor/Documents/Ogre/Space/CameraTrack.cpp:22:
/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:56: error: parse error before `@' token
/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:58: error: syntax error before `*' token
/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:59: error: `NSString' was not declared in this scope
/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:59: error: `aSelectorName' was not declared in this scope


Thanks for your patiance with me, guys...
hedefalk
Newcomer
 
Posts: 17
Joined: Thu Feb 10, 2005 8:00 pm

Postby hedefalk » Mon Feb 14, 2005 4:14 pm

I really feel like a stupid kid here. If I put SDLMain.m in Sources instead of Bundled Resources, which I now realize is the right thing to do, and exclude the #include "SDLMain.h" in my main-file, I can compile and even exit normally when I run. But the app didn't find the resources.cfg and plugins.cfg files so I had to put them in the same folder as the app. I just read that this happens for deployment builds so I guess that's what I have. Anyway, it finally works. Thanks for all the help.
hedefalk
Newcomer
 
Posts: 17
Joined: Thu Feb 10, 2005 8:00 pm

Postby hedefalk » Mon Feb 14, 2005 4:18 pm

No, as I thought, it was development build style... But the app till wont find the cfg-files unless I copy them to the same folder.
hedefalk
Newcomer
 
Posts: 17
Joined: Thu Feb 10, 2005 8:00 pm

Postby hedefalk » Tue Feb 15, 2005 4:42 am

This is really starting to make me mad. After finally been able to compile and run the CameraT.cpp using a new project, I have been trying again to do the Humble Beginnings tutorial, using the same project and setting up another target. I have really made the EXACT same thing, but now it doesn't work.

I'm back to that if I don't
#include "SDLMain.h" I can compile but get

[Session started at 2005-02-15 11:40:31 +0800.]
ZeroLink: unknown symbol '_SDL_main'
Tutorial1 has exited due to signal 6 (SIGABRT).

runtime error. And If I do include it I get the 2050 compile errors just like before...
hedefalk
Newcomer
 
Posts: 17
Joined: Thu Feb 10, 2005 8:00 pm

Postby Mecha » Tue Feb 15, 2005 6:49 am

The 2050 errors were covered in step 2--delete the pch file, and remove the Prefix Header entry in your target.

The zipfile I'm talking about is the 3rd-party Frameworks zipfile for OSX, right on the downloads page. :?
Mecha
Newcomer
 
Posts: 11
Joined: Sun Feb 22, 2004 10:20 pm
Location: Greater Pacific Northwest

Postby hedefalk » Tue Feb 15, 2005 12:08 pm

Mecha:

I have removed the pch file and the Prefix Header entry in my target and I still get these 2050 errors.

And I don't understand what you mean with the zipfile.

The 3rd Party Frameworks for OSX zip-file only contains zzip.framework which as you just wrote is only needed to build the Ogre.framework, right?
hedefalk
Newcomer
 
Posts: 17
Joined: Thu Feb 10, 2005 8:00 pm

Postby temas » Tue Feb 15, 2005 4:57 pm

if you notice in the Ogre samples I had to put

Code: Select all
extern "C" {

int main(int argc, char* argv[])
{...}

}


That was to get around that odd linking problem.
User avatar
temas
OGRE Team Member
OGRE Team Member
 
Posts: 1185
Joined: Sun Oct 06, 2002 11:19 pm
Location: The Woodlands, TX

Postby hedefalk » Tue Feb 15, 2005 6:26 pm

Heureka!

It works! Thanks alot. Finally I can start looking into the code (which I of course should already have done, considering what caused my problem).

I just wanna point out that it only works for me if I DO NOT include SDLMain.h in my code if someone has the same problem. Otherwise I still get the 2050 compile errors. I have no idea why it's like this since you guys have told me I SHOULD include this to make it work.

Again, thanks for your patiance with me!
hedefalk
Newcomer
 
Posts: 17
Joined: Thu Feb 10, 2005 8:00 pm

A Patch for README_OSX.txt that improves the instructions

Postby eyevee99 » Tue Mar 22, 2005 2:14 pm

Here is a patch for the OSX ReadMe file that incorporates all the bits and pieces dotted throughout the forum into the instructions. Hopefully no one else will need to go through the pain. ;)

Code: Select all
? patch.txt
Index: Docs/README_MacOSX.txt
===================================================================
RCS file: /cvsroot/ogre/ogrenew/Docs/README_MacOSX.txt,v
retrieving revision 1.8.6.1
diff -u -r1.8.6.1 README_MacOSX.txt
--- Docs/README_MacOSX.txt   22 Feb 2005 04:35:03 -0000   1.8.6.1
+++ Docs/README_MacOSX.txt   22 Mar 2005 13:07:07 -0000
@@ -35,30 +35,44 @@
---------------------------------------------
1)  Build the Ogre.framework
2)  Create a new project, using the Cocoa Application template
-3)  Delete the generated files.
-4)  Add SDLMain.m and SDLMain.h to your project. These are in the
+3)  Delete the ALL the generated files from within XCode. Delete *.m, *.pch, *.nib
+4)  In you build target's Info screen (cmb+i while the target is highlighed), remove the Prefix Header
+5)  Add SDLMain.m and SDLMain.h to your project. These are in the
     ogrenew/Mac/XCode/Classes folder. You will  probably want to copy
     these items so you may change them without affecting the originals.
-5)  Add the SDL and Ogre frameworks to your project.
+6)  Wrap your main function with:
+   
+    #ifdef __cplusplus
+    extern "C"
+    {
+    #endif
+
+    int main (...)
+   
+    #ifdef __cplusplus
+    }
+    #endif
+
+7)  Add the SDL and Ogre frameworks to your project in "Linked Frameworks". 
     You can have these copied into your application when it is built, and then
     not have your users install these themselves.  For information on how to do
     this refer to the XCode documentation.
-6)  Create the required plugins.cfg and resources.cfg files.
+8)  Create the required plugins.cfg and resources.cfg files.
     You may start from the examples of these files in
     ogrenew/Mac/XCode/Samples.  The plugins.cfg can probably be left as is,
     but you will want to remove the entries from resources.cfg, as they refer
     to the Sample resources. The entries in resources.cfg are relative to the
     'Resources' group in your application. By default, it and all of its
     sub-directories are searched by Ogre.
-7)  If you have built the Ogre framework with the Development build
+9)  If you have built the Ogre framework with the Development build
     style (the default), you will have to edit the Development build
     style of your Application to use the Ogre debug headers. To do this,
     set your 'OTHER_CFLAGS' and 'OTHER_CXXFLAGS' to '-DDEBUG'.
-8)  You are now ready to add your own resources and source files.
+10) You are now ready to add your own resources and source files.
     Take a look at the Samples and the documentation on the ogre
     website for guidance. You should be able to replicate the Samples
     by adding all of the source files from the Sample to your application,
     and adding the files from Media that it uses to your Resources.
-9)  When shipping your newly built .app You should be able to put the OGRE and
+11) When shipping your newly built .app You should be able to put the OGRE and
     other frameworks in .app/Contents/Frameworks and they will be found and
     used at runtime.

Cheers
eyevee99
Regular
 
Posts: 137
Joined: Tue Jul 22, 2003 11:28 am

Postby 3dmacuser » Tue Mar 22, 2005 8:21 pm

Hi, I'm trying to get Ogre running, following the directions above.

It compiles, but when I try to run, I it crashes, with this log:

Creating resource group General
Registering ResourceManager for type Material
Registering ResourceManager for type Mesh
Registering ResourceManager for type Skeleton
Loading library OgrePlatform.bundle
OverlayElementFactory for type Panel registered.
OverlayElementFactory for type BorderPanel registered.
OverlayElementFactory for type TextArea registered.
Registering ResourceManager for type Font
ArchiveFactory for archive type FileSystem registered.
ArchiveFactory for archive type Zip registered.
DevIL version: Developer's Image Library (DevIL) 1.6.5
DevIL image formats: bmp dib cut dcx dds gif ico cur jpg jpe jpeg lif mdl mng jng pcx pic pix png pbm pgm pnm ppm psd pdd psp pxr sgi bw rgb rgba tga vda icb vst tif tiff wal xpm raw
Registering ResourceManager for type HighLevelGpuProgram
Loading library /usr/local/lib/OGRERenderSystem_GL.so
An exception has occured: An exception has been thrown!

-----------------------------------
Details:
-----------------------------------
Error #: 9
Function: DynLib::load
Description: Could not load dynamic library /usr/local/lib/OGRERenderSystem_GL.so. System Error: Unknown Error.
File: /Users/work/Projects/ogrenew/OgreMain/src/OgreDynLib.cpp
Line: 82
Stack unwinding: DynLib::load(..) <- <<beginning of stack>>
Executable “OgreTest” has exited with status 0.


This is running on Panther 10.3.8 with XCode 1.5, on a powerbook 12"

I compiled the 1.0 ogre release, and put the framework in my /Library/Frameworks directory, and added it to my project.

For a test source, I'm using Bezier.cpp

Any ideas?
3dmacuser
Regular
 
Posts: 128
Joined: Tue Mar 22, 2005 8:18 pm

Postby eyevee99 » Tue Mar 22, 2005 11:33 pm

I haven't quite worked out the "why" yet on that one, but I found that if I commented out the "PluginFolder" entry in plugins.cfg then I no longer got this error.

My "cfg" files and media etc are in the same directory/folder as the built application.
Cheers
eyevee99
Regular
 
Posts: 137
Joined: Tue Jul 22, 2003 11:28 am

Postby temas » Wed Mar 23, 2005 3:28 am

Odd, it should be completely ignoring PluginFolder on this platform. I'll make a note to check that again.
User avatar
temas
OGRE Team Member
OGRE Team Member
 
Posts: 1185
Joined: Sun Oct 06, 2002 11:19 pm
Location: The Woodlands, TX


Return to Help

Who is online

Users browsing this forum: betajaen, iWillSpeak, Jubei and 7 guests