當前位置:首頁 » 編程軟體 » libcurla編譯

libcurla編譯

發布時間: 2022-09-18 17:52:15

『壹』 如何鏈接libcurl

靜態鏈接libcurl的步驟

1、使用跟程序相同的選項編譯libcurl靜態庫;
2、程序中在引入curl頭文件前定義
#define
CURL_STATICLIB
3、引入庫:
#if defined(_DEBUG)
#pragma comment(lib,
"libcurld.lib")
#else
#pragma comment(lib,
"libcurl.lib")
#endif

#pragma comment ( lib, "ws2_32.lib" )
#pragma
comment ( lib, "wldap32.lib" )

『貳』 有沒有人用過NDK編譯libcurl的

我記得,在官方文檔中 "Dev Guide" 部分的左下角有一小節是專門用來講解 "NDK" 的,你不妨去看看

『叄』 為什麼編譯好的libcurl靜態lib用不了

When building an application that uses the static libcurl library, you must
add -DCURL_STATICLIB to your CFLAGS. Otherwise the linker will look for
dynamic import symbols. If you get linker error like "unknown symbol
__imp__curl_easy_init ..." you have linked against the wrong (static)
library. If you want to use the libcurl.dll and import lib, you don't need
any extra CFLAGS, but use one of the import libraries below

在這里:http://curl.haxx.se/docs/faq.html#Link_errors_when_building_libcur

所以我們這樣來改

菜單-->project -->settings-->C++選項卡的General裡面的Project Option裡面加上-DCURL_STATICLIB (其實就相當於在Preprocessor definitions裡面加上CURL_STATICLIB一樣)

確定-->rebuild all

又出錯了:

libcurl.lib(easy.obj) : error LNK2001: unresolved external symbol
libcurl.lib(telnet.obj) : error LNK2001: unresolved external symbol
libcurl.lib(easy.obj) : error LNK2001: unresolved external symbol

.....

這個一看就明白了馬上加上:

#pragma comment ( lib, "ws2_32.lib" )
#pragma comment ( lib, "wldap32.lib" )

編譯-->叮的一個美妙的聲音想起了,哈哈,編譯成功

『肆』 如何編譯libcurl

我是這樣編的 :
① ./configure --prefix=/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi CC=/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-gcc --host=arm-linux
② 然後make ,
③ 接著 sudo make install
這樣 就在/usr/local/gcc-4.1.2-glibc-2.5-nptl-3/arm-none-linux-gnueabi/lib 下面 看到libcurl.so ,

然後我要用這個libcurl.so 交叉編譯一個c文件
④ arm-none-linux-gnueabi-gcc curl3.c -o curl0 -L. -lcurl

『伍』 如何在Visual Studio 2013中使用libcurl庫

本文詳細描述了如何編譯libcurl源文件,如何在Visual Studio 2013中使用libcurl庫,最後還給出了如何通過libcurl庫根據URL下載對應的網頁內容到本地的代碼實例。
http://download.csdn.net/download/dongdongup/701

『陸』 如何編譯libcurl

