Hullo guys,
I am trying to use cURL to access the files on an ftp: server - At this stage I am dearly hoping that there is an alternative that doesn't involve downloading a second library.
I'm getting exasperated and come to you for help - hopefully I have not worn my welcome too thin.
I am trying to set up libcurl and have run into a number of difficulties.
Take this code - for example.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
//This program shall test the functions of cURL.
#include<C:\curl\include\curl\curl.h>
#include<iostream>
#include<fstream>
#include<string>
#include<sstream>
using namespace std;
int main()
{
CURL* curl;
curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, "ftp.censored.com");
// curl_easy_setopt(curl, CURLOPT_VERBOSE,1);
}
| |
I get the following errors when I build/run it -
obj\Debug\curl3.o||In function `main':|
D:\Users\Daniel Cohen\Documents\Coding\cpp\curl3\curl3.cpp|14|undefined reference to `_imp__curl_easy_init'|
D:\Users\Daniel Cohen\Documents\Coding\cpp\curl3\curl3.cpp|15|undefined reference to `_imp__curl_easy_setopt'|
||=== Build finished: 2 errors, 0 warnings ===|
It seems obvious that I have failed to set up libcurl properly but cannot find a resource online which tells me how to do it correctly.
I have downloaded it, extracted it and placed it in C:\libcurl
I found a resource online that told me to change my build options in codeblocks
Below I've where/how you should set the compiler/linker options in C::B's GUI (first open the dialog Project -> Build options):
Compiler options:
"-DCURL_STATICLIB" -> add "CURL_STATICLIB" to Compiler settings -> Defines
"-I ..\..\include " -> add "..\..\include " in Search Directories -> Compiler
Linker options:
"-L ..\..\lib\" -> add "..\..\lib" in Search Directories -> Linker
"-lcurl", "-lws2_32", "-lwinmm" -> add "curl", "ws2_32", "winmm" in Linker settings -> Link libraries
|
I followed this advice to no avail.
I get well over 100 errors including c:\program files "undefined reference to `stringprep_check_version'" having changed the settings as suggested.
I also have 1 question relating to something I read on cURL's install webpage.
As a general rule, building a DLL with static CRT linkage is highly
discouraged, and intermixing CRTs in the same app is something to
avoid at any cost.
|
Does this mean it's a bad idea to refer to both MinGW's library and cURL's library in the same program?
Thanks - Dan