# Adding cuda code to an MFC project

**URL:** <https://forums.developer.nvidia.com/t/adding-cuda-code-to-an-mfc-project/75982>\
**Category:** CUDA Setup and Installation\
**Created:** [June 6, 2019, 6:37am UTC](https://forums.developer.nvidia.com/t/adding-cuda-code-to-an-mfc-project/75982 "2019-06-06T06:37:22Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mevlutbulut](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@mevlutbulut](https://forums.developer.nvidia.com/u/mevlutbulut)\
**Post date:** [June 6, 2019, 6:37am UTC](https://forums.developer.nvidia.com/t/adding-cuda-code-to-an-mfc-project/75982/1 "2019-06-06T06:37:22Z")

</div>

I installed cuda toolkit 10.1. When I create a Console application (I use MSVC++ 2015 Professional) I define a simple global kernel and call it from inside the main. I manage to compile the project without an error.(Choosing Cuda from build dependency menu, changing target machine from 32 bit to 64 bit, adding cudart\_static.lib as external library for building and changing the property of the file that contains cuda code from “C/C++” to “Cuda C/C++”).  
But when I want to do the same thing with an MFC project I get the following errors:

1\>------ Rebuild All started: Project: MFCApplication2, Configuration: Debug x64 ------  
1\>  
1\> C:\Users\mevlut\Documents\Visual Studio 2015\Projects\MFCApplication2\MFCApplication2\>“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin\nvcc.exe” -ccbin “C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86\_amd64” -x cu -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include" -G --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -g -use\_fast\_math -D\_WINDOWS -D\_DEBUG -D\_UNICODE -DUNICODE -Xcompiler “/EHsc /W1 /nologo /Od /FS /Zi /RTC1 /MTd " -o x64\Debug\cudaClass.h.obj “C:\Users\mevlut\Documents\Visual Studio 2015\Projects\MFCApplication2\MFCApplication2\cudaClass.h” -clean  
1\> cudaClass.h  
1\> Compiling CUDA source file cudaClass.h…  
1\>  
1\> C:\Users\mevlut\Documents\Visual Studio 2015\Projects\MFCApplication2\MFCApplication2\>“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin\nvcc.exe” -gencode=arch=compute\_35,code="sm\_35,compute\_35" --use-local-env -ccbin “C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86\_amd64” -x cu -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include” -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include" -G --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -g -use\_fast\_math -D\_WINDOWS -D\_DEBUG -D\_UNICODE -DUNICODE -Xcompiler “/EHsc /W1 /nologo /Od /Fdx64\Debug\vc140.pdb /FS /Zi /RTC1 /MTd " -o x64\Debug\cudaClass.h.obj “C:\Users\mevlut\Documents\Visual Studio 2015\Projects\MFCApplication2\MFCApplication2\cudaClass.h”  
1\>C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt\tchar.h(643): warning : expression has no effect  
1\>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\include\atlcomcli.h(698): error : invalid nontype template argument of type “const \_GUID \*”  
1\>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\comdef.h(494): error : invalid nontype template argument of type “const \_GUID \*”  
1\>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\comdef.h(501): error : invalid nontype template argument of type “const \_GUID \*”  
1\>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\comdef.h(508): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(30): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(33): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(36): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(39): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(42): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(45): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(48): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(51): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(54): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(57): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(60): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(63): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(93): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(96): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(99): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(102): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(105): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(108): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(111): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(114): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(117): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(123): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(126): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(129): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(132): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(135): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(144): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(147): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(150): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(153): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(156): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(159): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(165): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(168): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(171): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(174): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(177): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(180): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(183): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(186): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(189): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(192): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(195): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(198): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(201): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(204): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(210): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(213): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(216): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(219): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(222): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(228): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(240): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(243): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(246): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(249): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(252): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(255): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(264): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(267): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(270): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(273): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(279): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(282): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(285): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(288): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(291): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(297): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(300): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(303): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(306): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(312): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(315): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(318): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(321): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(324): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(330): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(333): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(336): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(339): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(342): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(345): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(348): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(351): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(354): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(663): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(666): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(669): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(678): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(681): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(684): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(687): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(690): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(693): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(696): error : invalid nontype template argument of type “const \_GUID \*”  
1\>c:\program files (x86)\microsoft visual studio 14.0\vc\include\comdefsp.h(699): error : invalid nontype template argument of type “const \_GUID \*”  
1\> cudaClass.h  
1\>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations\CUDA 10.1.targets(762,9): error MSB3721: The command ““C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin\nvcc.exe” -gencode=arch=compute\_35,code="sm\_35,compute\_35" --use-local-env -ccbin “C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86\_amd64” -x cu -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include” -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include” -G --keep-dir x64\Debug -maxrregcount=0 --machine 64 --compile -cudart static -g -use\_fast\_math -D\_WINDOWS -D\_DEBUG -D\_UNICODE -DUNICODE -Xcompiler “/EHsc /W1 /nologo /Od /Fdx64\Debug\vc140.pdb /FS /Zi /RTC1 /MTd " -o x64\Debug\cudaClass.h.obj “C:\Users\mevlut\Documents\Visual Studio 2015\Projects\MFCApplication2\MFCApplication2\cudaClass.h”” exited with code 1.  
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

Despite all my efforts I couldn’t resolve the problem. Can somebody help me in this please?

---

<div class="post-metadata">

**Author:** ![Robert\_Crovella](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/robert_crovella/32/14043_2.png) [@Robert\_Crovella](https://forums.developer.nvidia.com/u/Robert_Crovella)\
**Post date:** [June 6, 2019, 11:54am UTC](https://forums.developer.nvidia.com/t/adding-cuda-code-to-an-mfc-project/75982/2 "2019-06-06T11:54:51Z")

</div>

One possible approach: build your CUDA code into an ordinary windows DLL.

Call/link to the DLL from your MFC project.

Instructions for how to build a CUDA DLL in windows Visual Studio can be found in various places on this forum as well as around the web.

---

<div class="post-metadata">

**Author:** ![mevlutbulut](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@mevlutbulut](https://forums.developer.nvidia.com/u/mevlutbulut)\
**Post date:** [June 7, 2019, 10:54am UTC](https://forums.developer.nvidia.com/t/adding-cuda-code-to-an-mfc-project/75982/3 "2019-06-07T10:54:37Z")

</div>

this will restrict my ability to modify the code, I want to modify the code in a faster way. Isn’t there a sample cuda implementation together with mfc somewhere?

---

<div class="post-metadata">

**Author:** ![Robert\_Crovella](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/robert_crovella/32/14043_2.png) [@Robert\_Crovella](https://forums.developer.nvidia.com/u/Robert_Crovella)\
**Post date:** [June 7, 2019, 10:06pm UTC](https://forums.developer.nvidia.com/t/adding-cuda-code-to-an-mfc-project/75982/4 "2019-06-07T22:06:11Z")

</div>

There aren’t any ready-made sample projects provided by NVIDIA that I am aware of.

A quick google search on “cuda mfc” turned this up:

[url][https://teguhsatria.com/2010/07/04/cuda-mfc/[/url]](https://teguhsatria.com/2010/07/04/cuda-mfc/%5B/url%5D)

I wouldn’t be able to help you with that. It probably needs project updating to newer VS.

There are probably other examples, as well, to be found with google.

Since Visual Studio has the concept of solutions which can consist of multiple projects, creating a solution with a MFC project and also a CUDA DLL project seems fairly straightforward. It shouldn’t restrict your ability to edit the code in any way that I can think of. When you open the solution, you will have access to both projects, and you can click back and forth between files in each project.

---

<div class="post-metadata">

**Author:** ![mevlutbulut](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@mevlutbulut](https://forums.developer.nvidia.com/u/mevlutbulut)\
**Post date:** [June 10, 2019, 8:25am UTC](https://forums.developer.nvidia.com/t/adding-cuda-code-to-an-mfc-project/75982/5 "2019-06-10T08:25:26Z")

</div>

Thank you for the link, although I was aware of that sample, it is an old version of cuda and VS sample, the recipe doesn’t apply to the current versions.  
Following your suggestion I got MS VS 2019 version, and the same problem still exists. I deal with extreme optimization techniques. Using a dll is not not a good solution for me. Is there any other solution?

---

<div class="post-metadata">

**Author:** ![ryork](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ryork](https://forums.developer.nvidia.com/u/ryork)\
**Post date:** [June 26, 2019, 3:30pm UTC](https://forums.developer.nvidia.com/t/adding-cuda-code-to-an-mfc-project/75982/6 "2019-06-26T15:30:24Z")

</div>

Do you still have this problem?  
Can your code compile in MBCS mode? I ask because I am not sure CUDA can work with Unicode. I use CUDA with MFC in MBCS mode and it works fine.

---

<div class="post-metadata">

**Author:** ![mevlutbulut](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@mevlutbulut](https://forums.developer.nvidia.com/u/mevlutbulut)\
**Post date:** [July 1, 2019, 5:04am UTC](https://forums.developer.nvidia.com/t/adding-cuda-code-to-an-mfc-project/75982/7 "2019-07-01T05:04:16Z")

</div>

Hello ryork,  
I tried MBCS mode too, I couldn’t get an mfc project even with an empty cuda kernel statement compile without an error. Which versions of Cuda and Visual Studio are you using?

---

<div class="post-metadata">

**Author:** ![ryork](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ryork](https://forums.developer.nvidia.com/u/ryork)\
**Post date:** [July 8, 2019, 3:19pm UTC](https://forums.developer.nvidia.com/t/adding-cuda-code-to-an-mfc-project/75982/8 "2019-07-08T15:19:48Z")

</div>

I have CUDA v10.1 and VS2017.

---

<div class="post-metadata">

**Author:** ![mevlutbulut](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@mevlutbulut](https://forums.developer.nvidia.com/u/mevlutbulut)\
**Post date:** [July 8, 2019, 6:16pm UTC](https://forums.developer.nvidia.com/t/adding-cuda-code-to-an-mfc-project/75982/9 "2019-07-08T18:16:55Z")

</div>

is there anyway you can share an empty mfc project with a very simple CUDA kernal used somewhere in it?

---

<div class="post-metadata">

**Author:** ![ryork](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ryork](https://forums.developer.nvidia.com/u/ryork)\
**Post date:** [July 9, 2019, 4:42pm UTC](https://forums.developer.nvidia.com/t/adding-cuda-code-to-an-mfc-project/75982/10 "2019-07-09T16:42:01Z")

</div>

Yes, here’s one. I found that VS2017’s IDE is rather clunky for most of the project settings so I end up using a text editor to change them. I did that with mine. I copied and pasted most of the CUDA stuff into this project file. The solution is trivial and no different so I will not include it.  
///////////////////////////////////////////////////////  
ï»¿\<?xml version="1.0" encoding="utf-8"?\>  
  
  
$(VCTargetsPath)\BuildCustomizations  
  
  
  
Debug  
x64  
  
  
Release  
x64  
  
  
  
{19A99427-1EEB-4148-8B7F-212A71474946}  
FractalsGPU  
FractalsGPU  
  
  
  
Dynamic  
  
  
Dynamic  
  
  
Application  
MultiByte  
v141  
10.0.17763.0  
  
  
true  
  
  
false  
  
  
  
  
  
  
  
  
  
  
false  
ObjectsDbg64\</OutDir\>  
ObjectsDbg64\</IntDir\>  
false  
$(ProjectName)  
  
  
ObjectsRel64\</OutDir\>  
ObjectsRel64\</IntDir\>  
false  
true  
$(ProjectName)  
  
  
$(IncludePath)  
AllRules.ruleset  
  
  
  
  
  
Level4  
WIN32;\_MBCS;%(PreprocessorDefinitions)  
./;$(CudaToolkitDir)/include;C:/Cuda/inc;D:/Dev/MFCext/Include;  
  
  
Windows  
cudart\_static.lib;freeglut.lib;%(AdditionalDependencies)  
$(CudaToolkitLibDir);C:/Cuda/Lib/X64/;D:/Dev/Bin;$(PlatformName);  
  
  
compute\_52,sm\_52;compute\_61,sm\_61;compute\_75,sm\_75;  
-Xcompiler “/wd 4819” %(AdditionalOptions)  
./;C:/Cuda/inc  
WIN32  
  
  
  
  
Disabled  
MultiThreadedDebugDLL  
  
  
true  
Default  
  
  
MDd  
64  
  
  
  
  
MaxSpeed  
MultiThreadedDLL  
Use  
stdafx.h  
true  
  
  
false  
Default  
  
  
MD  
64  
  
  
  
  
ProgramDatabase  
Use  
stdafx.h  
true  
  
  
  
  
  
  
  
  
  
  
  
Create

---

<div class="post-metadata">

**Author:** ![ryork](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ryork](https://forums.developer.nvidia.com/u/ryork)\
**Post date:** [July 9, 2019, 4:45pm UTC](https://forums.developer.nvidia.com/t/adding-cuda-code-to-an-mfc-project/75982/11 "2019-07-09T16:45:25Z")

</div>

One more thing I just remembered - the install process doesn’t handle updating very well. You will have to fix all of your projects unless you do something I did which is making an environment variable to hold the version of CUDA installed which is 10.1 for me. That’s CUDA\_VERSION in the project file.

FWIW, I posted a bug report about this but it was blown off. I think this is seriously broken so I will continue to do it myself.

---

<div class="post-metadata">

**Author:** ![pkulkarni](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@pkulkarni](https://forums.developer.nvidia.com/u/pkulkarni)\
**Post date:** [June 10, 2022, 6:13pm UTC](https://forums.developer.nvidia.com/t/adding-cuda-code-to-an-mfc-project/75982/12 "2022-06-10T18:13:35Z")

</div>

I am facing the exact same error. Did you find any workaround?
