An alternative to libcurl?

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
If your curl lib is in C:\libcurl, you might need -L C:\libcurl as well as the other flags.

Or is ..\..\lib the path to the right directory??
Last edited on
-L C:\libcurl means putting this in the build options and it points the linker toward the libcurl library?

I should have actually mentioned it a day or two ago but I found a way to circumvent the need for libcurl in my program...

Still appreciate any help.

Thanks - Dan
Yes, it's a build option

Each small -l adds a library to look for
Each capital -L adds a directory to add to the library search path

Andy
You never need any lib on Windows, everything is included

Just use Wininet apis
Topic archived. No new replies allowed.