I kinda have the inverse problem as described here: Combining C++ and C - how does #ifdef __cplusplus work?
The whole app is in C code and now I need to add some C++ functions there. But while doing it I get this error:
/tmp/cczmWtaT.o: In function `aocl_utils::_checkError(int, char const*, int, char const*, ...)':
/home/harp/host/../common/src/AOCLUtils/opencl.cpp:245: undefined reference to `cleanup()'
/tmp/ccrmKQaT.o: In function `main':
/home/harp/host/src/main.c:165: undefined reference to `harp_setup()'
/tmp/ccGKataf.o: In function `solver_propagate(solver_t*)':
/home/harp/host/src/solver.c:751: undefined reference to `launch_kernel()'
collect2: error: ld returned 1 exit status
I've tried:
#ifdef __cplusplus
extern "C" {
#endif
<C code>
#ifdef __cplusplus
}
#endif
But it shows the same error.
What I'm doing is including a C++ header in a C file with the extern functions that I need.
Example:
solver.c
#include "HarpBuffers.h"
...
HarpBuffers.h
extern void harp_setup();
extern void setup_buffers(cl_int a, cl_int b, int **h_clause, unsigned int **h_assigns, int **h_target);
extern void launch_kernel();
extern void cleanup();