Arggg SDL _main undefined. Please help!

Member
Posts: 52
Joined: 2007.06
Post: #1
Background

Full working application developed under linux with opengl, cg, sdl

Just switched to a mac book pro, been waiting for an update in hardware and it came:-)

Now i downloaded the xcode development kit, which i was told will load most lib's i need.

Im using g++ compiler and a makefile for builds,

I downloaded the cg, sdl and sld_image frameworks and they are all installed in the root library/frameworks section

Ive downloaded the runtime and the devel-extras from the sdl site. I dont really see much in the sdl_devel-extras besides those sdlmain.h and sdlmain.m files. I attempted to include them in my project directory and in my main class with #include "SDLMain.h"
#include "SDLMain.m"

But i get a crazy amount of errors,

Here is a copy of my makefile and the error i get,

############
MACHINE= $(shell uname -s)
########################################################
# LIBRARY/FRAMEWORK INCLUDES -lXi-lXmu
#cgc -profile arbfp1 -o shader.pso shader.cg
#cgc -profile arbvp1 -o temp.vp test.cg
#glxinfo |grep programs
########################################################

ifeq ($(MACHINE),Darwin)
OPENGL_INC= -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
OPENGL_LIB= -framework OpenGL -framework GLUT -framework SDL_image -framework SDL -framework Cg
SDL_INC= #`sdl-config --cflags`
SDL_LIB= #`sdl-config --libs`

else
OPENGL_INC= -FOpenGL -FGLUT -FCg
OPENGL_LIB= -framework OpenGL -framework GLUT -framework SDL_image -framework SDL -framework Cg
SDL_INC= #'sdl-config --cflags'
SDL_LIB= #'sdl-config --libs'
endif
CC = g++
# libraries required to compile for the labs
INCLUDE=$(SDL_INC) $(OPENGL_INC)
LIBRARIES = -lm $(SDL_LIB) $(OPENGL_LIB)
ALLOFEM = $(INCLUDE) $(LIBRARIES)
########################################################
# COMPILE FLAGS & OBJECT LIST
########################################################
DEBUG =
TOPS = galaxy.o SolidEntity.o
SOLID_OBJS = Stars.o Planets.o Earth.o Mars.o Venus.o Mercury.o Jupiter.o Saturn.o Uranus.o Neptune.o Pluto.o
UTILITY = Vec3.o Frustum.o FileReader.o Matrix4x4.o Camera.o Texture.o Shaders.o Utility.o
OBJECTS = $(TOPS) $(UTILITY) $(SOLID_OBJS)
EXECUTABLE = galaxy
########################################################
# DEPENDENCIES -Wall warnings
########################################################
all: galaxy

run: all
./galaxy 1

big: all
./galaxy 2

stereo: all
./galaxy 3

debug: all
gdb ./galaxy

%.o: %.cpp %.h
$(CC) -c -O3 -o $@ $< $(INCLUDE)

$(EXECUTABLE): $(OBJECTS)
$(CC) -O3 -o $(EXECUTABLE) $(OBJECTS) $(LIBRARIES)

tar:
tar -czvf proj497.tgz *.cpp *.h *.txt makefile

clean:
rm -rf *.o galaxy proj497.tgz

