2009-11-22 9 views
20

Ho creato alcune funzioni wrapper che incapsulano con CoreAudio e l'obiettivo è creare una libreria C che possa essere utilizzata con alcuni strumenti C++ della riga di comando. Finora le cose stanno andando bene. Ho preso un progetto di esempio, l'ho modificato e si costruisce e funziona in XCode. Mi piacerebbe saltare XCode del tutto e costruire la libreria con gcc e un Makefile.Collegamento a framework Apple con gcc

Come è possibile eseguire il collegamento a un framework Apple? I framework sono solo librerie condivise che potrei includere nelle opzioni -l e -L su gcc?

risposta

24

Ecco un esempio:

gcc -framework CoreServices -o test test.c

Dalla pagina man di gcc di Apple (i686-apple-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. 

E dalla pagina man di 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

Quindi la differenza tra il collegamento con '-framework' e il collegamento con' -l' su Mac OS è il percorso di ricerca giusto? – user10607

Problemi correlati