Mac OS X 10.6 下安裝 GnuTLS

來源:互聯網
上載者:User

安裝環境:

  • Mac OS X: 10.6.6
  • Xcode: 3.2.5
  • GnuTLS: 2.10.4
  • Libgcrypt: 1.4.6
  • Libgpg-error: 1.10

要成功編譯GnuTLS必須先安裝Libgcrypt,而要成功編譯Libgcrypt又必須依賴Libgpg-error。所以必須按照Libgpg-error->Libgcrypt->GnuTLS的順序進行安裝。具體安裝方法見各程式的INSTALL文檔,以下是在安裝過程中出現的問題以及解決方案。

對Libgcrypt進行make時會出現以下錯誤:
mpih-add1-asm.S:47:suffix or operands invalid for `push'mpih-add1-asm.S:48:suffix or operands invalid for `push'mpih-add1-asm.S:78:suffix or operands invalid for `jmp'mpih-add1-asm.S:113:suffix or operands invalid for `pop'mpih-add1-asm.S:114:suffix or operands invalid for `pop'

這個錯誤可通過在configure時增加可選項disable-asm來避免。

./configure --disable-asm
對GnuTLS進行make時會出現以下錯誤:
serv.c:515:41: error: macro "__darwin_obsz" passed 2 arguments, but takes just 1serv.c: In function 'peer_print_info':serv.c:515: error: '__darwin_obsz' undeclared (first use in this function)serv.c:515: error: (Each undeclared identifier is reported only onceserv.c:515: error: for each function it appears in.)serv.c:515: error: expected expression before ')' tokenserv.c:515: warning: passing argument 3 of '__builtin___snprintf_chk' makes integer from pointer without a castserv.c:517:37: error: macro "__darwin_obsz" passed 2 arguments, but takes just 1serv.c:517: warning: passing argument 3 of '__builtin___snprintf_chk' makes integer from pointer without a castserv.c:518:31: error: macro "__darwin_obsz" passed 2 arguments, but takes just 1serv.c:518: error: expected expression before ')' tokenserv.c:518: warning: passing argument 3 of '__builtin___snprintf_chk' makes integer from pointer without a castserv.c:521:71: error: macro "__darwin_obsz" passed 2 arguments, but takes just 1serv.c:519: error: expected expression before ')' tokenserv.c:519: warning: passing argument 3 of '__builtin___snprintf_chk' makes integer from pointer without a castserv.c:533:51: error: macro "__darwin_obsz" passed 2 arguments, but takes just 1serv.c:533: warning: passing argument 3 of '__builtin___snprintf_chk' makes integer from pointer without a castserv.c:545:49: error: macro "__darwin_obsz" passed 2 arguments, but takes just 1serv.c:544: warning: passing argument 3 of '__builtin___snprintf_chk' makes integer from pointer without a castserv.c:553:49: error: macro "__darwin_obsz" passed 2 arguments, but takes just 1serv.c:552: warning: passing argument 3 of '__builtin___snprintf_chk' makes integer from pointer without a castserv.c:562:43: error: macro "__darwin_obsz" passed 2 arguments, but takes just 1serv.c:560: warning: passing argument 3 of '__builtin___snprintf_chk' makes integer from pointer without a castserv.c:570:43: error: macro "__darwin_obsz" passed 2 arguments, but takes just 1serv.c:568: warning: passing argument 3 of '__builtin___snprintf_chk' makes integer from pointer without a castserv.c:581:8: error: macro "__darwin_obsz" passed 2 arguments, but takes just 1serv.c:579: warning: passing argument 3 of '__builtin___snprintf_chk' makes integer from pointer without a castserv.c:590:78: error: macro "__darwin_obsz" passed 2 arguments, but takes just 1serv.c:590: warning: passing argument 3 of '__builtin___snprintf_chk' makes integer from pointer without a castserv.c:596:70: error: macro "__darwin_obsz" passed 2 arguments, but takes just 1serv.c:596: warning: passing argument 3 of '__builtin___snprintf_chk' makes integer from pointer without a castserv.c:601:68: error: macro "__darwin_obsz" passed 2 arguments, but takes just 1serv.c:601: warning: passing argument 3 of '__builtin___snprintf_chk' makes integer from pointer without a castserv.c:606:63: error: macro "__darwin_obsz" passed 2 arguments, but takes just 1serv.c:606: warning: passing argument 3 of '__builtin___snprintf_chk' makes integer from pointer without a castserv.c:611:60: error: macro "__darwin_obsz" passed 2 arguments, but takes just 1serv.c:611: warning: passing argument 3 of '__builtin___snprintf_chk' makes integer from pointer without a castserv.c:619:8: error: macro "__darwin_obsz" passed 2 arguments, but takes just 1serv.c:618: warning: passing argument 3 of '__builtin___snprintf_chk' makes integer from pointer without a castserv.c:623:54: error: macro "__darwin_obsz" passed 2 arguments, but takes just 1serv.c:623: warning: passing argument 3 of '__builtin___snprintf_chk' makes integer from pointer without a castserv.c:627:84: error: macro "__darwin_obsz" passed 2 arguments, but takes just 1serv.c:627: warning: passing argument 3 of '__builtin___snprintf_chk' makes integer from pointer without a cast

這個錯誤是由於宏snprintf在Mac OS X 10.6下的不相容造成的。解決方案是修改serv.c中的代碼,將宏tmp2拆成兩個宏。具體修改如下:

1. 先將tmp2的定義拆分為tmp2b和tmp2l。
-#define tmp2 &http_buffer[strlen(http_buffer)], len-strlen(http_buffer)+#define tmp2b &http_buffer[strlen(http_buffer)]+#define tmp2l len-strlen(http_buffer)
2. 接著將所有調用tmp2的地方替換為tmp2b, tmp2l。

參考文章:GnuTLS does not build on OS X 10.6 due to incompatibility with snprintf macro

以下是原文中關於錯誤及解決方案的描述:

Code built with gcc on Mac OS X 10.6 uses the object size checking feature of gcc by default. This involves redefiningseveral functions as macros; one of these functions is snprintf:    #define snprintf(str, len, ...) \     __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__)The usage of snprintf in src/serv.c in gnutls-2.10.4 is not compatible with that macro. serv.c attempts touse a macro (tmp2) that expands into two different arguments:    #define tmp2 &http_buffer[strlen(http_buffer)], len-strlen(http_buffer)    snprintf (tmp2, "%.2X", sesid[i]);Due to how nested macro evaluation works, the snprintf macro sees tmp2 as a single argument, and copies itinto __darwin_obsz(); then, when tmp2 is expanded, __darwin_obsz has two arguments, but it is onlydefined for one, and the result is a compilation error.One way to work around this issue might be to define _FORTIFY_SOURCE=0 so that the snprintf macro is notdefined, or simply doing an #undef snprintf for that file, but it seems safer and more portable to splittmp2 into two macros. I append a patch that does so.

GnuTLS 的詳細介紹:請點這裡
GnuTLS 的:請點這裡

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.