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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:51:18+00:00 2026-06-16T13:51:18+00:00

EDIT: I know about include guards, but include files are not the issue here.

  • 0

EDIT: I know about include guards, but include files are not the issue here. I’m talking about actual compiled and already linked code that gets baked into the static library.

I’m creating a general-purpose utility library for myself in C++.

One of the functions I’m creating, printFile, requires string, cout and other such members of the standard library.

I’m worried that when the library is compiled, and then linked to another project that also uses string and cout, the code for string and cout will be duplicated: it will both be prelinked in the library binary the program is being linked with, and it will be again linked with the project that uses them itself.

The library is structured like this:

  1. There is one libname.hpp file the programmer who uses the library is supposed to #include in his projects.
  2. For every function fname declared in libname.hpp, there is an file fname.cpp implementing it.
  3. All fname.cpp files also #include "libname.hpp".
  4. The library itself compiles into libname.a which is copied to /usr/lib/.

Will this even happen?
If yes, is it a problem at all?
If yes, then how can I avoid this?

  • 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-16T13:51:21+00:00Added an answer on June 16, 2026 at 1:51 pm

    I’m worried that when the library is compiled, and then linked to another project that also uses string and cout, the code for string and cout will be duplicated

    Don’t worry: no modern compilation system will do that. The code for template functions is emitted into object files, but the linker discards duplicate entries.

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

Sidebar

Related Questions

EDIT: I've found what's causing the issue, but I don't know why and I
If this is not out of place here, would like to know about the
Please let me know if you have any idea about it. Thanks EDIT What
I would like to know how I could edit mp3 files on the server
I believe my issue stems from the printf print buffer, but I know too
(I am talking about C, but it also applies to class templates in C++)
Caution: I know nothing about C++. I'm comfortable using C#, but this is confusing
I'm just learn about memory dynamic, and did experiment, but still get stuck. already
I know this stuff has been talked about a lot, but I'm having a
I know the forum has many questions about heap etc. but nothing helped me

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.