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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:34:50+00:00 2026-06-12T19:34:50+00:00

I came across a project recently that created it’s shared object libraries by linking

  • 0

I came across a project recently that created it’s shared object libraries by linking gcc generated object files (using the CC gnu makefile macro) with g++.

Aside from (possibly) ensuring the source code is encapsulated inside #ifdef __cplusplus / extern "c" { / #endif constructs to avoid name mangling problems, is there any reason why this would be … better?

  • 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-12T19:34:51+00:00Added an answer on June 12, 2026 at 7:34 pm

    If they only link with g++ then adding preprocessor checks and extern "C" is useless, that only affects preprocessing and compilation, at the linking stage that’s already done.

    They might have wanted to ensure that exceptions could propagate through their C library, but to do that they only need to link to libgcc not libstdc++.

    Maybe they just wanted the shared library to depend on libstdc++, so that users of the library would also depend on libstdc++ and wouldn’t have to link to it explicitly, although that might not work as they expected.

    So in short, no, I can’t think of any good reason if all the code is C code and not C++ code.

    However just because something is compiled with gcc doesn’t mean it’s C code, you can use the gcc executable to compile C++ code and it will invoke the C++ front-end (cc1plus) instead of the C front-end (cc1). If the C++ code uses the standard library then you either need to link with -lstdc++ or use g++ to link (which automatically links with -lstdc++). So maybe the answer is that it’s C++ code, and the fact they compiled the objects with gcc not g++ made you think it was C code.

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

Sidebar

Related Questions

I recently came across an article by Matthew Weier O'Phinney (ZF project lead) that
recently, while working on a db2 -> oracle migration project, we came across this
Recently in a previous project I came across a peculiar difference between VB.NET and
I recently came across some weird looking class that had three constructors: class Class
Recently in my project I have came across the image in the link .
I came across a situation that I had in another project that I'm not
I've been working on a project and came across some interesting behavior when using
I recently came across http://chromeexperiments.com/ . I found a couple of projects there that
I recently came across Flex builder and it was gr8 to know that it
I recently came across spring surf project and Spring webscripts . Both these technologies

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.