Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
Will a C compiled .so work with a C++ application?

If I want to dynamically link a shared library (.so) for a C++ application (which was built with g++) using LD_PRELOAD, does it matter if the .so is generated from a C source file (using gcc) or a C++ source file (using g++)? And why or why not?

Thanks for helping me understand this.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Yes, a C++ executable can be linked (both statically and dynamically) to a C library.

This is completely deliberate. The C++ ABIs are designed to be backwards compatible.

You will have to ensure that the declarations of functions and so on of the library symbols, as written in your C++ program, are marked extern "C" to denote that you are crossing a language boundary. Typically, the library's own shipped header files will do this for you.

over 4 years ago · Santiago Trujillo Report

0

It doesn't matter how an .so was generated. You should be able preload an .so that was generated from FORTRAN code too. The key issue is making sure that you use the symbols in the .so correctly.

When an .so is generated from C code, the names of the symbols are unmangled.

When an .so is generated from C++ code, the names of the symbols are mangled.

I am not sure whether the names of symbols in an .so generated from FORTRAN are mangled.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!