【问题标题】:wininet.h not compiling using GNU GCC compiler with code blockswininet.h 不使用带有代码块的 GNU GCC 编译器进行编译
【发布时间】:2014-07-15 22:16:31
【问题描述】:

我在尝试编译我的程序时遇到了一个特殊问题。我没有大量的 C++ 经验。我正在尝试简单地创建一个函数,该函数可以 FTP 将文件放到我的普通 FTP 服务器上。我正在使用 codeblocks 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++\uploader\main.cpp||In function 'void FileSubmit()':|
C:\C++\uploader\main.cpp|10|warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]|
C:\C++\uploader\main.cpp|11|warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]|
C:\C++\uploader\main.cpp|12|warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]|
obj\Debug\main.o:main.cpp|| undefined reference to `InternetOpenA@20'|
obj\Debug\main.o:main.cpp|| undefined reference to `InternetConnectA@32'|
obj\Debug\main.o:main.cpp|| undefined reference to `FtpPutFileA@20'|
obj\Debug\main.o:main.cpp|| undefined reference to `InternetCloseHandle@4'|
obj\Debug\main.o:main.cpp|| undefined reference to `InternetCloseHandle@4'|
||=== Build failed: 5 error(s), 3 warning(s) (0 minute(s), 1 second(s)) ===|

知道我在这里做错了什么吗?我需要使用某些编译器设置吗?

【问题讨论】:

  • 您是否在包含链接器抱怨的符号定义的库中进行链接?
  • 我已经在我的头文件中包含了#include ,如果这就是你的意思吗?找到这个没有问题。
  • 你得到的不是编译器错误,而是链接器错误。您需要与wininet.lib 链接。在你问之前,我不知道如何使用 GCC 或 CodeBlocks - 我是一名 MSVC 人。

标签: c++ gcc ftp codeblocks wininet


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多