build CUDA project using other library? how to write?

i got a visualization library based on openGL, assuming names , usually projects can be created by #include<mygl.h> in C++,linked by libmygl.a. Now i want to optimize some algorithm of it using CUDA. i wrote a, including <mygl.h>, by cannot pass compiling. how should i mix CUDA with this library. is the only way to use export “C”?


Yes. Nvcc is a C compiler, so names are mangled differently than with a c++ compiler. Extern “C” tells the compiler to expect C mangled names so that the linker understands what to do.

thanks, BTW can i use extern “C” importing a class? how to write for example~