Calling cuda specific functions from c++ program

I have currently a huge part of my project written in c++ and now I want to integrate that project with CUDA.

So, I want to call cuda specific functions from the main.cpp file of my project. Now, if I compile this .cpp file using the g++ compiler, it gives error saying that it does not understand the global, device identifiers. And if I compile it using the nvcc compiler, it straight away rejects it saying the file extension is not cu.
(Now, I cannot afford to rename this .cpp file to .cu)

What should I do?

Ask your employer to increase your compensation so you can afford renaming the file, or use the [font=“Courier New”]-x cu[/font] option to nvcc. :smile:

In my project I’d linked matlab with C++ (with mexFile) which is linked with CUDA using a shared library …
So if can/know make library, I advise you create CUDA library which can call from your main.