Following the answer given to this question (Developing C wrapper API for Object-Oriented C++ code) I managed to write a C wrapper for my C++ code.
I would like to compile and link my wrapper into a static library (compiled using g++) that could be used, compiled and linked using gcc only (not g++). This way the user of the library would not have to care that the library is written in C++.
Is this something possible?
Yes, you just need to provide the C interface with functions that have C linkage. Exactly as the linked question's answer work although for the header you will need to make it C-compliant. The common way would be using an
#ifdef __cplusplus
to detect whether the compiler is a C or C++ compiler.This link explains some of the compiler options and scenarios: http://docs.oracle.com/cd/E19422-01/819-3690/Building.Libs.html Specifically:
> 16.7 Building a Library That Has a C API