在Linux for Windows下,将libcurl与mingw32进行交叉编译 [英] Linking libcurl while cross compiling with mingw32 under Linux for Windows

查看:445
本文介绍了在Linux for Windows下,将libcurl与mingw32进行交叉编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编译libcurl使用mingw32和我试图链接它与我的程序使用mingw32 Windows系统从我的Linux机器。



我输出的文件,



我已经将它们包含在我的mingw32 libs文件夹中:/ usr / x86_64-w64-mingw32 / libclub- lib



我能够找到关于链接libstdc ++和libgcc的一些其他主题在执行时注意依赖关系错误,但是当试图添加libcurl.a它不会

  $ x86_64- w64-mingw32-g ++ main.cpp -o hello.exe -static-libgcc -static-libstdc ++ -static/usr/x86_64-w64-mingw32/lib/libcurl.a-lpthread 

但是,我不能让它使用libcurl.a并继续收到这些错误。

  /tmp/ccIceRus.o:main.cpp :( .text + 0xde):未定义的引用`__imp_curl_easy_init'
/tmp/ccIceRus.o: main.cpp :(。text + 0x106):未定义引用`__imp_curl_easy_setopt'
/tmp/ccIceRus.o:main.cpp:(.text+0x122):未定义引用`__imp_curl_easy_setopt'
/ tmp / ccIceRus.o:main.cpp :(。text + 0x13e):未定义引用`__imp_curl_easy_setopt'
/tmp/ccIceRus.o:main.cpp:(.text+0x159):未定义引用`__imp_curl_easy_setopt '
/tmp/ccIceRus.o:main.cpp:(.text+0x169):未定义引用`__imp_curl_easy_perform'
/tmp/ccIceRus.o:main.cpp:(.text+0x180) :未定义的引用`__imp_curl_easy_strerror'
/tmp/ccIceRus.o:main.cpp:(.text+0x197):未定义的引用`__imp_curl_easy_cleanup'
/ usr / bin / x86_64-w64-mingw32- ld:/tmp/ccIceRus.o:`rex地址0x80错误的地址0x80
collect2:错误:ld返回1退出状态

我做错了什么?我不能通过这个。我知道它必须有一些愚蠢的问题。



谢谢。

解决方案

我能够通过指定-DCURL_STATICLIB来解决问题,以及链接一些其他依赖关系。

  x86_64-w64 -mingw32-g ++ main.cpp -o hello.exe -DCURL_STATICLIB -static -lstdc ++ -lgcc -lpthread -lcurl -lwldap32 -lws2_32 


I have compiled libcurl using mingw32 and am trying to link it with my program using mingw32 for a Windows system from my Linux machine.

I was outputted the files, libcurl-4.dll libcurl.a libcurl.la libcurl.lai.

I have included them in my mingw32 libs folder at: /usr/x86_64-w64-mingw32/lib

I was able to find a few other topics on linking with the libstdc++ and libgcc to take care dependency errors while executed but when trying to add libcurl.a it will not compile period.

I used the following:

$ x86_64-w64-mingw32-g++ main.cpp -o hello.exe -static-libgcc -static-libstdc++ -static "/usr/x86_64-w64-mingw32/lib/libcurl.a" -lpthread

However, I cannot not get it to use the libcurl.a and am continuing to receive these errors.

/tmp/ccIceRus.o:main.cpp:(.text+0xde): undefined reference to `__imp_curl_easy_init'
/tmp/ccIceRus.o:main.cpp:(.text+0x106): undefined reference to `__imp_curl_easy_setopt'
/tmp/ccIceRus.o:main.cpp:(.text+0x122): undefined reference to `__imp_curl_easy_setopt'
/tmp/ccIceRus.o:main.cpp:(.text+0x13e): undefined reference to `__imp_curl_easy_setopt'
/tmp/ccIceRus.o:main.cpp:(.text+0x159): undefined reference to `__imp_curl_easy_setopt'
/tmp/ccIceRus.o:main.cpp:(.text+0x169): undefined reference to `__imp_curl_easy_perform'
/tmp/ccIceRus.o:main.cpp:(.text+0x180): undefined reference to `__imp_curl_easy_strerror'
/tmp/ccIceRus.o:main.cpp:(.text+0x197): undefined reference to `__imp_curl_easy_cleanup'
/usr/bin/x86_64-w64-mingw32-ld: /tmp/ccIceRus.o: bad reloc address 0x80 in section `.xdata'
collect2: error: ld returned 1 exit status

What am I doing wrong?. I can not get past this. I know it has to be some stupid issue.

Thank you.

解决方案

I was able to solve the question by specifying -DCURL_STATICLIB, as well as linking some other dependencies.

x86_64-w64-mingw32-g++ main.cpp -o hello.exe -DCURL_STATICLIB -static -lstdc++ -lgcc -lpthread -lcurl -lwldap32 -lws2_32

这篇关于在Linux for Windows下,将libcurl与mingw32进行交叉编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