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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:42:44+00:00 2026-05-28T20:42:44+00:00

I have created a sample c++ project under Visual Studio 2010 with following files.

  • 0

I have created a sample c++ project under Visual Studio 2010 with following files.

A.h

#ifndef A_H
#define A_H

#include <iostream>

void foo();

#endif

A.cpp

#include "A.h"

void foo()
{
    int a = 1;
}

main.cpp

#include "A.h"

int main(int argc, char* argv[])
{
    foo();    

    return 0;
}

I am getting the following output after build:

1>—— Build started: Project: opengl_test, Configuration: Debug Win32 ——

1> main.cpp

1> A.h

1> A.cpp

1> Generating Code…

1>Debug\A.obj : warning LNK4042: object specified more than once; extras ignored

1>main.obj : error LNK2019: unresolved external symbol “void __cdecl foo(void)” (?foo@@YAXXZ) referenced in function _main

1>C:\Users\alp\Projects\Test Samples\opengl_test\Debug\opengl_test.exe : fatal error LNK1120: 1 unresolved externals

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

What is the reason for this error?

  • 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-28T20:42:45+00:00Added an answer on May 28, 2026 at 8:42 pm

    I think what happened is that A.h was in the Source group of the project rather than the Header group, so it was compiled as if it were a .cpp. Since both A.cpp and A.h will generate an object file A.obj, the last one to compile is the only one that got linked. I believe the last one compiled was A.h, which didn’t have an implementation of foo(), thus the linker couldn’t find it.

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

Sidebar

Related Questions

I have created a simple windows forms visual studio 2010 project in windows 7
I've created a sample project to simplify my problem. I have this simple handler:
I have created simple project from maven-achetype-quickstart under Eclipse Indigo, then I went to
I have created simple project from maven-archetype-quickstart under Eclipse Indigo, then I went to
i have created a simple public ref class in the vc++ project, which is
I have created a sample report with crystal report 10. Now, I wanna to
I have created a sample java socket application. I used Socket s = new
I have taken the MailComposer example added to a simple project and under a
Good Day All, I’m new to programming. I’m using Visual Studio 2010. I’m taking
We have a project where the .js and .css files gets compressed with YUI

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.