1. Android
1.1配置
將curl源文件加到在Android源代碼external/curl/中。創建shell腳本configure.sh,並把它放到external/curl/中。
腳本內容如下:
#!/bin/sh SDK_ROOT=/home/nudtzxm/android_sdk export PATH="$SDK_ROOT/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin:$PATH" ./configure --host=arm-linux CC=arm-eabi-gcc \ CPPFLAGS="-I $SDK_ROOT/system/core/include -I $SDK_ROOT/hardware/libhardware/include -I $SDK_ROOT/hardware/libhardware_legacy/include -I $SDK_ROOT/hardware/ril/include -I $SDK_ROOT/dalvik/libnativehelper/include -I $SDK_ROOT/frameworks/base/include -I $SDK_ROOT/frameworks/base/opengl/include -I $SDK_ROOT/external/skia/include -I $SDK_ROOT/out/target/proct/generic/obj/include -I $SDK_ROOT/bionic/libc/arch-arm/include -I $SDK_ROOT/bionic/libc/include -I $SDK_ROOT/bionic/libstdc++/include -I $SDK_ROOT/bionic/libc/kernel/common -I $SDK_ROOT/bionic/libc/kernel/arch-arm -I $SDK_ROOT/bionic/libm/include -I $SDK_ROOT/bionic/libm/include/arch/arm -I $SDK_ROOT/bionic/libthread_db/include -I $SDK_ROOT/bionic/libc/kernel/common -I $SDK_ROOT/bionic/libc/kernel/arch-arm -I $SDK_ROOT/system/core/libcutils -I $SDK_ROOT/out/target/proct/generic/obj/STATIC_LIBRARIES/libcutils_intermediates -I $SDK_ROOT/out/target/proct/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates -I $SDK_ROOT/system/core/include/arch/linux-arm/ -include $SDK_ROOT/system/core/include/arch/linux-arm/AndroidConfig.h" \ CFLAGS="-nostdlib -fno-exceptions -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -Wno-multichar -msoft-float -march=armv5te -mtune=xscale -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -mthumb-interwork -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -DSK_RELEASE -DNDEBUG -g -Wstrict-aliasing=2 -finline-functions -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers -DNDEBUG -UDEBUG -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64" \ LIBS="-L$SDK_ROOT/out/target/proct/generic/obj/lib -L$SDK_ROOT/out/target/proct/generic/obj/STATIC_LIBRARIES/libcutils_intermediates/libcutils.a -lc -lm -ldl $SDK_ROOT/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/interwork/libgcc.a"
進入到curl的根目錄,運行這個腳本:
1.2 Make
進入curl的根目錄,運行make curl命令:
1.3 參數配置
您可能會看到參數配置是復雜的。如何設置呢?你應該閱讀curl/ Android.mk的注釋。
2 iOS
我改變了參數的配置,所以配置命令是:
./configure –disable-shared –host=arm-apple-darwin10
3.視窗
打開的vc6curl.dsw,並選擇「DLL Release」來編譯。您會在CURL_ROOT\lib\DLL-Release
發現libcurl.dll和libcurl_imp.lib。
4.關於頭文件
curl/include的頭文件,只在成功配置後使用,頭文件在不同的平台上是不同的。

『柒』 libcurl庫怎麼編譯到codeblocks中

Okay, I managed to build your example successfully with libcurl using
static linkage. The details involved to make this work are quite
intricate -- setting it up correctly can get tricky for the unwary.

Here are the steps I used to make this work, be sure to follow them carefully:

Go to Project build options->Compiler settings->#defines: type in CURL_STATICLIB.
When this is defined the libcurl.h header will have its function
signatures preprocessed to fit static linkage. Otherwise dynamic linkage
is assumed and the mangled names then become _imp__*. The unresolved errors from your screenshot indicate it's attempting a dynamic link rather than the desired static link.

Under Project build options->Linker settings->Link libraries make sure it contains the following: curl, rtmp, idn, ssl, ssh2, crypto, z, ws2_32, wldap32, winmm, gdi32.
Note that order is important. Due to a design deficiency of the gnu
linker, the most dependant libraries need to be listed first followed by
least dependant. Other linkers like msvc link and borland's ilinker do
not exhibit such issues -- the libraries can be listed in any order.
Under Project build options->Linker settings->Other linker options
add in '-static'. This will make sure that the static version of 'idn'
is used. If this switch is omitted then your compiled program could
depend on 'libidn-11.dll' to run which probably isn't what you want.

At this point, you should be able to compile and link libcurl programs without any issues. A couple things worth mentioning,

Under Other linker options the other extra switches from your screenshot aren't needed. 'libcurl.a' is already listed and covered by Link libraries.
The 'libcrypto.a' seems to cover the same references as the
'libeay32.a' so only one of them is needed. However, 'libeay32.a' causes
dynamic linkage despite its larger size. If you want your application
to be 'fully self-contained' use 'libcrypto.a' instead like in the
screenshot.
If you wish to link dynamically in the future, just replace the listing with 'curldll' under Link libraries and remove the CURL_STATICLIB define. The extra libraries (eg. ssl, idn, rtmp etc.) aren't needed since libcurl.dll already covers them.
You can avoid the tedious error prone setup of a new libcurl program by employing codeblocks' user templates. (eg. File->New->Project->User templates)

Hopefully this resolves any build problems you have with libcurl once and for all.

『捌』 libcurl是什麼語言開發的

libcurl是C語言開發的網路庫,支持多種網路協議.
有很多種不同的方式來編譯C語言代碼。這里使用UNIX平台下的編譯方式。即使你使用的是其他的操作系統,你仍然可以通過閱讀本文檔來獲取許多有用的信息。

