I tried to fix the original curl C++ code, but it is not compiling for me.
The revised code is attached.
The message given when it says error, is attached too.
Please help.
#include "curl.h"
#include "easy.h"
size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream) {
size_t written;
written = fwrite(ptr, size, nmemb, stream);
return written;
}
CURL *curl;
FILE *fp;
CURLcode res;
long lSize;
char *translated;
void Func() {
curl = curl_easy_init();
if(curl) {
fp = fopen("C:\\trans.txt","wb");
curl_easy_setopt(curl, CURLOPT_URL,
"http://paaaagggeeee.com/123.html");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
fclose(fp);
}
fp = fopen("C:\\Output.txt","rb");
fseek (fp , 0 , SEEK_END);
lSize = ftell (fp);
rewind (fp);
fread (translated,1,lSize,fp);
translated[lSize] = 0;
fclose(fp);
}1>------ Build started: Project: project1, Configuration: Debug Win32 ------
1> main.cpp
1>c:\documents and settings\alex\my documents\visual studio
2010\projects\project1\project1\main.cpp(19): warning C4996: 'fopen': This
function or variable may be unsafe. Consider using fopen_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio
10.0\vc\include\stdio.h(234) : see declaration of 'fopen'
1>c:\documents and settings\alex\my documents\visual studio
2010\projects\project1\project1\main.cpp(27): warning C4996: 'fopen': This
function or variable may be unsafe. Consider using fopen_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio
10.0\vc\include\stdio.h(234) : see declaration of 'fopen'
1>C:\Program
Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning
MSB8012: TargetPath(C:\Documents and Settings\alex\my documents\visual studio
2010\Projects\project1\project1\project1.exe) does not match the Linker's
OutputFile property value (C:\Documents and Settings\alex\my documents\visual
studio 2010\Projects\project1\Debug\project1.exe). This may cause your project
to build incorrectly. To correct this, please make sure that $(OutDir),
$(TargetName) and $(TargetExt) property values match the value specified in
%(Link.OutputFile).
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_easy_cleanup
referenced in function "void __cdecl Func(void)" (?Func@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_easy_perform
referenced in function "void __cdecl Func(void)" (?Func@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_easy_setopt
referenced in function "void __cdecl Func(void)" (?Func@@YAXXZ)
1>main.obj : error LNK2019: unresolved external symbol __imp__curl_easy_init
referenced in function "void __cdecl Func(void)" (?Func@@YAXXZ)
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main
referenced in function ___tmainCRTStartup
1>C:\Documents and Settings\alex\my documents\visual studio
2010\Projects\project1\Debug\project1.exe : fatal error LNK1120: 5 unresolved
externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html