SDL2 in MacOSX 10.9

I try to create applications using SDL in Netbeans, but it doesn't works. I try to compile a simple test code, and I suppose that anythings is wrong. This is the error message:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
"/Applications/Xcode.app/Contents/Developer/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/test
mkdir -p build/Debug/GNU-MacOSX
rm -f "build/Debug/GNU-MacOSX/main.o.d"
g++    -c -g -MMD -MP -MF "build/Debug/GNU-MacOSX/main.o.d" -o build/Debug/GNU-MacOSX/main.o main.cpp
main.cpp:24:33: error: use of undeclared identifier 'SDL_OPENGL'
   SDL_SetVideoMode(xres,yres,0,SDL_OPENGL | SDL_HWSURFACE | SDL_FULLSCREEN);
                                ^
main.cpp:24:46: error: use of undeclared identifier 'SDL_HWSURFACE'
   SDL_SetVideoMode(xres,yres,0,SDL_OPENGL | SDL_HWSURFACE | SDL_FULLSCREEN);
                                             ^
main.cpp:24:62: error: use of undeclared identifier 'SDL_FULLSCREEN'
   SDL_SetVideoMode(xres,yres,0,SDL_OPENGL | SDL_HWSURFACE | SDL_FULLSCREEN);
                                                             ^
main.cpp:36:7: error: use of undeclared identifier 'SDL_GL_SwapBuffers'
      SDL_GL_SwapBuffers();
      ^
4 errors generated.
make[2]: *** [build/Debug/GNU-MacOSX/main.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2


Thanks !
Last edited on
Do you have SDL 1.2 installed?
No, SDL 2
Well, then that's the problem. The code is using SDL 1.2.
All right, I'm gone to try installing SDL1.2. Thanks! (:
Seems better, but I don't know what to do with te error.

1
2
3
4
5
6
7
8
9
10
11
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
"/Applications/Xcode.app/Contents/Developer/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/test
mkdir -p build/Debug/GNU-MacOSX
rm -f "build/Debug/GNU-MacOSX/main.o.d"
g++ -I/Library/Frameworks/SDL.framework/Headers main.cpp SDLmain.m -framework SDL -framework Cocoa   -c -g -MMD -MP -MF "build/Debug/GNU-MacOSX/main.o.d" -o build/Debug/GNU-MacOSX/main.o main.cpp
clang: warning: -framework SDL: 'linker' input unused
clang: warning: -framework Cocoa: 'linker' input unused
clang: error: cannot specify -o when generating multiple output files
make[2]: *** [build/Debug/GNU-MacOSX/main.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
Last edited on
The 'linker' stuff are just warnings so I don't think you have to care about that.

I think the error you get is because you mention main.cpp twice.
g++ -I/Library/Frameworks/SDL.framework/Headers main.cpp SDLmain.m -framework SDL -framework Cocoa -c -g -MMD -MP -MF "build/Debug/GNU-MacOSX/main.o.d" -o build/Debug/GNU-MacOSX/main.o main.cpp

Remove one of them.
Last edited on
The same:

1
2
3
4
5
6
7
8
9
10
11
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
"/Applications/Xcode.app/Contents/Developer/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/test
mkdir -p build/Debug/GNU-MacOSX
rm -f "build/Debug/GNU-MacOSX/main.o.d"
g++ -I/Library/Frameworks/SDL.framework/Headers SDLmain.m -framework SDL -framework Cocoa   -c -g -MMD -MP -MF "build/Debug/GNU-MacOSX/main.o.d" -o build/Debug/GNU-MacOSX/main.o main.cpp
clang: warning: -framework SDL: 'linker' input unused
clang: warning: -framework Cocoa: 'linker' input unused
clang: error: cannot specify -o when generating multiple output files
make[2]: *** [build/Debug/GNU-MacOSX/main.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2


PD: Thanks for your time Peter.
I'm afraid I can't help you. I'm not so familiar with Mac OS and Clang.
After search, finally I reed that SDL1.2 doesn't works in MacOSX 10.9, and I try to install again SDL2. Well, my problem is that I don't know how to compile a .cpp project using SDL2. I try some commands for do this but always have an error. This is the last one, now applying SDL2 framework. It's the same problem than the beginning. It's a problem with the makefile that i have to include in to the project?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -f nbproject/Makefile-SDL.mk QMAKE= SUBPROJECTS= .build-conf
"/Applications/Xcode.app/Contents/Developer/usr/bin/make"  -f nbproject/Makefile-SDL.mk dist/SDL/GNU-MacOSX/test2
mkdir -p build/SDL/GNU-MacOSX
rm -f "build/SDL/GNU-MacOSX/main.o.d"
g++ -I/System/Library/Frameworks/OpenGL.framework/Headers -framework SDL2 -framework Cocoa -framework OpenGL   -c -g -MMD -MP -MF "build/SDL/GNU-MacOSX/main.o.d" -o build/SDL/GNU-MacOSX/main.o main.cpp
clang: warning: -framework SDL2: 'linker' input unused
clang: warning: -framework Cocoa: 'linker' input unused
clang: warning: -framework OpenGL: 'linker' input unused
main.cpp:23:33: error: use of undeclared identifier 'SDL_OPENGL'
   SDL_SetVideoMode(xres,yres,0,SDL_OPENGL | SDL_HWSURFACE | SDL_FULLSCREEN);
                                ^
main.cpp:23:46: error: use of undeclared identifier 'SDL_HWSURFACE'
   SDL_SetVideoMode(xres,yres,0,SDL_OPENGL | SDL_HWSURFACE | SDL_FULLSCREEN);
                                             ^
main.cpp:23:62: error: use of undeclared identifier 'SDL_FULLSCREEN'
   SDL_SetVideoMode(xres,yres,0,SDL_OPENGL | SDL_HWSURFACE | SDL_FULLSCREEN);
                                                             ^
main.cpp:35:7: error: use of undeclared identifier 'SDL_GL_SwapBuffers'
      SDL_GL_SwapBuffers();
      ^
4 errors generated.
make[2]: *** [build/SDL/GNU-MacOSX/main.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
As I said earlier it looks like the code is using SDL 1.2. Try if this example works better: http://wiki.libsdl.org/SDL_CreateWindow#Code_Examples
OMG jaja I love you! I don't understand you at the beginning. Thanks!
One more question. What's the difference in the code using 1.2 and 2.0?
Thank you very much!
Topic archived. No new replies allowed.