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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:31:28+00:00 2026-06-02T15:31:28+00:00

As a continuation of my previous question in stackoverflow: Getting LINK error : Extern

  • 0

As a continuation of my previous question in stackoverflow:
Getting LINK error : Extern in C++. How to access the value of a variable which is modified in File A.CPP in another file File B.CPP
IN my C++ code I want to make use of a variable “VarX” in a file “B” which is actually modified in another file “A”.
So I had a look @ the following link & used extern concept.

How do I use extern to share variables between source files?

error LNK2001: unresolved external symbol “unsigned int
VarX” (?VarX@@3IA)

My scenario is as follows:

File1.h
extern unsigned int VarX;

File2.cpp
#include File1.h
VarX = 101;

File3.cpp
#include File1.h
unsigned int temp = VarX;

IMP NOTE: In the header file File1.h there are many other structure definitions and also many othe rdefinitions apart from the Extern definition.

Can someone help me in this. How shall I read the Value of VarX which is modified in File2.cpp in another File File3.cpp.

  • 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-02T15:31:29+00:00Added an answer on June 2, 2026 at 3:31 pm

    You have to define VarX in global scope, which I’m assuming you’re not doing now, since otherwise it wouldn’t even compile:

    //File2.cpp
    #include "File1.h"
    unsigned int VarX = 101;  //this has to be outside any code block or namespace
                              //or class... 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a continuation from a previous stackoverflow question. I've renamed some variables so
This question is in continuation to my previous question, in which I asked about
This is in continuation to my previous question which was closed cause of similarity
This is a continuation of my previous question which I posted when I wasn't
This is a continuation from the previous stackoverflow jQuery question I asked, but I
This question is a continuation of my previous question here zend models architecture (big
This question is in continuation to my previous question . I am trying to
This is a continuation of my previous question .NET regex engine returns no matches
This question is a continuation of a previous thread to compare two lists with
This is a continuation of my previous question: Could not find an implementation of

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.