我目前正在嘗試在Ubuntu 64x 14.04上爲Windows 32x交叉編譯libcurl。一些研究之後,我按照這些步驟:交叉編譯C Windows libcurl在Ubuntu上沒有正確鏈接
1)從https://curl.haxx.se/download.html
2下載庫)進入提取libcurl的文件夾,然後執行:
./configure --host=i686-w64-mingw32 --build=i686-pc-linux-gnu --prefix=/usr/i686-w64-mingw32/ --enable-static --disable-shared
3)執行:使
4)執行:須藤使安裝
然後,我添加這些包括stateme NTS:
#include <winsock2.h> // Needed for curl
#include <windows.h> // Windows API
#include <curl/curl.h>
int main(int argc, char** argv)
{
CURL *curl;
CURLcode response;
char url[] = "someurl.com";
curl = curl_easy_init();
if(curl)
{
curl_easy_setopt(curl, CURLOPT_URL, url); //set url options
/* Perform the request, res will get the return code */
response = curl_easy_perform(curl);
if(response != CURLE_OK)
{
//Do something
}
/* always cleanup */
curl_easy_cleanup(curl);
}
return 0;
}
現在我試圖編譯我的代碼有以下參數:
i686-w64-mingw32-gcc main.c -o main.exe -L/usr/i686-w64-mingw32/lib -lcurl
編譯器返回的以下錯誤代碼:
/tmp/ccebLf6U.o:main.c:(.text+0x336): Not defined reference to `_imp__curl_easy_init'
/tmp/ccebLf6U.o:main.c:(.text+0x365): Not defined reference to `_imp__curl_easy_setopt'
/tmp/ccebLf6U.o:main.c:(.text+0x372): Not defined reference to `_imp__curl_easy_perform'
/tmp/ccebLf6U.o:main.c:(.text+0x3f4): Not defined reference to `_imp__curl_easy_cleanup'
collect2: error: ld returned 1 exit status
有人曾經對如何解決這一問題的想法?
[編輯]
東西真的很有趣,我偶然發現的是,如果你調用捲曲配置你一堆的編譯器選項。
爲什麼你標記[tag:linux]和[tag:ubuntu]如果你包含'windows.h'? – LPs
@LPs閱讀我在第一句話中陳述的內容。我在Ubuntu又名Linux上做了一個交叉編譯,我的問題在於Linux交叉編譯路徑。 – Qubasa