make
g++ -c -O3 -o galaxy.o galaxy.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -c -O3 -o SolidEntity.o SolidEntity.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -c -O3 -o Vec3.o Vec3.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -c -O3 -o Frustum.o Frustum.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -c -O3 -o FileReader.o FileReader.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -c -O3 -o Matrix4x4.o Matrix4x4.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -c -O3 -o Camera.o Camera.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -c -O3 -o Texture.o Texture.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -c -O3 -o Shaders.o Shaders.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -c -O3 -o Utility.o Utility.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -c -O3 -o Stars.o Stars.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -c -O3 -o Planets.o Planets.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -c -O3 -o Earth.o Earth.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -c -O3 -o Mars.o Mars.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -c -O3 -o Venus.o Venus.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -c -O3 -o Mercury.o Mercury.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -c -O3 -o Jupiter.o Jupiter.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -c -O3 -o Saturn.o Saturn.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -c -O3 -o Uranus.o Uranus.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -c -O3 -o Neptune.o Neptune.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -c -O3 -o Pluto.o Pluto.cpp -FOpenGL -FGLUT -FCg -FSDL_image -FSDL
g++ -O3 -o galaxy galaxy.o SolidEntity.o Vec3.o Frustum.o FileReader.o Matrix4x4.o Camera.o Texture.o Shaders.o Utility.o Stars.o Planets.o Earth.o Mars.o Venus.o Mercury.o Jupiter.o Saturn.o Uranus.o Neptune.o Pluto.o -lm -framework OpenGL -framework GLUT -framework SDL_image -framework SDL -framework Cg
/usr/bin/ld: Undefined symbols:
_main
collect2: ld returned 1 exit status
make: *** [galaxy] Error 1
Quote this message in a reply
Moderator
Posts: 771
Joined: 2003.04
Member
Posts: 52
Joined: 2007.06
Post: #3
really appreciate the help,

Ive been to the page already, i include the two files with zero luck. They give me a crazy amount of errors if i include SDLMain.m and SDLMain.h

I grabbed the SDL-devel-extra and it has a folder called sdlmain with three internal folders.
Cocoamenus
CustomView
Nibless

They all contain SDLMain.m/h files, which ones am i suppose to use?

Really new to mac, got most of my programs working except for this one.

I also noticed i posted this in the wrong forum location, sorry about that!

Steven
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #4
You should #include SDL.h, and you should have SDLMain.h visible by your project, and compile SLDMain.m with your project. Your main function should follow the prototype int main(int argc, char **argv) as well.
Quote this message in a reply
Member
Posts: 52
Joined: 2007.06
Post: #5
Question do i need to install the sdl, sdl_image and Cg frameworks in the system/library/frameworks section of the disk?

Cause right now they are only in the library/frameworks section, they are not present int he system/library/framework area.

Thanks for the help
Quote this message in a reply
Member
Posts: 52
Joined: 2007.06
Post: #6
No problem here is my main from galaxy,

#include <SDL/SDL.h>
#include "SDLMain.m"
#include "SDLMain.h"
...

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

I get a lot of errors doing this.
Quote this message in a reply
Member
Posts: 52
Joined: 2007.06
Post: #7
I also tried the unix install as per instructions on sdl and have no luck even with that install. I had everything working in the first 8 hours of getting my mbp except for this, now 5 days later im still fighting a loosing battle and i have a big demo for another department on thursday.


Not really sure what else to try,

Steven
Quote this message in a reply
Member
Posts: 52
Joined: 2007.06
Post: #8
Got the unix install done as per sdl instructions,

Slight problem with the build file for sdl,

changed
-I/usr/X11R6/include -> -I/Developer/SDKs/MacOSX10.4U.sdk/usr/X11R6/include

Now will see if she works,
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #9
Don't #include SDLMain.m, it's a source file, not a header. Don't #include SDLMain.h, either.

Just make sure that <SDL/SDL.h> is included in main.cpp, and compile SDLMain.m as an additional source file.

Whilst you're at it, get rid of all the -F arguments in your compile lines.

And no, don't stick any X11 stuff in your include or lib paths. That's a bad idea.
Quote this message in a reply
Member
Posts: 52
Joined: 2007.06
Post: #10
Thanks buddy,

Your the man,

Reading over so many tutorials argg.

Youve been a big help,

Here where we are at now,

Look better?

