我需要在ubuntu 16上编译App.exe。我安装了mingw-w64,openssl和curl:
sudo apt-get install mingw-w64
wget http://www.openssl.org/source/openssl-1.0.2k.tar.gz
tar -xzvf openssl-1.0.2k.tar.gz
cd openssl-1.0.2k/
./Configure mingw64 shared --cross-compile-prefix=x86_64-w64-mingw32- --prefix=/usr/x86_64-w64-mingw32/
make
sudo make install
cd ..
wget https://curl.haxx.se/download/curl-7.53.1.tar.gz
tar -xzvf curl-7.53.1.tar.gz
cd curl-7.53.1/
./configure --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --build=i686-pc-linux-gnu --prefix=/usr/x86_64-w64-mingw32 --enable-static --disable-shared --with-ssl --with-zlib
make
sudo make install
cd ..
x86_64-w64-mingw32-g++ -v -o test.exe test.cpp -static -DCURL_STATICLIB -lcurl
安装执行没有错误,但在编译时:
x86_64-w64-mingw32-g++ -v -o test.exe test.cpp -static -DCURL_STATICLIB -lcurl
TEST.CPP:
#include <iostream>
#include <curl/curl.h>
using namespace std;
int main(int argc, char **argv)
{
cout << curl_version() << endl;
return 0;
}
编译其他错误:
...
/usr/lib/gcc/x86_64-w64-mingw32/5.3-win32/../../../../x86_64-w64-mingw32/lib/libcurl.a(libcurl_la-curl_ntlm_core.o):curl_ntlm_core.c:(.text+0x202): undefined reference to `DES_ecb_encrypt'
/usr/lib/gcc/x86_64-w64-mingw32/5.3-win32/../../../../x86_64-w64-mingw32/lib/libcurl.a(libcurl_la-curl_ntlm_core.o):curl_ntlm_core.c:(.text+0x2fe): undefined reference to `MD4_Init'
/usr/lib/gcc/x86_64-w64-mingw32/5.3-win32/../../../../x86_64-w64-mingw32/lib/libcurl.a(libcurl_la-curl_ntlm_core.o):curl_ntlm_core.c:(.text+0x30c): undefined reference to `MD4_Update'
/usr/lib/gcc/x86_64-w64-mingw32/5.3-win32/../../../../x86_64-w64-mingw32/lib/libcurl.a(libcurl_la-curl_ntlm_core.o):curl_ntlm_core.c:(.text+0x317): undefined reference to `MD4_Final'
collect2: error: ld returned 1 exit status
我不知道我错在哪里。你呢?