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

本秂侑毒 提交于 2020-01-17 17:30:10

问题


i'm getting a peculiar issue when trying to compile my program. I don't have a huge ammount of experience with C++. I'm trying to simple create a function that can FTP put a file upto my plain FTP server. I'm using codeblocks IDE, and the GNU GCC compiler, and in the end, i thought to try a full fledged example i found online to test if it was me writing some silly code. I have installed the windows SDK with all libs, so i can confirm the files are present, and if i build without any code, there is no linker errors.

I copied the OP's code, as it looked fine, and he complained of no such issues. http://social.msdn.microsoft.com/Forums/en-US/76eb8b89-4b96-41ba-b869-e30711f29256/ftpputfile?forum=vcgeneral

However when i attempt to build my project, i get a plethora of errors:

||=== 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)) ===|

Any idea what i'm doing wrong here? Do i need to be using certain compiler settings?


回答1:


For anyone else experiencing this problem. The solution to this, as implied by Igor in the commends on the op, was too manually add a link to the lib. In code blocks, this is accomplished by going to project --> Build Options, click the linker tab, and then manually browse to the file and include it. This has now made my project compile. Why code blocks requires this I don't know. But it does, so thanks Igor.



来源:https://stackoverflow.com/questions/24769097/wininet-h-not-compiling-using-gnu-gcc-compiler-with-code-blocks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!