On 2007-12-15, at 23:21:23, Adam wrote:
When modifying an OpenGL program that I found on nehe.gamedev.net, for some reason I get the following error code:
/usr/bin/ld: Undefined symbols:
_main
collect2: ld returned 1 exit status
...and yet I have the main function defined! Sorry if this is a stupid question or something, but my head hurts pretty bad right now from trying to figure this out... I bet it's something simple, but I can't figure it out.
I bet it's because your main function is in a C++ source and isn't declared extern "C".
Even when I declared main() as extern "C", it had the errors.
I didn't have this problem until a short while ago, when I made some minor changes to the program, and now I can't get any of my Xcode projects to work - they all have this error message now. I didn't change anything in the Xcode preferences, either. Any ideas?
All help is appreciated and thanks in advance.
Chances are this is a variant of the SDL OpenGL App project and you tried to adapt it to your needs by changing a few names here and there and thinking you could bypass the layer of 'main' shenanigans SDL uses to work in a Cocoa app.
That's not going to work because at minimum you have to coordinate the product and executable name change with the items in the Info.plist of the target so that the resulting application has Info.plist and InfoPlist.strings files with a valid ExecutableName/BundleName values.
Then there's the 'main' stuff. I wouldn't recommend anything other than finding the 'main' in the atlantis files and snapping your code in there for this type of project.
OTOH, there is another example Xcode application in one or another of the SDL distributions which has many targets. One of those might be better for your purposes if you don't need the Cocoa.
HTH,
Philip Aker