簡體   English   中英

Objective-C和C

[英]Objective-C and C

我嘗試使用“ libmsrp”,但是當我嘗試編譯庫時,出現以下錯誤:

$ make so
gcc -ggdb -shared -Wl,-soname,libmsrp.so.0 -o libmsrp.so.0.0.2 msrp.o msrp_session.o msrp_message.o msrp_relay.o msrp_switch.o msrp_callback.o msrp_network.o msrp_utils.o -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations  -lpthread
ld: unknown option: -soname
collect2: ld returned 1 exit status
make: *** [so] Error 1

因此,我將-soname選項更改為-dylib_install_name -Wl。 編譯后出現以下錯誤:

$ make so
gcc -ggdb -shared -Wl,-dylib_install_name -Wl,libmsrp.dylib.0.0.2 -o libmsrp.dylib.0.0.2 msrp.o msrp_session.o msrp_message.o msrp_relay.o msrp_switch.o msrp_callback.o msrp_network.o msrp_utils.o -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations  -lpthread <p>
Undefined symbols:<p>
"_main", referenced from:
start in crt1.10.5.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [so] Error 1

因此,我嘗試在Objective-C項目中進行編譯。 我添加源文件和頭文件並編譯該項目。

我收到以下錯誤:

command: MSRP_LIST_FREE(sessions, sessions_lock);

msrp.c:75: error: expected ';' before 'temp'
msrp.c:75: error: 'temp' undeclared (first use in this function)
msrp.c:75: error: 'next' undeclared (first use in this function)
msrp.c:75: error: expected ';' before 'temp'
msrp.c:75: error: 'previous' undeclared (first use in this function)

宣言:

#define MSRP_LIST_FREE(list, lock
if(!(list))
    return 0;
else {
    typeof((list)) temp = list, next = NULL;
    while(temp) {
        next = temp->next;
        MSRP_LIST_REMOVE((list), (lock), temp);
        temp = next
    }
}

任何想法?

從源文件編譯時,makefile可能會處理一些未設置的定義。 您應該繼續使用make進行編譯;)也許,您應該嘗試使用gmake代替make。

-soname應該是我認為的-install_name (而不是-dylib_install_name )。 無論如何,當我進行更改時,它都會干凈地編譯。

這是我在make文件中所擁有的:

gcc -ggdb -shared -Wl,-install_name,libmsrp.so.0 -o libmsrp.so.0.0.2 ... etc.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM