Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6102511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:37:21+00:00 2026-05-23T13:37:21+00:00

I need link cURL in Ubuntu 11.04 after installed cURL by source code. .

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:37:21+00:00Added an answer on May 23, 2026 at 1:37 pm

    This should do the job. You didn’t really link to cURL before.

    build: $(SOURCES)
        $(CXX) -o $(OUT) $(INCLUDE) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $(SOURCES)
    

    Notice the added $(LDLIBS).

    Oh, I should add that basically what happens is that you throw overboard the built-in rules of GNU make (see output of make -np) and define your own. I would suggest that you either use the built-in ones if you want to rely on the respective variables to be sufficient to control the build or that you still split it up into compilation and link step for the sake of brevity.

    Brief explanation: GNU make comes with a rule that states how to make a .o file from a .cpp (or .c) file. So your make file could perhaps be rewritten to (approx.)

    # Testing cURL
    # MAKEFILE
    
    # C++ Compiler (Default: g++)
    CXX = g++
    CFLAGS = -Wall -Werror
    
    # Librarys
    INCLUDE = -I/usr/local/include
    LDFLAGS = -L/usr/local/lib 
    LDLIBS = -lcurl
    
    # Details
    SOURCES = src/main.cpp
    OUT = test
    
    .PHONY: all
    
    all: build
    
    $(OUT): $(patsubst %.cpp,%.o,$(SOURCES))
    

    This should generate the binary with the name test (contents of OUT) and makes otherwise use of the built-in rules. Make infers from the use of .o files that there must be source files, will look for them and compile them. So implicitly this build will run one invocation for each .cpp file and one for the linking step.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I know that in C you need to link the code to the
I need to display link after each comment, when you click that link, a
I need to link our C/C++ code that is using the DB2 ODBC driver
I have a ListView that displays a link button. I need the link button
I need to replace link index.php?a=2 ,but if it's have & after a=2 then
I have the code to extract the links, but I need the link label
I have a PHP code that will return a image. the link is given
I need a link in an HTML page that could use any JavaScript to
I need a link to invoke a flash movie (with javascript) that takes the
I need to link to a category in my wordpress site. The following code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.