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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:29:28+00:00 2026-05-17T20:29:28+00:00

It seems to me like a no-brainer, but I cannot find any information against

  • 0

It seems to me like a no-brainer, but I cannot find any information against or for it.

From the point of view of demangling etc, I don’t suppose this to be a big problem, but I can’t figure out, how I can write a little tiny C program which calls a function from a little tiny C++ library.

I am on linux right now, trying with static binding.

This must be something many people are running into or many books cover, but I feel like a blind gump sitting in front of this problem. Interestingly, there is no such question on SO either.

I do not even know IF this can work, far lesser HOW this has to be done.

  • 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-17T20:29:29+00:00Added an answer on May 17, 2026 at 8:29 pm

    Typically, you need to force the C++ compiler to build the library with C linkage for the exported functions.

    You can do that by doing the following to your header:

    #ifdef __cplusplus
    extern "C" {
    #endif
    
    void func(void);
    
    /* ... Other function defs go here ... */
    
    #ifdef __cplusplus
    }
    #endif
    

    Normally, the linker will do C++ name-mangling to the functions, so that the C linker won’t be able to find them. extern "C" forces it not to do that. You need to wrap it in the #ifdef, because extern "C" isn’t valid in C.

    UPDATE

    As Charles Salvia says in a comment below, you need to ensure that no exceptions make their way out through your interface, because C has no way of handling them (at least not a platform-independent way).

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

Sidebar

Related Questions

This seems like a no-brainer but I couldn't find anything on it. How do
Seems like this should be simple, but I don't find it in a net
Seems like certain browsers (Internet Explorer with Compatibility View ON ) don't support the
This seems like kind of a no-brainer but I want to require a number
Seems like a simple problem, but I can't find an answer. With cacheing disabled,
Having namespaces seems like no-brainer for most languages. But as far as I can
Seems like everyone have issue accessing local machine or internet etc from emulator. All
Seems like a basic question but I can't find this anywhere. Basically I've got
Seems like newbie's question, but I just can't find the answer. Can I somehow
This seems like a no brainer but surely there is either an internal js

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.