PDA

Ver la versión completa : SDL en Mac OS X



[Madox]
16/01/2006, 23:49
Muy buenas,

Estaba intentando crear una simple prueba con SDL en Mac OS X, pero no consigo que compile. Instale las SDL via Fink y también con los archivos, SDL-1.2.9.dmg y SDL-devel-1.2.9.pkg.tar.gz, de http://www.libsdl.org/.

Para compilar hago:

g++ -o main -g -O2 -I/sw/include/SDL -I/sw/include main.cpp -L/sw/lib -lSDLmain -lSDL

o

g++ -o main main.cpp -framework SDL
Y la salida del compilador es:

ld: /sw/lib/libSDLmain.a(SDLMain.o) illegal reference to symbol: .objc_class_name_NSAppleMenuController defined in indirectly referenced dynamic library /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
ld: /sw/lib/libSDLmain.a(SDLMain.o) illegal reference to symbol: .objc_class_name_NSAutoreleasePool defined in indirectly referenced dynamic library /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
ld: /sw/lib/libSDLmain.a(SDLMain.o) illegal reference to symbol: _CPSEnableForegroundOperation defined in indirectly referenced dynamic library /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
ld: /sw/lib/libSDLmain.a(SDLMain.o) illegal reference to symbol: ___CFConstantStringClassReference defined in indirectly referenced dynamic library /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
ld: /usr/lib/crt1.o illegal reference to symbol: __objcInit defined in indirectly referenced dynamic library /usr/lib/libobjc.A.dylib
ld: warning suggest use of -bind_at_load, as lazy binding may result in errors or different symbols being used
symbol _acosl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _tanl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _tanhl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _asinl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _atan2l used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _atanl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _ceill used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _coshl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _cosl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _expl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _floorl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _fmodl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _frexpl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _hypotl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _ldexpl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _log10l used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _logl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _modfl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _powl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _sinhl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _sinl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)
symbol _sqrtl used from dynamic library /usr/lib/libstdc++.6.dylib(single module) not from earlier dynamic library /usr/lib/libSystem.B.dylib(ld64.o)

Decir que he instalado el DevkitGP2X para Mac OS X y compila perfectamente y me genera el archivo ".gpe".

¿Algun maquero, o no maquero :D, sabe que pude ser?


Un saludo ;)

kounch
17/01/2006, 02:03
¿Qué versión de OS X usas?

Fink todavía no es compatible al 100% con OS X 10.4.

Por otra parte, los problemas de enlazado con librerías SDL en OS X se suelen solucionar si instalas las mismas desde código fuente (configure, make, make install, etc.) en vez de un paquete binario.

Para distribuir luego el software que hagas para OS X, enlaza estáticamente y así evitas problemas para la gente (no ocupa mucho relativamentee y es lo más seguro).

Finalmente, en el FAQ de SDL para OS X recomiendan que sigas unas directrices básicas a la hora de preparar tu código para enlazar con SDL (te lo he marcado en rojo):

http://www.libsdl.org/faq.php?action=listentries&category=7#55


Q: What is SDLMain.m? Do I need it? Why is _main undefined?
A: Just like main() is the entry point for C programs (inc. C++, Objective-C, and Objective-C++), SDL_main() is the main entry point for SDL programs. However, you don't actually write an SDL_main() function. The header file "SDL_main.h" remaps your main() function to the SDL_main() function with a function macro. Your SDL_main() function is called after the code in SDLMain.m has performed the required "bootstrap" initializations to support the SDL runtime.

There are three things you have to do:
You must include either SDLMain.m/.h or libSDLmain in your application, because this is the code that defines SDL's entry point. If you fail to do this, it is likely that "_main undefined" will be thrown by the linker.
You must give your main() procedure the following prototype:
int main(int argc, char*argv[]);
You must make sure the file containing your main() procedure #includes SDL.h.
Otherwise, the macro will not remap main() to SDL_main(), you will get an undefined _main error, or the bootstrap process will not run, and SDL will behave strangely or your application will crash or hang.

