Basicly I want to make a c++ program which does the following:
1- logs in to 4shared.com with username 'user_example' and password 'password_example'.
2- uploads to the 4shared account a file named 'test_upload.txt' located in 'C:\test\'
3- downloads a file named 'test_download.txt' from the 4sared account
I user curl 7.39.0 and curlpp 0.7.3
I don't expect someone to give me a full answer but help me out with some difficulties:
1- how to keep the same session between successive http requests
2- how to make an http request to upload a file
3- how to get the url of a file with specified name on a 4shared account
It looks like 4shared.com supports WebDAV: http://www.4shared.com/faq.jsp#q36 which should be possible to do with libcURL. Unfortunatly they do not list a WebDAV example in their Example Sources section. If you are premium then the FAQ I linked to above says that you can use FTP which does have an example listed at libcURL:
The content of Main.cpp is exactly the same as the content of ftpupload.c but 1 change: I replaces "FILE *stream" with "void *stream" because of another error I received.
Why are you using the command line? For that matter what are you trying to do with libcomdlg32.a? You have to link to libcurl. Undo that change you made to "FILE *stream" and tell us what error you originally got.
How can I link to libcurl? I forgot how I did it for libcomdlg32.a
I have just copied "curl\include" from download pack to "\Program Files (x86)\CodeBlocks\MinGW\"
Since you're using MingW, step one is to launch MSYS. If you do not have MSYS, then you have to download it: http://www.mingw.org/wiki/MSYS
After that, you will have a batch file in what ever directory you installed MSYS to called "msys.bat", run this with administrative privileges. This will open what appears to be a *nix like terminal window. from there use the 'cd' command to change the working directory to the folder where you unzipped cURL to (you may want to redownload cURL for this in case you cut and pasted from your last attempt). Remember to switch out the '\' characters in the normal windows directory with '/' characters. After that, you enter './configure' into the command line and wait a while until in finishes. As the name suggests, this will configure the makefile for you, this takes a while, as in it may be time to run out for coffee or go make yourself a sandwich kind of time pretty much regardless of how powerful your computer is. Get to this point and post back if you have any trouble.
It compiles fine but when I run the program it sais that the program can't start because libcurl.dll is missing from my computer. I don't want my program to use DLL files, I want to use static linking. I found some informations on how do I statically link libcurl:
5.7 in the FAQ says:
When building an application that uses the static libcurl library, you must add -DCURL_STATICLIB to your CFLAGS. Otherwise the linker will look for dynamic import symbols. If you're using Visual Studio, you need to instead add CURL_STATICLIB in the "Preprocessor Definitions" section.
How can I add "-DCURL_STATICLIB" parameter to CFLAGS in Code::Blocks?
I have already added "-DCURL_STATICLIB" to compiler options AND linker options. Also, I have defined CURL_STATICLIB in my script before including curl/curl.h. I don't know what libraries to import, I tried many of them I've downloaded, I tried libcurl.lib, all of the .a and the .dll.a files. This thing makes me crazy, I don't know what to do, all forums are full of posts that don't work.
Also, I don't know how should I define REMOTE_URL in order to upload the file 'C:\test\test_upload.txt' to the 4shared.com account with username 'user_example' and password 'password_example':
There will be two versions of the "libcurl.a" file, one that is intended for statically linking and one that is meant for dynamic linking. So make sure you are linking to the correct file in that regard. If you are getting that error then it sounds like you are linking to the dynamic version of the file.
How should I define REMOTE_URL in order to upload the file 'C:\test\test_upload.txt' to the 4shared.com account with username 'user_example' and password 'password_example'?