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 6798333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:43:03+00:00 2026-05-26T18:43:03+00:00

I have 2 files, grabURL.cpp and grabURL.hpp. When I compile the both with gcc

  • 0

I have 2 files, grabURL.cpp and grabURL.hpp. When I compile the both with gcc it gives me multiple definitions errors.

grabURL.cpp

#include "grabURL.hpp"
size_t buffer(void *ptr, size_t size, size_t nmemb, void *stream) { 
            int numbytes = size*nmemb; 
            char lastchar = *((char *) ptr + numbytes - 1); 
        *((char *) ptr + numbytes - 1) = '\0'; 
            ret.append((char *)ptr); 
            ret.append(1,lastchar); 
        *((char *) ptr + numbytes - 1) = lastchar;
    return size*nmemb; 
 }
void grabURL(std::string url, std::string *theRet){
    curl_easy_setopt(curl,CURLOPT_URL,url.c_str());
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION, buffer);
res = curl_easy_perform(curl);
*theRet = ret;
}

grabURL.hpp:

#ifndef CURLURLGRAB_HPP
#define CURLURLGRAB_HPP
#include <string>
#include <curl/curl.h>
CURL * curl;
CURLcode res;
std::string ret;
size_t buffer(void *ptr, size_t size, size_t nmemb, void *stream);
void grabURL(std::string url,std::string* theRet);

#endif

I have no idea what I am doing wrong, I thought I did the ifndef thing correctly. What exactly is wrong?

  • 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-26T18:43:03+00:00Added an answer on May 26, 2026 at 6:43 pm

    This definitions in your header file:

    CURL * curl;
    CURLcode res;
    std::string ret;
    

    get defined when you include the file from the cpp file, and pressumably some other translation unit (perhaps main.cpp?)

    They don’t look like something that should be in a header file, but if they do then you can declare them extern within the header file and move the actual definitions to the cpp file.

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

Sidebar

Related Questions

I have files served like so: AJAX request handler -> Include file I would
Suppose I have files a.cpp and b.cpp and I get warnings in a.cpp and
Lets say I have files: Libs: one.cpp, one.h two.cpp, two.h three.cpp, three.h Program: program.cpp
I have files which have many empty cells which appear as NaNs when I
I am constantly noticing that I have files checked out for editing that I
In my Visual Studio 2010 project I have files with .mm file extension, that
I have a problem in giving Ajax functionality to a hyperlink. I have files
Possible Duplicate: Regex for matching javadoc fragments I have files having content like /**
I'm probably missing something very obvious here. I have files with the extension .st
We have some files on our website that users of our software can download.

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.