Q: Is there a way to avoid SDLMain.m and Objective-C in my program? I want a pure C/C++ program.
A: If you are using ProjectBuilder or XCode, then the answer is no. SDLMain.m must be included in your application, which requires Cocoa/Objective-C.

You can still write your SDL application in C++. The easiest way to get started with this is to rename "main.c" in the project stationary to "main.cpp" and recompile your application.

If you are developing using the UNIX variant of SDL, you can link libSDLmain.a into your application, which simply contains a precompile version of SDLmain.m.

So for command-line/Makefile builds, just add -lSDLmain to your build commands like any other library and add "-framework Cocoa" to the gcc or ld flags. Better yet, use the sdl-config script (in the source code distribution) which computes the correct compiler and linker flags for you.

[Madox]
17/01/2006, 06:55
Hola Kounch,
.
Estoy usando Mac OS X Panther.

He usado -lSDLmain y -framework Cocoa al compilar y me sigue diciendo lo mismo :( , tambien he provado con lo que me dice sdl-config --libs y tambien dice practicamente lo mismo :(

He intentado compilar las SDL desde las fuentes y me da error. Exactamente me dice:


ld: /usr/lib/gcc/darwin/3.3/libstdc++.a(functexcept.o) illegal reference to symbol: std::logic_error::logic_error(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) defined in indirectly referenced dynamic library /usr/lib/libstdc++.6.dylib
/usr/bin/libtool: internal link edit command failed
make[2]: *** [libSDL.la] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1
Un saludo :)

kounch
17/01/2006, 14:04
']Estoy usando Mac OS X Panther.
He intentado compilar las SDL desde las fuentes y me da error. Exactamente me dice:
Pueden ser dos cosas:
La versión oficial de SDL está preparada para OS X 10.4.4 (Tiger) y, para compilarse con versiones anteriores tienen que hacerse unos cambios, ya que Apple ha cambiado la forma de enlazar con la libreria estándar de C pasándola a dinámica, con lo que podría ser eso. Puedes intentar compilar SDL 1.2.8 o mirar en sus opciones de compilación para pasar a estático el enlazado.

La otra opción es que tengas un lío de instalación con varias SDL instaladas. Intenta hacer lo siguiente:
Borra todas las librerías que tengas instaladas de SDL (mira en /System/Library, en /Library y en tu carpeta de usuario/Library/ y dentro de estas, en Frameworks)
Intenta compilarlo usando xcode. Si no puedes, compilarlo, pero no hagas un make install.
Mueve las librerias o frameworks que te haya creado a /Library/Frameworks/
Intenta ahora enlazar contra esas librerias en esa ruta. Si no funcionara, intenta jugar con las posibilidades de compilador en test/frameworks

A ver si con esto se arregla.

kounch

[Madox]
17/01/2006, 22:12
Pues nada, que no quiere compilar :D

He probado a compilar las versiones 1.2.8 y 1.2.7, y las dos dan el mismo error de antes.


Muchas gracias de todos modos kounch.

Un saludo ;)

NoobLuck
23/01/2006, 02:56
Para compilar con openGL bajo MacOS X , a mi tb me pedía poner el cocoa.
Con las SDL no se que tendrás que usar.

Te recomiendo que desinstales las SDL que vienen con el fink y que vayas a la página oficial de las librerias SDL y te bajes el .img con el paquete con las librerias. La instalación será gráfica, la típica del mac os x. Después crea el proyecto con Xtools o intenta lo que has estado haciendo hasta ahora.

[Madox]
23/01/2006, 05:03
Para compilar con openGL bajo MacOS X , a mi tb me pedía poner el cocoa.
Con las SDL no se que tendrás que usar.

Te recomiendo que desinstales las SDL que vienen con el fink y que vayas a la página oficial de las librerias SDL y te bajes el .img con el paquete con las librerias. La instalación será gráfica, la típica del mac os x. Después crea el proyecto con Xtools o intenta lo que has estado haciendo hasta ahora.
Por ahora voy tirando con Dev-C++ en Windows.

El dia que actualize a Tiger mirare de instalar las SDL otra vez, porque creo que lo que me pasa ahora es culpa del compilador :llorosa:


Un saludo :)