make
g++ -c -O3 -o galaxy.o galaxy.cpp
g++ -c -O3 -o SolidEntity.o SolidEntity.cpp
g++ -c -O3 -o Vec3.o Vec3.cpp
g++ -c -O3 -o Frustum.o Frustum.cpp
g++ -c -O3 -o FileReader.o FileReader.cpp
g++ -c -O3 -o Matrix4x4.o Matrix4x4.cpp
g++ -c -O3 -o Camera.o Camera.cpp
g++ -c -O3 -o Texture.o Texture.cpp
g++ -c -O3 -o Shaders.o Shaders.cpp
g++ -c -O3 -o Utility.o Utility.cpp
g++ -c -O3 -o Stars.o Stars.cpp
g++ -c -O3 -o Planets.o Planets.cpp
g++ -c -O3 -o Earth.o Earth.cpp
g++ -c -O3 -o Mars.o Mars.cpp
g++ -c -O3 -o Venus.o Venus.cpp
g++ -c -O3 -o Mercury.o Mercury.cpp
g++ -c -O3 -o Jupiter.o Jupiter.cpp
g++ -c -O3 -o Saturn.o Saturn.cpp
g++ -c -O3 -o Uranus.o Uranus.cpp
g++ -c -O3 -o Neptune.o Neptune.cpp
g++ -c -O3 -o Pluto.o Pluto.cpp
g++ -O3 -o galaxy SDLMain.m galaxy.o SolidEntity.o Vec3.o Frustum.o FileReader.o Matrix4x4.o Camera.o Texture.o Shaders.o Utility.o Stars.o Planets.o Earth.o Mars.o Venus.o Mercury.o Jupiter.o Saturn.o Uranus.o Neptune.o Pluto.o -lm -framework OpenGL -framework GLUT -framework SDL_image -framework SDL -framework Cg
/usr/bin/ld: Undefined symbols:
.objc_class_name_NSApplication
.objc_class_name_NSAutoreleasePool
.objc_class_name_NSMenu
.objc_class_name_NSMenuItem
.objc_class_name_NSObject
.objc_class_name_NSProcessInfo
.objc_class_name_NSString
_CFBundleCopyBundleURL
_CFBundleGetInfoDictionary
_CFBundleGetMainBundle
_CFRelease
_CFURLCreateCopyDeletingLastPathComponent
_CFURLGetFileSystemRepresentation
_CPSEnableForegroundOperation
_CPSGetCurrentProcess
_CPSSetFrontProcess
_NSAllocateMemoryPages
_NSApp
_NSDeallocateMemoryPages
___CFConstantStringClassReference
_objc_msgSend
collect2: ld returned 1 exit status
make: *** [galaxy] Error 1
Quote this message in a reply
Member
Posts: 52
Joined: 2007.06
Post: #11
Added
-Framework Cocoa and now everything works perfectly.


Yes!~
Quote this message in a reply
Member
Posts: 52
Joined: 2007.06
Post: #12
As another note,

All my fragment programs and vertex programs worked perfectly, all the sdl stuff perfect.

On my home computer,

Dual Xeon 2.8ghz, 2g rdram, scsi 15k and bfg 7800gs 256mb i got 60fps and on the new mbp 2.4ghz, 2g ram, nvidia 8600 g 256mb and the sata 5400 im getting 48fps so im pretty happy. Really impressed with this notebook. My buddies linux xps 2.16 nvidia 7400 could only pump out 28fps with the same application. Plus we know these drivers for the 8600 suck right now, so pretty impressed mac boys!

Also very impressed with the forum, u know your macs!
Quote this message in a reply
Member
Posts: 114
Joined: 2005.03
Post: #13
m3the01 Wrote:Question do i need to install the sdl, sdl_image and Cg frameworks in the system/library/frameworks section of the disk?

Cause right now they are only in the library/frameworks section, they are not present int he system/library/framework area.

Thanks for the help

Don't change anything in /System (except for installing kernel extensions). It isn't wrong to put SDL, SDL_image and CG in either /Library/Frameworks or ~/Library/Frameworks, but when you ship the program, it's best to put them in the bundle under Contents/Frameworks, so that your users don't have to install those frameworks themselves.
Quote this message in a reply
Member
Posts: 52
Joined: 2007.06
Post: #14
Yeah thats what i was thinking, just like when i use to pack the usr/lib directory on other builds.

Thanks
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Trouble Shooting Undefined Symbols Atomical 12 4,727 Sep 8, 2005 12:53 PM
Last Post: Atomical