2009-11-22 17 views
20

He creado algunas funciones de contenedor que encapsulan el trabajo con CoreAudio, y el objetivo es crear una biblioteca C que pueda usar con algunas herramientas C++ de línea de comando. Hasta ahora las cosas están funcionando bien. Tomé un proyecto de muestra, lo modifiqué, y se construye y ejecuta en XCode. Me gustaría omitir XCode por completo y construir la biblioteca con gcc y un Makefile.Vinculación con frameworks de Apple con gcc

¿Cómo puedo vincularme con un Apple Framework? ¿Frameworks solo comparte bibliotecas que podría incluir en las opciones -l y -L en gcc?

Respuesta

24

He aquí un ejemplo:

gcc -framework CoreServices -o test test.c

Desde la página del manual de gcc de Apple (i686-manzana-darwin10-gcc-4.2.1):

In addition to the options listed below, Apple's GCC also accepts and 
    passes nearly all of the options defined by the linker ld and by the 
    library tool libtool. Common options include -framework, -dynamic, 
    -bundle, -flat_namespace, and so forth. See the ld and libtool man 
    pages for further details. 

Y de la página man de ld:

-framework name[,suffix] 
      This option tells the linker to search for `name.frame- 
      work/name' the framework search path. If the optional suffix 
      is specified the framework is first searched for the name 
      with the suffix and then without (e.g. look for `name.frame- 
      work/name_suffix' first, if not there try `name.frame- 
      work/name'). 
+0

Entonces, ¿la diferencia entre enlazar con '-framework' y enlazar con' -l' en Mac OS es la ruta de búsqueda correcta? – user10607

Cuestiones relacionadas