I am trying to add some code to a larger C project that requires the use of a C++ library.
The C++ library provides a wrapper using functions marked extern "C" that provide access to the functionality of the library
//Some C++ library
//mywrapper.h
#ifdef __cplusplus
extern "C" {
#endif
void wrapperFunction1( int width );
void wrapperFunction1( int height);
#ifdef __cplusplus
} // extern "C"
#endif
This compiles with g++ without problem.
When making a C program and including mywrapper.h, I continually get linker errors referencing vtable and cxa_pure_virtual:
undefined reference to `vtable for __cxxabiv1::__class_type_info'
undefined reference to `__cxa_pure_virtual'
In testing, these errors go away and allow the program to compile when I add the stdc++ library, but this isn't a option for the larger C project. Is there a way to compile a C program to access a C++ library without these errors and without stdc++? And the deals of the errors are referring to modules that are deep inside of the C++ library and not referenced in mywrapper.h, so why is C program even trying to refer to them?