2009-11-22 12 views
20

Ich habe einige Wrapper-Funktionen erstellt, die die Arbeit mit CoreAudio kapseln, und das Ziel ist es, eine C-Bibliothek zu erstellen, die ich mit einigen C++ - Befehlszeilen-Tools verwenden kann. Bis jetzt funktioniert es gut. Ich nahm ein Beispielprojekt, modifizierte es, und es baut und läuft in XCode. Ich möchte XCode ganz überspringen und die Bibliothek mit gcc und einem Makefile erstellen.Verknüpfung mit Apple-Frameworks mit gcc

Wie kann ich ein Apple Framework verlinken? Sind Frameworks nur freigegebene Bibliotheken, die ich in die Optionen -l und -L auf gcc aufnehmen könnte?

Antwort

24

Hier ist ein Beispiel:

gcc -framework CoreServices -o test test.c

Aus der Manpage von gcc Apple (i686-Apfel-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. 

Und von ld's man page:

-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

Der Unterschied zwischen der Verknüpfung mit '-framework' und der Verknüpfung mit' -l' auf Mac OS ist der Suchpfad richtig? – user10607