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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:05:23+00:00 2026-06-15T10:05:23+00:00

I am holily convinced that this is an extremely basic thing that every living

  • 0

I am holily convinced that this is an extremely basic thing that every living human being is perfectly able to perform, yet somehow it’s not working for me. The FAQ and many other threads/questions found through Google have not fixed this for me.

The situation is as follows: I have one Visual Studio 2010 project. This project is located in a Visual Studio 2010 solution. The project has the following files:

add.h:

class Adder {
public:
    static int add(int i1, int i2);
};

add.cpp:

class Adder {
public:
    static int add(int i1, int i2) {
        return i1 + i2;
    }
};

main.cpp:

#include "add.h"

int main() {
    Adder::add(5, 6);
    return 0;
}

When attempting to run this code, which looks fairly basic to me, I get the following linker error:

main.obj : error LNK2019: unresolved external symbol "public: static int __cdecl Adder::add(int,int)" (?add@Adder@@SAHHH@Z) referenced in function _main

From what I could gather, this implies that the linker could not find the implementation for Adder::add(). However, the files are in exactly the same project, the generated .obj files are in exactly the same folder, and every single tutorial I’ve read on the subject of classes and header files tells me that this should work.

I’ve tried the following potential solutions thus far:

  • Add the project’s own folder to additional includes/dependencies/sources/whatevers
  • Add extern identifiers to various things
  • Use a seperate namespace
  • Various other small adjustments in the hope they would work

So I guess my problem boils down to: How can I get the linker to notice the add.cpp file? Any help is appreciated, I’ve spent several hours on this now without success, while this seems like an extremely basic thing to me.

  • 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-06-15T10:05:24+00:00Added an answer on June 15, 2026 at 10:05 am

    The following defines a whole new class

    //add.cpp:
    class Adder {
    public:
        static int add(int i1, int i2) {
            return i1 + i2;
        }
    };
    

    different from the one in the header, available only to this translation unit (“add.cpp”).

    What it should contain is:

    //add.cpp
    #include "add.h"
    int Adder::add(int i1, int i2) {
        return i1 + i2;
    }
    

    This implements the method defined in the class from the header add.h.

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

Sidebar

Related Questions

I have a CSS <ul> <li> nested menu that works perfectly in IE 8
I have a column in a dataframe like this: npt2$name # [1] Andreas Groll,
Could someone please explain what the for loop in this class does? Specifically the
Humbly asking for help with (of course) IE. I have a div that is
I keep getting this error: initializer-string for array of chars is too long Even
I got this array: $allImmunities = array( 'poisonPercent' => '/images/gems/earth.gif', 'earthPercent' => '/images/gems/earth.gif', 'paralyzePercent'
I have this method public static List<Contact> Load(string filename) { if (!File.Exists(filename)) { throw
I am working on this site: http://www.problemio.com and if you mouse over the categories
I am working on this site: http://www.problemio.com and if you mouse over the categories
I have a table like this: ID Name ---------- 1 john 1 molly 2

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.