Friday, April 8, 2011

XCode: Does my program crash even before reaching main()?

Hi,

I am trying to port a project including both SDL and WxWidgets to MacOS X with XCode 3.1.2. The project is fairly big, but I finally got it to compile successfully. However, it exits immediately after starting it with the message "MyApplication has exited with status 99".

For debugging purposes, I changed my main function to look like this:

int main(int argc, char *argv[])
{
    cout <<"hello world";
    cout <<"and goodbye";
    throw "test";
}

I also added breakpoints to all three main function lines. However, the debugger does still not break and the application still exits right after startup.

The debug console output looks as follows:

(gdb) run [Switching to process 94140 local thread 0x3607] Running…

Debugger stopped. Can't find test.xml !

Debugger stopped. Program exited with status value:99.(gdb)

I do not know what file "can't find test.xml" refers to, why XCode is looking for it in the first place or if it is related to my problem at all.

This is my first XCode project, so I am clueless on how to proceed. Any hints would be greatly appreciated.

Thanks,

Adrian

From stackoverflow
  • You probably don't have the right project settings. Which project template did you choose?

  • SDL uses some hack around your main function. It's likely that your main code is never reached.

    Try breaking on "start" and stepping from there - AFAIK "start" is the entry point to any macho executable.

    What you're seeing looks like your binary exits with error code "99". You may want to look for error code 99 in SDL or WX.

    Later edit: *from SDL site: The header file "SDL_main.h" remaps your main() function to the SDL_main() function with a function macro.*

  • In the end I found that there was a different main() function in a unit test file from a third party library I had included by mistake.

  • And I expect that test.xml is a data file for that unit test, and it may have expected it in a default directory. Project > Edit Active Executable and make sure that the working directory on launch is where the code expects it to be (root, project directory, or executable directory).

    I have to say, though, that I don't recommend learning a new tool by porting source code you're unfamiliar with to it. You are going to have a hard time telling what problems are due to learning Xcode from what problems are due to the odd expectations of SDL/WxWidgets.

    Adrian Grigore : It has been a rough way so far, but I think the worst is almost over. The whole project is based on open source cross-plattform libraries, which is why I am trying to do this myself. As soon as my own code is being executed and the debugger works, I should hopefully be fine.

0 comments:

Post a Comment