View topic - Spring compile failing (Undefined symbol _main) -- SOLVED



All times are UTC + 1 hour


Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: 26 Jan 2011, 20:44 

Joined: 26 Jan 2011, 20:25
I am attempting to compile Spring via the Spring on Mac OSX tutorial with macports, but I am getting an error when it attempts to compile Spring (everything else seems to have installed fine). I am running Snow Leopard 10.6.5 on a Macbook Pro with a core i7 and an Nvida Geforce GT330. XCode is version 3.2.3.

As the topic says, it is saying that _main is an undefined symbol and suggests _SDL_Main, and then fails. Here is the full log text from main.log: http://pastebin.com/BiLU9iL8

If you could please help me get this up and running, I would really appreciate it. I am going to be working in Spring to create a mod as a research assistant in a project at my college, and need to begin using Widgets and Gadgets as soon as possible. Thank you in advance for any help you provide.


Last edited by Freezerburn on 02 Feb 2011, 04:17, edited 1 time in total.

Top
 Offline Profile  
 
PostPosted: 26 Jan 2011, 23:22 
User avatar

Joined: 30 May 2010, 10:56
Location: France
the SDL issue is a permanent hassle :(
ok, could you try moving your /System/Library/Frameworks/SDL.Framework folder somewhere else (your homedir for instance). I recall seeing conflicts between the stock SDL version and the one installed by MacPorts when building spring.
Personally I deleted the stock SDL framework altogether, but you might want to keep it as a backup just in case.

Let me know if this helped.
daft


Top
 Offline Profile  
 
PostPosted: 26 Jan 2011, 23:27 

Joined: 26 Jan 2011, 20:25
daftalx wrote:
the SDL issue is a permanent hassle :(
ok, could you try moving your /System/Library/Frameworks/SDL.Framework folder somewhere else (your homedir for instance). I recall seeing conflicts between the stock SDL version and the one installed by MacPorts when building spring.
Personally I deleted the stock SDL framework altogether, but you might want to keep it as a backup just in case.

Let me know if this helped.
daft

I do not see SDL.Framework installed. Is it possible that MacPorts did not install it? Should I go get the most recent version of SDL from their website?

EDIT: I uninstalled/reinstalled libsdl several times from MacPorts and it didn't change the outcome. I also manually added SDL.Framework (the most recent one from libsdl.org) to /System/Library/Frameworks and the result was the same.

EDIT/UPDATE: Manually going through the make files, I found where the compiler was looking for the SDL headers (/Library/Frameworks/SDL.Framework/headers), and was able to locate the install of SDL that, assumedly, MacPorts put in place. I removed the one I put into /System/Library/Frameworks as it is not needed, and could only cause conflicts. I am still investigating things and hopefully this issue will be resolved soon.


Top
 Offline Profile  
 
PostPosted: 01 Feb 2011, 18:53 

Joined: 26 Jan 2011, 20:25
UPDATE ON PROGRESS/FINDINGS:
(I apologize for the double post, but I do not know how to indicate that this is still being worked on otherwise. just editing a post will not flag a topic as having new content. sorry! :( )

When searching around the internet for solutions to the problem of the _main symbol being undefined, one person somewhere suggested that the files in question should be pre-processed and the output of that should be looked at. So I added the -save-temps flag to the build.flags file, to get the pre-processed output and poke around in it. Turns out, the main function does not exist anywhere within the processed files, and only SDL_main can be found.

My current theory is that SDLmain.m/h are not being included in the makefile, and are thus not being built, which is why main can't be found. Unfortunately, Objective-C is a type of mysticism to me right now, and I do not know how to make it be included in the makefile and have it built. I will continue investigating this, and will be checking the pre-made XCode projects that SDL provides to see how it is accomplished there.

I will make another post (possibly) when I have more progress to report, or if I manage to fix the problem. If anybody knows how to get SDLmain.m/h included during the build process, please let me know, as that could save me a lot of trouble. I'll be checking back into the forum for a few hours today as I work on this.


Top
 Offline Profile  
 
PostPosted: 01 Feb 2011, 20:16 
User avatar

Joined: 30 May 2010, 10:56
Location: France
Ok, so just to try to make sense out of much enthusiasm and ideas, I'll just give you a hint on a few facts that I've either experienced, learnt or just noticed so far:
  • By removing the stock SDL from Mac OS and keeping only MacPorts's one in opt/local, the install finds it and works fine for the version to date (0.82.1.2). Hence there seems to be no trouble getting spring running via Macports.
  • The _main binding issue is not new to spring on Mac, an is only occurring (in my case) when trying to build the headless system (for some reason indeed SDL has trouble with the binding process.
Are you trying to build from source directly or via Macports? Of the former, which version? you could try to build without headless (I.e. Just make spring) to see I that ever works...

But please do keep reporting ;)


Top
 Offline Profile  
 
PostPosted: 01 Feb 2011, 20:42 

Joined: 26 Jan 2011, 20:25
daftalx wrote:
Ok, so just to try to make sense out of much enthusiasm and ideas, I'll just give you a hint on a few facts that I've either experienced, learnt or just noticed so far:
  • By removing the stock SDL from Mac OS and keeping only MacPorts's one in opt/local, the install finds it and works fine for the version to date (0.82.1.2). Hence there seems to be no trouble getting spring running via Macports.
  • The _main binding issue is not new to spring on Mac, an is only occurring (in my case) when trying to build the headless system (for some reason indeed SDL has trouble with the binding process.
Are you trying to build from source directly or via Macports? Of the former, which version? you could try to build without headless (I.e. Just make spring) to see I that ever works...

But please do keep reporting ;)


Quick update:
Aaaah! You did not mention that the Framework I was looking for would be in /opt/local and not in one of the Library/Frameworks locations. Removing the SDL.Framework got the _main not being found issue resolved. However it does still have a few errors, though I'm not sure what these are yet, as I have not had time to look through the full log thoroughly. Here is a link to the pastebin of the full log: pastebin. If you see anything that could be fixed easily, let me know. I'll take a look through it as soon as possible, and I will keep checking back here.

To answer your other questions, I am using macports (should be the most recent version as I made sure to update it). I made a copy of the entire spring folder with all the source code though and was using that to try and build so that I could modify files if I wanted to. (such as modifying the makefile to output the temporary files) Spring is also the most recent version, as I make sure to sync macports often.


Top
 Offline Profile  
 
PostPosted: 01 Feb 2011, 22:01 

Joined: 26 Jan 2011, 20:25
Yet another update:

Ok, I had to fiddle with things a bit, but I've made some progress. I am no longer getting the _main symbol not found problem, and it is properly finding SDL. (the previous error log I posted indicated that none of the SDL headers were being found)
Here are the steps that I took to get to where I am:
  • Removed SDL.Framework from /System/Library/Frameworks
  • Removed SDL.Framework from ~/Library/Frameworks
  • Changed -I/System/Library/Frameworks/SDL.Framework/headers to -I/opt/local/Library/Frameworks/SDL.Framework/headers in both C_FLAGS and CXX_FLAGS in flags.make in <springpath>/rts/CMakeFiles/spring.dir
  • Added -F/opt/local/Library/Frameworks to C_FLAGS and CXX_FLAGS flags.make in <springpath>/rts/CMakeFiles/spring.dir
My current error log is this: error log
The main thing that I noticed was the error is here:
Code:
:info:build ld: framework not found SDL
:info:build collect2: ld returned 1 exit status

directly after the linking step. Not sure why this is happening.


Top
 Offline Profile  
 
PostPosted: 02 Feb 2011, 04:16 

Joined: 26 Jan 2011, 20:25
FINAL UPDATE! It's working!

Alright, so here are all of the steps that I had to go through to get this working, and all of the things that happened that resulted in errors. Hopefully this information can be used at some point to improve building on Mac or help out another person.

  • First, I used MacPorts to get everything before reaching the _main undefined errors.
  • After that, I discovered that putting the SDL.framework FROM THE MACPORTS INSTALL in /opt/local/Library/Frameworks anywhere but in /System/Library/Frameworks will result in one of two errors: if it is kept in /opt/local/Library/Frameworks then gcc will not be able to find it, if it is kept in /Library/Frameworks then you will get the _main symbol undefined error.
  • After moving SDL.framework to /System/Library/Frameworks was the tedious part. I had to manually go into every links.txt/links.make file and remove "-framework SDL" and add "/opt/local/lib/libSDL-1.2.0.dylib /opt/local/lib/libSDL.a /opt/local/lib/libSDLmain.a" (without the quotes, check your directory to make sure that the files are named correctly as you have a different version of SDL when you read this). If -framework SDL is left in place, the linker will tell you that it cannot be found. I am not sure what happens without adding the libs to the linker, but it will PROBABLY fail, as I'm sure it needs those to work.
  • Run the "sudo ports install springrts" command from the tutorial (no quotes) again, and if everything was done properly, (and there aren't any other weird errors) it SHOULD build and install fine.
  • As a side note, the actual binary is stored inside /opt/local/var/macports/software/springrts/<version number>/opt/local/bin/ (version as of posting is 0.81.2.1_0). You can run spring just by typing "spring" (no quotes) into any terminal.

Thank you for your help daftalx, I would not have figured this out without your posts :D I hope this information will be useful for everyone here as well.


Top
 Offline Profile  
 
PostPosted: 03 Feb 2011, 14:54 
User avatar

Joined: 30 May 2010, 10:56
Location: France
no pb. :-)

btw, if you feel like having time to tickle the latest official release, feel free to give it a go. I'd gladly use a little help here, as my days and nights are a bit dense at the moment. Will open a thread about my progress soon (hopefully this week).

daft


Top
 Offline Profile  
 
PostPosted: 08 Feb 2011, 21:19 

Joined: 26 Jan 2011, 20:25
daftalx wrote:
no pb. :-)

btw, if you feel like having time to tickle the latest official release, feel free to give it a go. I'd gladly use a little help here, as my days and nights are a bit dense at the moment. Will open a thread about my progress soon (hopefully this week).

daft

Yeah I understand the feeling of being busy. Unfortunately I doubt I will be able to help with getting it more Mac friendly, as I will barely have time for my current work load. Maybe sometime in the summer, when this semester is over...


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.