Using Libcurl Dev C++ Undefined Reference Errors

******MY CODE:********* -compiler: devc++ 5.11 libcurl version: 7.60

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
#include <curl/types.h>
#include <curl/easy.h>


int main()
{

curl_global_init( CURL_GLOBAL_ALL );
CURL * myHandle = curl_easy_init ( );

// Set up a couple initial paramaters that we will not need to mofiy later.
curl_easy_setopt(myHandle, CURLOPT_USERAGENT, "Mozilla/4.0");
curl_easy_setopt(myHandle, CURLOPT_AUTOREFERER, 1 );
curl_easy_setopt(myHandle, CURLOPT_FOLLOWLOCATION, 1 );
curl_easy_setopt(myHandle, CURLOPT_COOKIEFILE, "");

// Visit the login page once to obtain a PHPSESSID cookie
curl_easy_setopt(myHandle, CURLOPT_URL, "http://www.hackthissite.org/user/login/");
curl_easy_perform( myHandle );


// Now, can actually login. First we forge the HTTP referer field, or HTS will deny the login
curl_easy_setopt(myHandle, CURLOPT_REFERER, "http://www.hackthissite.org/user/login/");
// Next we tell LibCurl what HTTP POST data to submit
char *data="username=your_username_here&password=your_password_here";
curl_easy_setopt(myHandle, CURLOPT_POSTFIELDS, data);
curl_easy_perform( myHandle );

curl_easy_cleanup( myHandle );


return 0;
}


**************ERRORS:*****************

C:\Users\b0600539\Downloads\Dev-Cpp\MinGW64\libcurl\Untitled9.cpp [Error] curl/types.h: No such file or directory
compilation terminated.
C:\Users\b0600539\Downloads\Dev-Cpp\MinGW64\libcurl\Makefile.win recipe for target 'Untitled9.o' failed


********When I delete the "#include <curl/types.h>" from the code I get the following errors:********

C:\Users\b0600539\Downloads\Dev-Cpp\MinGW64\libcurl\Untitled9.cpp In function 'int main()':

C:\Users\b0600539\Downloads\Dev-Cpp\MinGW64\libcurl\Untitled9.cpp [Warning] deprecated conversion from string constant to 'char*' [-Wwrite-strings]

C:\Users\b0600539\Downloads\Dev-Cpp\MinGW64\libcurl\Untitled9.o Untitled9.cpp:(.text+0x15): undefined reference to `__imp_curl_global_init'
C:\Users\b0600539\Downloads\Dev-Cpp\MinGW64\libcurl\Untitled9.o Untitled9.cpp:(.text+0x1e): undefined reference to `__imp_curl_easy_init'
C:\Users\b0600539\Downloads\Dev-Cpp\MinGW64\libcurl\Untitled9.o Untitled9.cpp:(.text+0x3e): undefined reference to `__imp_curl_easy_setopt'
C:\Users\b0600539\Downloads\Dev-Cpp\MinGW64\libcurl\Untitled9.o Untitled9.cpp:(.text+0x59): undefined reference to `__imp_curl_easy_setopt'
C:\Users\b0600539\Downloads\Dev-Cpp\MinGW64\libcurl\Untitled9.o Untitled9.cpp:(.text+0x74): undefined reference to `__imp_curl_easy_setopt'
C:\Users\b0600539\Downloads\Dev-Cpp\MinGW64\libcurl\Untitled9.o Untitled9.cpp:(.text+0x90): undefined reference to `__imp_curl_easy_setopt'
C:\Users\b0600539\Downloads\Dev-Cpp\MinGW64\libcurl\Untitled9.o Untitled9.cpp:(.text+0xac): undefined reference to `__imp_curl_easy_setopt'
C:\Users\b0600539\Downloads\Dev-Cpp\MinGW64\libcurl\Untitled9.o Untitled9.cpp:(.text+0xbc): undefined reference to `__imp_curl_easy_perform'
C:\Users\b0600539\Downloads\Dev-Cpp\MinGW64\libcurl\Untitled9.o Untitled9.cpp:(.text+0xd8): undefined reference to `__imp_curl_easy_setopt'
C:\Users\b0600539\Downloads\Dev-Cpp\MinGW64\libcurl\Untitled9.o Untitled9.cpp:(.text+0xff): undefined reference to `__imp_curl_easy_setopt'
C:\Users\b0600539\Downloads\Dev-Cpp\MinGW64\libcurl\Untitled9.o Untitled9.cpp:(.text+0x10f): undefined reference to `__imp_curl_easy_perform'
C:\Users\b0600539\Downloads\Dev-Cpp\MinGW64\libcurl\Untitled9.o Untitled9.cpp:(.text+0x11f): undefined reference to `__imp_curl_easy_cleanup'
C:\Users\b0600539\Downloads\Dev-Cpp\MinGW64\libcurl\collect2.exe [Error] ld returned 1 exit status
C:\Users\b0600539\Downloads\Dev-Cpp\MinGW64\libcurl\Makefile.win recipe for target 'Project8.exe' failed



How do I fix these undefined reference errors? Also, what is the equivalent of types.h header file in curl 7.60? This version of curl doesn't come with that header file.
Last edited on
Topic archived. No new replies allowed.