Errors using CUDA and VS generated forms

I’m doing research work this summer which includes translating VB code to C++ code to be used on a C2050 with CUDA c.

I have the compiler working and can create/run CUDA applications, however recently I began writing up the forms for the GUI.

This is where problems arose. I used the windows forms option in VS2010 to create the necessary forms however it is riddled with errors.

This is code that is “generated” for the most part, and I have identical code running in an environment that does not use the CUDA compiler.

That leads me to believe that there is an issue between the forms in VS2010 and CUDA 3.2 however I have found next to nothing on the problem online or on this site. The most frustrating part is I do not get a real error, its little syntax errors on just about every line. Eventually it overloads with over 100 lines or errors and quits.

The exit code is as follows:

2>  Error limit reached.

2>  100 errors detected in the compilation of "C:/Users/End-user/AppData/Local/Temp/tmpxft_00001228_00000000-3_module1.cpp1.ii".

2>  Compilation terminated.

2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 3.2.targets(290,3): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2008 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin"  -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\include"  -G0  --keep-dir "Debug" -maxrregcount=32  --machine 32 --compile  -D_NEXUS_DEBUG -g    -Xcompiler "/EHsc /nologo /Od /Zi  /MDd " -o "Debug\module1.cu.obj" "C:\Users\End-user\Documents\Visual Studio 2010\Projects\Conversion\Conversion\module1.cu"" exited with code 4.

2>

With just some general errors being:

2>(5): error : name must be a namespace name

2>(6): error : name followed by “::” must be a class or namespace name

2>(7): error : name followed by “::” must be a class or namespace name

2>(8): error : name followed by “::” must be a class or namespace name

2>(9): error : name followed by “::” must be a class or namespace name

2>(10): error : name followed by “::” must be a class or namespace name

2>(15): error : expected a declaration

It goes on for well over 100 errors but the code all works in non CUDA environments.

That snippet of errors comes from the following code:

#pragma once

#include "Form1.h"

namespace Conversion {

	using namespace System;

	using namespace System::ComponentModel;

	using namespace System::Collections;

	using namespace System::Windows::Forms;

	using namespace System::Data;

	using namespace System::Drawing;

	/// <summary>

	/// Summary for Form2

	/// </summary>

	public ref class Form2 : public System::Windows::Forms::Form

	{

	public:

		Form2(void)

		{

			InitializeComponent();

			//

			//TODO: Add the constructor code here

			//

		}

After looking around I found to change the suggestion to change “Common language runtime support” to /clr.

While this removed the errors before compilation it still has the same issues.

If this topic is in the wrong area I apologize.

Any suggestions or help would be appreciated.

Thank you.

The “using namespace foo::bar” syntax isn’t valid C++…it’s valid C++/CLI though (the extended version of C++ that works on .NET).

To my knowledge, nvcc works as a sort of preprocessor, parsing the C/C++ code in your .cu/.cuh files and compiling the CUDA-specific stuff into a form which can then be processed by your standard C/C++ compiler (in your case, msvc). I think the problem you’re having is that nvcc only supports standard C/C++ syntax, and it’s choking on the extra stuff which is only available in C++/CLI.

Your only two choices (AFAIK) are (1) convince nVidia to add support for C++/CLI to nvcc, or; (2) emit standard C++ instead of C++/CLI (in which case, you’ll lose any .NET interoperability afforded by C++/CLI).

Yeah that is pretty much what I was afraid of.

By using standard C++ I assume the use of forms is either very limited or not supported?
I can probably work around the use of the UI if necessary but since its a code conversion of someone elses code I’m trying to keep it similar to make it easier for them.

Would there happen to be other options for building UIs? I’m sure CUDA supports something haha

Thanks for the quick reply by the way, jack!

If you want to use forms (to build a GUI) from standard C++, you won’t be able to do it through .NET (i.e., System.Windows.Forms, or whatever the equivalent is in WPF). I think you’d have to do it in MFC? You might want to double-check though, it’s been quite a long time since I had to deal with that stuff.

Thanks for the help, jack!

I will look into MFC and see what I can find and use.
I will post back with my findings.

Disclaimer: I have no experience width Visual Studio at all.

Can’t you separate the CUDA code and the GUI code into different files, and the compile only the CUDA part with nvcc? I do that on Mac OS and Linux all the time, because even there the occasional problem pops up where CUDA and GUI code have some weird interference when within the same file.