wininet.h不使用带有代码块的GNU GCC编译器编译

wininet.h not compiling using GNU GCC compiler with code blocks

本文关键字:GNU GCC 编译 编译器 代码 wininet      更新时间:2023-10-16

我在编译程序时遇到了一个特殊的问题。我在c++方面没有丰富的经验。我试图简单地创建一个功能,可以FTP把文件到我的普通FTP服务器。我正在使用代码块IDE和GNU GCC编译器,最后,我想尝试一个我在网上找到的完整的例子来测试是不是我写了一些愚蠢的代码。我已经安装了windows SDK与所有库,所以我可以确认文件存在,如果我构建没有任何代码,没有链接器错误。

我复制了OP的代码,因为它看起来很好,他抱怨没有这样的问题。http://social.msdn.microsoft.com/Forums/en-US/76eb8b89-4b96-41ba-b869-e30711f29256/ftpputfile?forum=vcgeneral

然而,当我试图构建我的项目,我得到一个过多的错误:

||=== Build: Debug in uploader (compiler: GNU GCC Compiler) ===|
C:C++uploadermain.cpp||In function 'void FileSubmit()':|
C:C++uploadermain.cpp|10|warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]|
C:C++uploadermain.cpp|11|warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]|
C:C++uploadermain.cpp|12|warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]|
objDebugmain.o:main.cpp|| undefined reference to `InternetOpenA@20'|
objDebugmain.o:main.cpp|| undefined reference to `InternetConnectA@32'|
objDebugmain.o:main.cpp|| undefined reference to `FtpPutFileA@20'|
objDebugmain.o:main.cpp|| undefined reference to `InternetCloseHandle@4'|
objDebugmain.o:main.cpp|| undefined reference to `InternetCloseHandle@4'|
||=== Build failed: 5 error(s), 3 warning(s) (0 minute(s), 1 second(s)) ===|

你知道我哪里做错了吗?我需要使用某些编译器设置吗?

对于遇到此问题的其他人。正如Igor在op的注释中所暗示的那样,解决这个问题的方法是手动添加到库的链接。在代码块中,这是通过进入project -> Build Options,单击链接器选项卡,然后手动浏览到文件并包含它来完成的。这现在已经使我的项目编译。为什么代码块需要这样,我不知道。但确实如此,所以谢谢你,伊戈尔。