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 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

Related Questions

I have a job that periodically runs and archives files into a folder structure
I have a folder save here: C:\MyFiles And in that folder I have a
I have following folder structure: ProjectFolder/images/some images In the same folder ProjectFolder/WEB-INF/classes/com/xyz/here is java
I have some *.hbm.xml files that are placed in the same folder at the
here is my code it shares the folder but that does not work correctly
I have a folder path stored in the property nightly.basepath (here the value would
Here is my code html> <head></head> <body> <?php $dir = 'folder/'; $files = scandir($dir);
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/
I have simple application with following folder structure: ProjFolder |-----src |----------packagename |---------------{sourcefiles} |----------META-INF |---------------{beans.xml}

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.