2013-03-06 123 views
3

我正在使用libcurl進行HTTP/HTTPS請求。我已經下載了源代碼並構建爲一個靜態庫。如何構建自定義libcurl以僅支持HTTP/HTTPS協議

我的最終可執行文件的大小有所增加。我試圖修剪我的可執行文件,因爲我有其他限制。

在分析過程中,我觀察到libcurl支持許多協議,包括HTTP。但是我的具體用途是HTTP/HTTPS。

有沒有一種方法可以在構建libcurl時定義編譯標誌來禁用其他協議?

謝謝你閱讀這篇文章!

+1

嘗試'運行./configure --disable-FTP - 禁用文件--...',對所有協議,你不想要的。 – 2013-03-06 15:23:04

+0

忘記提及: 我想在WIN env中獲得圖書館,並且我在VC++上構建。 – 2013-03-06 15:24:59

+0

不錯的用戶名;) – 2013-03-06 17:33:33

回答

6

看看:http://curl.haxx.se/docs/install.html

Disabling Specific Protocols in Win32 builds 
    -------------------------------------------- 

    The configure utility, unfortunately, is not available for the Windows 
    environment, therefore, you cannot use the various disable-protocol 
    options of the configure utility on this platform. 

    However, you can use the following defines to disable specific 
    protocols: 

    HTTP_ONLY    disables all protocols except HTTP 
    CURL_DISABLE_FTP  disables FTP 
    CURL_DISABLE_LDAP  disables LDAP 
    CURL_DISABLE_TELNET disables TELNET 
    CURL_DISABLE_DICT  disables DICT 
    CURL_DISABLE_FILE  disables FILE 
    CURL_DISABLE_TFTP  disables TFTP 
    CURL_DISABLE_HTTP  disables HTTP 

    If you want to set any of these defines you have the following 
    possibilities: 

    - Modify lib/config-win32.h 
    - Modify lib/curl_setup.h 
    - Modify lib/Makefile.vc6 
    - Add defines to Project/Settings/C/C++/General/Preprocessor Definitions 
    in the vc6libcurl.dsw/vc6libcurl.dsp Visual C++ 6 IDE project. 
+0

感謝發佈。我將重申信息! – 2013-03-06 15:27:03