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

  • SEARCH
  • Home
  • 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 6996605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:10:45+00:00 2026-05-27T20:10:45+00:00

I’ve tried now days to get up a libcurl sample c++ code running in

  • 0

I’ve tried now days to get up a libcurl sample c++ code running in Netbeans (Compiler is cygwin) on a Windows machine but it failes every time.
I’ve also searched through the web (and also through stackoverflow) but can’t find a solution… 🙁

Here is just the sample code i want to run…

#include <cstdlib>
#include <curl/curl.h>

using namespace std;

/*
 * 
 */
int main(int argc, char** argv) {
    CURL *curl;
    CURLcode res;

    curl = curl_easy_init();
    if(curl) {
    curl_easy_setopt(curl, CURLOPT_URL, "http://google.com");
    res = curl_easy_perform(curl);

    curl_easy_cleanup(curl);
    }

    return 0;
}

here is the compiler result:

"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/cygdrive/c/Users/Alexander/Documents/NetBeansProjects/CppApplication_3'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/Cygwin_4.x_1-Windows/cppapplication_3.exe
make[2]: Entering directory `/cygdrive/c/Users/Alexander/Documents/NetBeansProjects/CppApplication_3'
mkdir -p build/Debug/Cygwin_4.x_1-Windows
rm -f build/Debug/Cygwin_4.x_1-Windows/main.o.d
g++.exe -lcurl   -c -g -MMD -MP -MF build/Debug/Cygwin_4.x_1-Windows/main.o.d -o build/Debug/Cygwin_4.x_1-Windows/main.o main.cpp
mkdir -p dist/Debug/Cygwin_4.x_1-Windows
g++.exe -lcurl    -o dist/Debug/Cygwin_4.x_1-Windows/cppapplication_3 build/Debug/Cygwin_4.x_1-Windows/main.o  
build/Debug/Cygwin_4.x_1-Windows/main.o: In function `main':
/cygdrive/c/Users/Alexander/Documents/NetBeansProjects/CppApplication_3/main.cpp:20: undefined reference to `_curl_easy_init'
/cygdrive/c/Users/Alexander/Documents/NetBeansProjects/CppApplication_3/main.cpp:22: undefined reference to `_curl_easy_setopt'
/cygdrive/c/Users/Alexander/Documents/NetBeansProjects/CppApplication_3/main.cpp:23: undefined reference to `_curl_easy_perform'
/cygdrive/c/Users/Alexander/Documents/NetBeansProjects/CppApplication_3nbproject/Makefile-Debug.mk:61: recipe for target `dist/Debug/Cygwin_4.x_1-Windows/cppapplication_3.exe' failed
make[2]: Leaving directory `/cygdrive/c/Users/Alexander/Documents/NetBeansProjects/CppApplication_3'
nbproject/Makefile-Debug.mk:58: recipe for target `.build-conf' failed
make[1]: Leaving directory `/cygdrive/c/Users/Alexander/Documents/NetBeansProjects/CppApplication_3'
/main.cpp:25: undefined reference to `_curl_easy_cleanup'
nbproject/Makefile-impl.mk:39: recipe for target `.build-impl' failed
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/Cygwin_4.x_1-Windows/cppapplication_3.exe] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 2s)

The libcurl is also installed as a package within cygwin…
The libcurl.a is located at ‘E:\cygwin\lib’ and the cygcurl-4.dll is located at ‘E:\cygwin\bin’.

If someone could help me that would be so great!

Thanks in advance!
Regards,
Alex

  • 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-27T20:10:46+00:00Added an answer on May 27, 2026 at 8:10 pm

    Put the -l option at the end of your link command, like this:

    g++ -o main main.o -lcurl
    

    So in your case the output shall look like so:

    g++.exe -o dist/Debug/Cygwin_4.x_1-Windows/cppapplication_3 build/Debug/Cygwin_4.x_1-Windows/main.o -lcurl
    

    Verbatim from the gcc manual:

    It makes a difference where in the command you write this [-l] option; the
    linker searches and processes libraries and object files in the order
    they are specified. Thus, foo.o -lz bar.o' searches libraryz’ after
    file foo.o but before bar.o. If bar.o refers to functions in `z’,
    those functions may not be loaded.

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.