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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:37:49+00:00 2026-05-13T19:37:49+00:00

Here is my folder structure: / | — program.cpp — utility.h — utility.cpp |

  • 0

Here is my folder structure:

/
|
 -- program.cpp
 -- utility.h
 -- utility.cpp
|
 -- module/
    |
     -- utility.h
     -- utility.cpp

// Note that I have two files named utility.h and two named utility.cpp

On building the project, I get a link error (LNK2028: unresolved token and so on…) saying that some symbols aren’t defined. I have confirmed that all symbols are defined and that all declared functions have a corresponding definition.

I have a feeling that on compiling my project, the utility.cpp files from both folders are compiled into the same utility.obj in the output folder. As a result, one overwrites the other.

  1. Is this expected behaviour?
  2. How do I
    build a C++ binary which has two
    files with the same name (though in
    different folders)?
  • 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-13T19:37:49+00:00Added an answer on May 13, 2026 at 7:37 pm

    Right click both/either .cpp files > properties > C/C++ > Output Files > Object File Name > set a custom name. e.g. if both files are named MyFile.cpp in folder A and another in folder B, you can set the output to be AMyFile and BMyFile.

    Alternatively, you can also use a macro to prefix the object names with the immediate parent folder name (i.e. using $(IntDir)\$(SafeParentName)$(SafeInputName)). If this is not enough (e.g. you have A/B/MyFile.cpp and C/B/MyFile.cpp) and you don’t mind having some object files cluttering your source tree, you can also use $(InputDir)\ which will put the object files in the same folder as the source file.

    the cpp files will then be compiled into two different object files..

    enjoy!

    Update for VS2010: There is a better solution in VS2010, check it out here. Thanks to n1ck‘s comment

    btw, if the contents have the same name, do you separate them using different namespaces?

    namespace A { // in folder A
        class CMyFile {};
    };
    
    namespace B{ // in folder B
        class CMyFile {};
    };
    
    // client.cpp
    #include "A/MyFile.h"
    #include "B/MyFile.h"
    int main() {
        A::CMyFile aMyFile;
        B::CMyFile bMyFile;
        return 0;
    }
    

    I don’t know if it matters but it’s definitely clearer to human : D

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

Sidebar

Ask A Question

Stats

  • Questions 513k
  • Answers 513k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer No, only the user can initiate it becoming an out… May 16, 2026 at 5:56 pm
  • Editorial Team
    Editorial Team added an answer I suspect that anti-aliasing means that the pixel for "."… May 16, 2026 at 5:56 pm
  • Editorial Team
    Editorial Team added an answer To summarize and add a bit more Let the database… May 16, 2026 at 5:56 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have some *.hbm.xml files that are placed in the same folder at the
Here's the folder structure of my project: /ping --/Controller ----Ping_Conntroller_Main.php ----Ping_Conntroller_Db.php --/Model ----dbCredentials.php --/View
Using PHP 5.3.3 (stable) on Linux CentOS 5.5. Here's my folder structure: www/myFolder/ www/myFolder/testFolder/
Ok here's my issue I have a file that is delivered through https, all
I have this folder public/assets/dvd_files/dvds/ and i want to svn ignore anything that might
My application displays a folder structure in a tree. The user can browse the
[SOLVED] I copy the chipmunk folder structure from cocos2d+chipmunk template and build OK. Classes/Chipmunk/include/src
So here's my project: I am building a central interface/dashboard to present the test
Here's the issue... if I use, say a directory catalog in MEF and have
I am using PHP and I need to script something like below: I have

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.