I wrote a simple ftp uploader with python, because ftplib is a very simple library, and i wanted to use this script in C but i have no idea, how to do this.
Can you help me? Or can you suggest me an ftp library to use directly on C?
Thanks
I wrote a simple ftp uploader with python, because ftplib is a very simple library, and i wanted to use this script in C but i have no idea, how to do this.
Can you help me? Or can you suggest me an ftp library to use directly on C?
Thanks
Try learning from Beej's Guide to Network Programming.Originally Posted by nicauron
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Or if you are on Windows, you can use it's built in library...
FTP Sessions (Windows)
If you want to use the script you have you can either call it as an external process (using system, ShellExecute, etc...) or look to the python/C api - 5. Embedding Python in Another Application — Python v2.7.2 documentation
I tried to use this library but i found some errorsDev C++ gave me this responseCode:int SendFTP() { HINTERNET hInternet; HINTERNET hFtpSession; hInternet = InternetOpen(NULL,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0); hFtpSession = InternetConnect(hInternet,serverftp , INTERNET_DEFAULT_FTP_PORT,user, password, INTERNET_SERVICE_FTP, 0, 0); if(FtpPutFile(hFtpSession,file, namefile, FTP_TRANSFER_TYPE_BINARY,0) == TRUE){ printf("File Sent! "); } else{ printf("Sending Failed.."); } InternetCloseHandle(hFtpSession); InternetCloseHandle(hInternet); }
: In function `SendFTP':
undefined reference to `InternetOpenA@20'
undefined reference to `InternetConnectA@32'
undefined reference to `FtpPutFileA@20'
undefined reference to `InternetCloseHandle@4'
undefined reference to `InternetCloseHandle@4'
collect2: ld returned 1 exit status
You are missing an #include, have not told the linker about the library, or the library is not in minGW's default path.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
It looks like you didn't include wininet.lib in your linker's list.
Also DevC++ is outdated and abandoned. It is entirely likely that it's missing several of the newer libraries...
If you are doing C-99 only (no C++) you should probably update to Pelles C (free, available in both x86 and x64 flavours, resource editors included and the best help file I've ever seen)
If you are doing C-89 and C++ you most likely want to use Code::Blocks with MinGW (C and C++, x86 only, no resource editors, free)
I'm using Dev-C++ and i made #include <wininet.h>
So what is the problem??
CommonTater told you right here:
The header file just tells the compiler about the functions (name, return type, parameter types and count), it doesn't actually provide the implementations (i.e. there's no code). For that you need to tell the linker where to find the wininet.lib functions. But few of us can tell you where to set that up, since as Tater mentioned, Dev-C++ is outdated and abandoned, so few here use it.
I'm sorry but i don't know how to do it? Can you explain to me? Now I have installed Pelles C
Last edited by nicauron; 07-06-2011 at 10:38 AM.
The folder Path was already charged, and i added the library wininet.lib to the linkers but i already have the same problem.
If you're adding wininet.lib that's already on the default Pelles C search paths.
Did you enable Microsoft Extensions in your Project->Options?
Also if you're using MS library functions you need to set the calling protocal to STDCALL, on the same page.
It might help if you posted the new error messages...
Last edited by CommonTater; 07-06-2011 at 12:24 PM.
it's so weird, i made what you said and now the error changed, now the compiler found some errors in a function that Dev-C++ hadn't found, because the function worked!!
These are the errors:
warning #2027: Missing prototype for 'kp'.
warning #2027: Missing prototype for 'kp'.
warning #2027: Missing prototype for 'sleep'.
warning #2027: Missing prototype for 'SendFTP'.
warning #2096: Missing return value.