Getting syntax error building project with CUDA library

I am having this issue with creating a C++ project that has some CUDA code parts using Visual Studio. Currently, I have a solution with 2 projects inside of it. The first is an OpenGL wrapper and the second is some CUDA code for that wrapper. The CUDA part builds with no errors and outputs its lib file. However, when I attempt to build the solution I get the following error:

error C2059: syntax error: ‘<’

I know it’s from the kernel call and I have read about this issue from a few other posts, but most people weren’t building the CUDA code with NVCC and I don’t think that’s my problem. I have read that you need to compile the C++ with g++, cl, etc. and the CUDA with NVCC, then link them with NVCC. How would I do that with Visual Studio? Or if that’s not the case, what am I missing?

Here is a gist of the CUDA file: GL Buffer with CUDA · GitHub

You haven’t provided a prototype for send_data_kernel that I can see (unless it is in glad.h).

If you don’t have a prototype for it, and you are using it before you define/declare it, that is going to cause trouble.

Furthermore, nearly everything in that file is templated. It’s also written as if it is a header file, but it is in a file called Buffer.cu (which I normally wouldn’t expect to be a header file).

If you are compiling this as a separate .cu file, it’s not clear to me that any of those functions would actually instantiate (again, barring what I can’t see in glad.h, since you haven’t provided it.)

Are you actually including this Buffer.cu file in other files?

Alternatively, provide the complete console output from your VS console that shows the error C2059.
If the actual nvcc and cl.exe compile commands are not shown in your console output, don’t bother putting it here until you have increased the VS verbosity so we can see the exact command that is being executed that gives rise to the C2059 error. The error log list that is in VS 2017 is not sufficient for this purpose. You need to extract the exact command and error from the console output.

Ops, I didn’t notice those forward references, fixed those so all functions in the file have a prototype, also made it a ‘.cuh’ file, because your right it should be a header. Also glad.h is just an OpenGL loading library. However, I am still getting the same issue.
I have a copy of the log with the verbosity set to normal and it is compiling the buffer file with NVCC and creating the output ‘.lib’ which should be used in the other project. However the other project is being compiled with CL, I don’t know if that’s causing the problem.

Here’s the log:

If you are including this Buffer.cuh in the other project, and that other project is being compiled with cl.exe, then that is the problem. Just like your research has already pointed out to you.

You can’t put <<<…>>> directly through cl.exe, even if it is only in a .cuh header file. That is CUDA code, regardless of what file or kind of file it is in. It must go through the nvcc compiler chain. You cannot use it in a header, or anywhere else, in code that will be compiled directly by cl.exe

Okay, I thought since the CUDA files were already compiled as a library, I could just link to the library and it would work. Thanks for the help!