## Error in .C(” *** “) : C symbol name ” *** ” not in load table

If you are getting this error, as I was, then you are probably trying to write an extension for R in C++ and not C. I was just writing a function “linsgp” in C++. See if the following scenario is familiar to you

> dyn.load("main.so")
> .C("linsgp")
Error in .C("linsgp") : C symbol name "linsgp" not in load table


My C++ code looked like this

...
void linsgp(){
...


What is missing is extern “C”, so it should look like this:

...
extern "C" void linsgp(){
...


The reason is that C++ supports overloading of function names and so the compiler mangles the name with information about the arguments. C, however, does not support this and doesn’t mangle the name. Inserting extern “C” tells the compiler not to mangle the name such that the name used for linkage is C-compatible.