0

How can I cross compile "cURL" for windows on linux(actually using kali)? Or is there a linux distro where the cross compile environment is already built or where the cross compile environment is simple to build? Please Help!

I have Mingw working fine with header files already in its include directory. Now I compiled cURL and verified its existence in Mingw's include directory. But now when I include <curl/curl.h> in my code, this is the error I will get during compile time:

/tmp/ccsrpc1o.o:https.c:(.text+0x1c): undefined reference to `__imp__curl_global_init'
/tmp/ccsrpc1o.o:https.c:(.text+0x26): undefined reference to `__imp__curl_easy_init'
/tmp/ccsrpc1o.o:https.c:(.text+0x4a): undefined reference to `__imp__curl_easy_setopt'
/tmp/ccsrpc1o.o:https.c:(.text+0x5a): undefined reference to `__imp__curl_easy_perform'
/tmp/ccsrpc1o.o:https.c:(.text+0x73): undefined reference to `__imp__curl_easy_strerror'
/tmp/ccsrpc1o.o:https.c:(.text+0xb2): undefined reference to `__imp__curl_easy_cleanup'
/tmp/ccsrpc1o.o:https.c:(.text+0xbc): undefined reference to `__imp__curl_global_cleanup'
collect2: ld returned 1 exit status
  • 1
    Mingw is the cross compiling tool you are looking for. – xuhdev Jul 07 '15 at 05:59
  • I have Mingw working fine with headers already in its include directory. Now I compiled cURL and verified its existence in Mingw's include directory. But now when I include in my code, this is the error I will get during compile time: (I'm going to edit the question, it can't fit in here lol) – DisjointTech Jul 07 '15 at 06:56
  • This is not a include issue, its a linker issue, what means he cant find the compiled library binary at all. – Nidhoegger Jul 07 '15 at 07:03
  • How can I accomplish this linking? I'm using the "i586-mingw32msvc-gcc" command, is there an option like the linking option with gcc: $ gcc -o https https.c -lcurl – DisjointTech Jul 07 '15 at 07:33
  • You should at least be able to specify library to link with directly with full path with something like `i586-mingw32msvc-gcc -o https https.c /path/to/curl/libcurl.a` – dewaffled Jul 07 '15 at 09:32
  • Also, check [this](http://stackoverflow.com/a/20728782/4074081) discussion – dewaffled Jul 07 '15 at 09:34
  • Hello frymode, I tried that command but I'm still getting the same error, I may had compiled "libcurl" wrongly. Can you guide me on how to cross compile "libcurl"? I was thinking that might be the issue. – DisjointTech Jul 07 '15 at 18:33
  • try add a preprocessor flag "CURL_STATICLIB" – Sany Liew Jul 08 '15 at 01:00
  • I've found the solution, I recompiled curl with the --with-winssl option instead of the --with-ssl option. Now I can compiled the https.c file, but when I try to run it on a windows xp with sp3, it return "libcurl-4.dll not found". To get the program ruunning, do I have to install "libcurl" on windows too? – DisjointTech Jul 09 '15 at 02:00
  • Thank you all for assisting me in finding the solution to this issue!!! – DisjointTech Sep 21 '15 at 15:13

1 Answers1

1

First cross compile cURL with these commands:

$ ./configure --host=i586-mingw32msvc --enable-http --with-zlib --with-winssl
$ make
$ make install

And you can now compile your code(s):

$ i586-mingw32msvc-gcc -o https.exe https.c -lcurl or

$ i586-mingw32msvc-gcc -o https.exe https.c /usr/i586-mingw32msvc/lib/libcurl.dll.a