2009-11-22 21 views
20

Tôi đã tạo một số hàm bao bọc đóng gói làm việc với CoreAudio và mục đích là tạo một thư viện C mà tôi có thể sử dụng với một số công cụ dòng lệnh C++. Cho đến nay mọi thứ đang hoạt động tốt. Tôi lấy một dự án mẫu, sửa đổi nó, và nó xây dựng và chạy trong XCode. Tôi muốn bỏ qua XCode hoàn toàn và xây dựng thư viện với gcc và Makefile.Liên kết với các khung công tác của Apple với gcc

Tôi làm cách nào để liên kết với Apple Framework? Khung làm việc chỉ là các thư viện được chia sẻ mà tôi có thể bao gồm trong các tùy chọn -l và -L trên gcc?

Trả lời

24

Dưới đây là một ví dụ:

gcc -framework CoreServices -o test test.c

Từ trang người đàn ông của gcc của 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. 

Và từ trang người đàn ông của 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

Vì vậy, sự khác biệt giữa liên kết với '-framework' và liên kết với' -l' trên Mac OS là đường dẫn tìm kiếm phải không? – user10607

Các vấn đề liên quan