編譯

你的編譯器必須知道libcurl頭文件的位置。所以在編譯的時候,你要設置頭文件的包含路徑。可以使用curl-config工具來獲取這方面的信息:

$ curl-config –cflags

鏈接

編譯完源碼(這時的源代碼不是指libcurl的源代碼,你是你自己寫的程序代碼)之後,你還必須把目標文件鏈接成單個可執行文件。你要鏈接libcurl庫,以及libcurl所依賴的其他庫,例如OpenSLL庫。當然可能還需要一些其他的操作系統庫。最後你還要設置一些編譯選項,當然可以使用curl-config工具簡化操作:

$curl-config –libs

是否使用SSL

定製編譯libcurl。與其他庫不同的是,libcurl可以定製編譯,根據實際需要是否支持某些特性,如是否支持SSL傳輸,像HTTPS和FTPS。如果決定需要支持SSL,必須在編譯時正確的設置。可以使用』curl-config』來判斷libcurl庫是否支持SSL:

$ curl-config –feature

『玖』 linux編libcurl庫時依賴openssl怎麼編

如果你在編譯時遇到這個錯誤,這可能是下面的原因:你嘗試編譯的程序使用OpenSSL,但是需要和OpenSSL鏈接的文件(庫和頭文件)在你Linux平台上缺少。
要解決這個問題,你需要安裝OpenSSL 開發包,這在所有的現代Linux發行版的標准軟體倉庫中都有。
要在Debian、Ubuntu或者其他衍生版上安裝OpenSSL:

復制代碼
代碼如下:

$ sudo apt-get install libssl-dev

『拾』 如何編譯libcurl

1:linux下源碼編譯
./configure --prefix=/usr/local/curl --disable-shared --enable-static --without-libidn --without-ssl --without-librtmp --without-gnutls --without-nss --without-libssh2 --without-zlib --without-winidn --disable-rtsp --disable-ldap --disable-ldaps --disable-ipv6

注意:不需要其它功能就disable,不然會在連接時報錯, 如果你沒有disable掉,但你的機器上又沒有安裝相應的庫,link時會報錯。

2:windows下源碼編譯
libcurl 7.21以後的版本在Windows下的編譯比較簡單,自帶了MinGW和VC環境的Makefile文件,首先去Curl官網下載源代碼:curl.haxx.se/download.html,任選一個下載即可,推薦這個: curl-7.21.2.tar.gz,下載完成後解壓開,打開命令行進入curl源碼目錄,(在此之前請先設置好MinGW的環境變數):
cd curl-7.21.2
編譯libcurl庫文件:
cd lib
make -f Makefile.m32
等待編譯完成即可
(若需編譯生成curl可執行文件,則執行:
cd ../src
make -f Makefile.m32)

編譯完成後,我們需要復制include頭文件和庫文件到一個目錄供程序開發用
1. 新建curllib目錄
2. 新建curllib/include目錄,將源代碼include目錄里的curl文件夾復制到curllib/include目錄,這些是使用libcurl需要的頭文件
3. 新建curllib/lib目錄,將源代碼lib目錄里編譯好的庫文件libcurl.a,libcurldll.a,libcurl.dll復制到curllib目錄
4. 將MinGW安裝目錄下lib文件夾里的libwldap32.a和libws2_32.a復制到curllib/lib目錄

熱點內容
獨立開發android 發布:2025-04-15 12:52:45 瀏覽:72
主變保護裝置怎麼配置 發布:2025-04-15 12:47:17 瀏覽:81
數組轉化為字元串php 發布:2025-04-15 12:33:10 瀏覽:446
fms資料庫 發布:2025-04-15 12:33:02 瀏覽:660
安卓手機來源於哪個國家 發布:2025-04-15 12:23:12 瀏覽:872
我的世界伺服器怎麼設置領地語 發布:2025-04-15 12:14:11 瀏覽:613
伺服器電腦和硬碟錄像機 發布:2025-04-15 12:13:36 瀏覽:56
php在線時間 發布:2025-04-15 12:13:22 瀏覽:971
iphonevpn怎麼配置 發布:2025-04-15 12:12:06 瀏覽:180
如何改進配置氯化鈉溶液實驗 發布:2025-04-15 12:10:34 瀏覽:213