I need link cURL in Ubuntu 11.04 after installed cURL by source code.
.
Correction of the PROBLEM
First I discovered that the -l must come before the -L and then discovered that I was not entering a variable in the makefile.
.
Get cURL Configs:
On my termial:
# curl-config --libs
-L/usr/local/lib -lcurl
# curl-config --cflags
-I/usr/local/include
It's all right, where this directory there are files cURL.
My Makefile:
# Testing cURL
# MAKEFILE
# C++ Compiler (Default: g++)
CXX = g++
CFLAGS = -Wall -Werror
# Librarys
INCLUDE = -Iusr/local/include
LDFLAGS = -Lusr/local/lib
LDLIBS = -lcurl
# Details
SOURCES = src/main.cpp
OUT = test
all: build
build: $(SOURCES)
$(CXX) -o $(OUT) $(INCLUDE) $(CFLAGS) $(LDFLAGS) $(SOURCES)
My C++ Source Code:
#include <iostream>
#include <curl/curl.h>
int main( void )
{
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
return 0;
}
And the ERROR:
# make
g++ -o test -Iusr/local/include -Wall -Werror -Lusr/local/lib src/main.cpp
/tmp/ccli90i2.o: In function `main':
main.cpp:(.text+0xa): undefined reference to `curl_easy_init'
main.cpp:(.text+0x31): undefined reference to `curl_easy_setopt'
main.cpp:(.text+0x3d): undefined reference to `curl_easy_perform'
main.cpp:(.text+0x4d): undefined reference to `curl_easy_cleanup'
collect2: ld returned 1 exit status
make: ** [build] Erro 1
I know this is a error of not finding the library, but for me everything is correct