# Cuda 3.2 build rules problems

**URL:** <https://forums.developer.nvidia.com/t/cuda-3-2-build-rules-problems/19549>\
**Category:** CUDA Programming and Performance\
**Created:** [November 3, 2010, 12:44pm UTC](https://forums.developer.nvidia.com/t/cuda-3-2-build-rules-problems/19549 "2010-11-03T12:44:23Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunburntfish](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sunburntfish](https://forums.developer.nvidia.com/u/sunburntfish)\
**Post date:** [November 3, 2010, 12:44pm UTC](https://forums.developer.nvidia.com/t/cuda-3-2-build-rules-problems/19549/1 "2010-11-03T12:44:23Z")

</div>

I am having trouble getting Cuda to work with Visual Studio 2010. I am working on Windows XP 32-bit and have installed Visual Studio, the Cuda 3.2 toolkit and the SDK. When I try to build an exercise from the NVIDIA website (cudaMallocAndMemCpy) I get the following message:

“error MSB6006: ‘cmd.exe’ exited with code -1.”

Visual Studio doesn’t seem to recognise the .cu file. I have tried going to the project’s “Build customisations…” as suggested by many ([forum posts](http://innovativesolution.wordpress.com/2009/09/22/set-cuda-build-rules-to-project-in-visual-studio/)) but the Cuda 3.2 build customisation files are non-existent. I thought this might be a problem with me installing visual studio after the Cuda toolkit but I have uninstalled and reinstalled in an appropriate order and still have the same problem. Please help!

---

<div class="post-metadata">

**Author:** ![sunburntfish](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sunburntfish](https://forums.developer.nvidia.com/u/sunburntfish)\
**Post date:** [November 3, 2010, 12:44pm UTC](https://forums.developer.nvidia.com/t/cuda-3-2-build-rules-problems/19549/2 "2010-11-03T12:44:23Z")

</div>

I am having trouble getting Cuda to work with Visual Studio 2010. I am working on Windows XP 32-bit and have installed Visual Studio, the Cuda 3.2 toolkit and the SDK. When I try to build an exercise from the NVIDIA website (cudaMallocAndMemCpy) I get the following message:

“error MSB6006: ‘cmd.exe’ exited with code -1.”

Visual Studio doesn’t seem to recognise the .cu file. I have tried going to the project’s “Build customisations…” as suggested by many ([forum posts](http://innovativesolution.wordpress.com/2009/09/22/set-cuda-build-rules-to-project-in-visual-studio/)) but the Cuda 3.2 build customisation files are non-existent. I thought this might be a problem with me installing visual studio after the Cuda toolkit but I have uninstalled and reinstalled in an appropriate order and still have the same problem. Please help!

---

<div class="post-metadata">

**Author:** ![Ken\_Domino](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Ken\_Domino](https://forums.developer.nvidia.com/u/Ken_Domino)\
**Post date:** [November 11, 2010, 4:05am UTC](https://forums.developer.nvidia.com/t/cuda-3-2-build-rules-problems/19549/3 "2010-11-11T04:05:35Z")

</div>

> [@](#):
>
> I am having trouble getting Cuda to work with Visual Studio 2010. I am working on Windows XP 32-bit and have installed Visual Studio, the Cuda 3.2 toolkit and the SDK. When I try to build an exercise from the NVIDIA website (cudaMallocAndMemCpy) I get the following message:
> 
> “error MSB6006: ‘cmd.exe’ exited with code -1.”
> 
> Visual Studio doesn’t seem to recognise the .cu file. I have tried going to the project’s “Build customisations…” as suggested by many (forum posts) but the Cuda 3.2 build customisation files are non-existent. I thought this might be a problem with me installing visual studio after the Cuda toolkit but I have uninstalled and reinstalled in an appropriate order and still have the same problem. Please help!

Building CUDA programs with MSVC++ 2010 is a complete mess right now. I’m not sure why there just hasn’t been any official release of the new rule files for CUDA 3.2, since MSVC2010 has been out for many, many months. Doesn’t seem very nice. But, I found some information on why it is a problem, at [Build error: error MSB3686](http://social.msdn.microsoft.com/Forums/en/vcprerelease/thread/d24cba9c-ec87-4e27-83c2-1343a2e62a40).

The problem is that MS decided to change the old “.rules” syntax of VS2008 to something even more messy in VS2010. VS2010 is supposed to convert the old .rules file, but it doesn’t work–at least not for me. So, here’s what I was able to do to get it to work.

1. Install both MSVC2008 and MSVC2010. You will be compiling your .cu files with NVCC, which a thin driver program that calls the old VC9 compiler. NVCC cannot compile using CL from VC2010; NVCC must use the old compiler.

2. Set up an environmental variable called VC9INSTALLDIR to the VS C++ 2008 installation directory, e.g., through the Control Panel Environmental variables dialog box. The value of the variable should be something like C:\Program Files\Microsoft Visual Studio 9.0\VC. It will depend on where you installed it. Make sure the trailing "" is added to the path.

3. Attached is a zip file containing three files for the .cu build rule.

4. Unpack the zip, and copy the files (cuda.props, cuda.targets, cuda.xml) to the MSBUILD config directory, which should be by default C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations. This path depends on where you installed MSVC2010.

5. Open MVSC2010, and convert or create a new project. I would start with a really simple program, not one of the examples from the SDK. They are too complicated.

6. Go to menu item “Project | Build Customizations…” and make sure to select the “cuda(.targets, .props)” rule.

7. Set up your options for the .cu file in your project.

You should be able to build now. The rule files I give are slightly different from that in the link [Build error: error MSB3686](http://social.msdn.microsoft.com/Forums/en/vcprerelease/thread/d24cba9c-ec87-4e27-83c2-1343a2e62a40)

There was a problem where double quotes needed to be added in the cuda.props file, since Windows allows spaces in paths.

If it still gives you errors the “-1” errors, go to the output window in MSVC and copy the command it’s trying to execute, and see what it’s doing.

Caveats: You should be able to compile .cpp files with the VC10 compiler, .cu files with NVCC(VC9), and link with the runtime in VC10–works for me. However, you may get problems with linking in some situations, e.g., unresolved external symbol “public: static void \_\_cdecl std::\_String\_base::\_Xran(void)” (?\_Xran@\_String\_base@std@@SAXXZ). In that case, you may have to rip apart the .cu file so that it only has kernel code, device code, and kernel calls, so that it doesn’t use the C runtime.

Ken  
[cuda-build-rules.zip](https://forums.developer.nvidia.com/uploads/short-url/vLS6wrgPzxDccU0Lrh1uGyozLZU.zip) (5.38 KB)

---

<div class="post-metadata">

**Author:** ![Ken\_Domino](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Ken\_Domino](https://forums.developer.nvidia.com/u/Ken_Domino)\
**Post date:** [November 11, 2010, 4:05am UTC](https://forums.developer.nvidia.com/t/cuda-3-2-build-rules-problems/19549/4 "2010-11-11T04:05:35Z")

</div>

> [@](#):
>
> I am having trouble getting Cuda to work with Visual Studio 2010. I am working on Windows XP 32-bit and have installed Visual Studio, the Cuda 3.2 toolkit and the SDK. When I try to build an exercise from the NVIDIA website (cudaMallocAndMemCpy) I get the following message:
> 
> “error MSB6006: ‘cmd.exe’ exited with code -1.”
> 
> Visual Studio doesn’t seem to recognise the .cu file. I have tried going to the project’s “Build customisations…” as suggested by many (forum posts) but the Cuda 3.2 build customisation files are non-existent. I thought this might be a problem with me installing visual studio after the Cuda toolkit but I have uninstalled and reinstalled in an appropriate order and still have the same problem. Please help!

Building CUDA programs with MSVC++ 2010 is a complete mess right now. I’m not sure why there just hasn’t been any official release of the new rule files for CUDA 3.2, since MSVC2010 has been out for many, many months. Doesn’t seem very nice. But, I found some information on why it is a problem, at [Build error: error MSB3686](http://social.msdn.microsoft.com/Forums/en/vcprerelease/thread/d24cba9c-ec87-4e27-83c2-1343a2e62a40).

The problem is that MS decided to change the old “.rules” syntax of VS2008 to something even more messy in VS2010. VS2010 is supposed to convert the old .rules file, but it doesn’t work–at least not for me. So, here’s what I was able to do to get it to work.

1. Install both MSVC2008 and MSVC2010. You will be compiling your .cu files with NVCC, which a thin driver program that calls the old VC9 compiler. NVCC cannot compile using CL from VC2010; NVCC must use the old compiler.

2. Set up an environmental variable called VC9INSTALLDIR to the VS C++ 2008 installation directory, e.g., through the Control Panel Environmental variables dialog box. The value of the variable should be something like C:\Program Files\Microsoft Visual Studio 9.0\VC. It will depend on where you installed it. Make sure the trailing "" is added to the path.

3. Attached is a zip file containing three files for the .cu build rule.

4. Unpack the zip, and copy the files (cuda.props, cuda.targets, cuda.xml) to the MSBUILD config directory, which should be by default C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations. This path depends on where you installed MSVC2010.

5. Open MVSC2010, and convert or create a new project. I would start with a really simple program, not one of the examples from the SDK. They are too complicated.

6. Go to menu item “Project | Build Customizations…” and make sure to select the “cuda(.targets, .props)” rule.

7. Set up your options for the .cu file in your project.

You should be able to build now. The rule files I give are slightly different from that in the link [Build error: error MSB3686](http://social.msdn.microsoft.com/Forums/en/vcprerelease/thread/d24cba9c-ec87-4e27-83c2-1343a2e62a40)

There was a problem where double quotes needed to be added in the cuda.props file, since Windows allows spaces in paths.

If it still gives you errors the “-1” errors, go to the output window in MSVC and copy the command it’s trying to execute, and see what it’s doing.

Caveats: You should be able to compile .cpp files with the VC10 compiler, .cu files with NVCC(VC9), and link with the runtime in VC10–works for me. However, you may get problems with linking in some situations, e.g., unresolved external symbol “public: static void \_\_cdecl std::\_String\_base::\_Xran(void)” (?\_Xran@\_String\_base@std@@SAXXZ). In that case, you may have to rip apart the .cu file so that it only has kernel code, device code, and kernel calls, so that it doesn’t use the C runtime.

Ken

---

<div class="post-metadata">

**Author:** ![euphrat](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@euphrat](https://forums.developer.nvidia.com/u/euphrat)\
**Post date:** [November 18, 2010, 8:49pm UTC](https://forums.developer.nvidia.com/t/cuda-3-2-build-rules-problems/19549/5 "2010-11-18T20:49:44Z")

</div>

> [@](#):
>
> Building CUDA programs with MSVC++ 2010 is a complete mess right now. I’m not sure why there just hasn’t been any official release of the new rule files for CUDA 3.2, since MSVC2010 has been out for many, many months. Doesn’t seem very nice. But, I found some information on why it is a problem, at [Build error: error MSB3686](http://social.msdn.microsoft.com/Forums/en/vcprerelease/thread/d24cba9c-ec87-4e27-83c2-1343a2e62a40).
> 
> The problem is that MS decided to change the old “.rules” syntax of VS2008 to something even more messy in VS2010. VS2010 is supposed to convert the old .rules file, but it doesn’t work–at least not for me. So, here’s what I was able to do to get it to work.
> 
> 1. Install both MSVC2008 and MSVC2010. You will be compiling your .cu files with NVCC, which a thin driver program that calls the old VC9 compiler. NVCC cannot compile using CL from VC2010; NVCC must use the old compiler.
> 
> 2. Set up an environmental variable called VC9INSTALLDIR to the VS C++ 2008 installation directory, e.g., through the Control Panel Environmental variables dialog box. The value of the variable should be something like C:\Program Files\Microsoft Visual Studio 9.0\VC. It will depend on where you installed it. Make sure the trailing "" is added to the path.
> 
> 3. Attached is a zip file containing three files for the .cu build rule.
> 
> 4. Unpack the zip, and copy the files (cuda.props, cuda.targets, cuda.xml) to the MSBUILD config directory, which should be by default C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations. This path depends on where you installed MSVC2010.
> 
> 5. Open MVSC2010, and convert or create a new project. I would start with a really simple program, not one of the examples from the SDK. They are too complicated.
> 
> 6. Go to menu item “Project | Build Customizations…” and make sure to select the “cuda(.targets, .props)” rule.
> 
> 7. Set up your options for the .cu file in your project.
> 
> You should be able to build now. The rule files I give are slightly different from that in the link [Build error: error MSB3686](http://social.msdn.microsoft.com/Forums/en/vcprerelease/thread/d24cba9c-ec87-4e27-83c2-1343a2e62a40)
> 
> There was a problem where double quotes needed to be added in the cuda.props file, since Windows allows spaces in paths.
> 
> If it still gives you errors the “-1” errors, go to the output window in MSVC and copy the command it’s trying to execute, and see what it’s doing.
> 
> Caveats: You should be able to compile .cpp files with the VC10 compiler, .cu files with NVCC(VC9), and link with the runtime in VC10–works for me. However, you may get problems with linking in some situations, e.g., unresolved external symbol “public: static void \_\_cdecl std::\_String\_base::\_Xran(void)” (?\_Xran@\_String\_base@std@@SAXXZ). In that case, you may have to rip apart the .cu file so that it only has kernel code, device code, and kernel calls, so that it doesn’t use the C runtime.
> 
> Ken

Hi! I’m new to CUDA and am currently desperately trying to set up a simple demo project with CUDA 3.2 in VS2010.

I think i found an error in your cuda.xml file … When you observe the CUDA Build rule command line, it messes up the include switch, writing something like

“-IC:\Program Files […]”

Clearly, this should be

-I “C:\Program FIles […]”

I tried to manually fix and came up with the following solution:

1. in cuda.props, change the value by removing the “” around the “[Include]” term (two times)

2. in cuda.xml, search for the StringListProperty with DisplayName=“Additional Include Directories”, and change the Switch to: Switch='-I “[value]” ’

Note: the switch at “Preprocessor Definitions” seems to have an error too, fix it by inserting a space between -D and [value] in the switch, otherwise the preprocessor definition characters would stick with the “-D”

Further, I wonder whether the props files you provided are somewaht out of date … there is no option for -arch sm\_20 or sm\_21 contained yet. Are these props conform to CUDA 3.2?

I found an interesting blog (unfortunately not helping me) about CUDA 3.1. and VS2010 at [#2782 » Blog Archive » Getting CUDA 3.1 Working with Visual Studio 2010](http://www.ademiller.com/blogs/tech/2010/08/getting-cuda-3-1-working-with-visual-studio-2010/)

where sm\_20 seems already be supported.

Nevertheless, despite your excellent explanation, I can’t run my simple CUDA Demo File. I followed your steps, but am not entirely sure what exactly to do at step 7) Set up your options for the .cu file in your project. Could you elaborate on the settings in detail? Despite fixing the command line as described above, when compiling and building my .cu file, it brings “The command “echo …” exited with code -1.”

Here my demo code:

[b][font=“Courier New”]main.cu:

#include \<stdio.h\>

**global** void kernel()

{

}

int main()

{

```
kernel<<<1,1>>>();

printf("Demo");

return 0;

```

}[/font][/b]

Btw, I didn’t convert a project from VS2008 to VS2010 but creating a new empty C++ Project in VS2010 and adding this main.cu file.

Appreciate any help on this,

Thanks,

Reinhold

---

<div class="post-metadata">

**Author:** ![euphrat](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@euphrat](https://forums.developer.nvidia.com/u/euphrat)\
**Post date:** [November 18, 2010, 8:49pm UTC](https://forums.developer.nvidia.com/t/cuda-3-2-build-rules-problems/19549/6 "2010-11-18T20:49:44Z")

</div>

> [@](#):
>
> Building CUDA programs with MSVC++ 2010 is a complete mess right now. I’m not sure why there just hasn’t been any official release of the new rule files for CUDA 3.2, since MSVC2010 has been out for many, many months. Doesn’t seem very nice. But, I found some information on why it is a problem, at [Build error: error MSB3686](http://social.msdn.microsoft.com/Forums/en/vcprerelease/thread/d24cba9c-ec87-4e27-83c2-1343a2e62a40).
> 
> The problem is that MS decided to change the old “.rules” syntax of VS2008 to something even more messy in VS2010. VS2010 is supposed to convert the old .rules file, but it doesn’t work–at least not for me. So, here’s what I was able to do to get it to work.
> 
> 1. Install both MSVC2008 and MSVC2010. You will be compiling your .cu files with NVCC, which a thin driver program that calls the old VC9 compiler. NVCC cannot compile using CL from VC2010; NVCC must use the old compiler.
> 
> 2. Set up an environmental variable called VC9INSTALLDIR to the VS C++ 2008 installation directory, e.g., through the Control Panel Environmental variables dialog box. The value of the variable should be something like C:\Program Files\Microsoft Visual Studio 9.0\VC. It will depend on where you installed it. Make sure the trailing "" is added to the path.
> 
> 3. Attached is a zip file containing three files for the .cu build rule.
> 
> 4. Unpack the zip, and copy the files (cuda.props, cuda.targets, cuda.xml) to the MSBUILD config directory, which should be by default C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations. This path depends on where you installed MSVC2010.
> 
> 5. Open MVSC2010, and convert or create a new project. I would start with a really simple program, not one of the examples from the SDK. They are too complicated.
> 
> 6. Go to menu item “Project | Build Customizations…” and make sure to select the “cuda(.targets, .props)” rule.
> 
> 7. Set up your options for the .cu file in your project.
> 
> You should be able to build now. The rule files I give are slightly different from that in the link [Build error: error MSB3686](http://social.msdn.microsoft.com/Forums/en/vcprerelease/thread/d24cba9c-ec87-4e27-83c2-1343a2e62a40)
> 
> There was a problem where double quotes needed to be added in the cuda.props file, since Windows allows spaces in paths.
> 
> If it still gives you errors the “-1” errors, go to the output window in MSVC and copy the command it’s trying to execute, and see what it’s doing.
> 
> Caveats: You should be able to compile .cpp files with the VC10 compiler, .cu files with NVCC(VC9), and link with the runtime in VC10–works for me. However, you may get problems with linking in some situations, e.g., unresolved external symbol “public: static void \_\_cdecl std::\_String\_base::\_Xran(void)” (?\_Xran@\_String\_base@std@@SAXXZ). In that case, you may have to rip apart the .cu file so that it only has kernel code, device code, and kernel calls, so that it doesn’t use the C runtime.
> 
> Ken

Hi! I’m new to CUDA and am currently desperately trying to set up a simple demo project with CUDA 3.2 in VS2010.

I think i found an error in your cuda.xml file … When you observe the CUDA Build rule command line, it messes up the include switch, writing something like

“-IC:\Program Files […]”

Clearly, this should be

-I “C:\Program FIles […]”

I tried to manually fix and came up with the following solution:

1. in cuda.props, change the value by removing the “” around the “[Include]” term (two times)

2. in cuda.xml, search for the StringListProperty with DisplayName=“Additional Include Directories”, and change the Switch to: Switch='-I “[value]” ’

Note: the switch at “Preprocessor Definitions” seems to have an error too, fix it by inserting a space between -D and [value] in the switch, otherwise the preprocessor definition characters would stick with the “-D”

Further, I wonder whether the props files you provided are somewaht out of date … there is no option for -arch sm\_20 or sm\_21 contained yet. Are these props conform to CUDA 3.2?

I found an interesting blog (unfortunately not helping me) about CUDA 3.1. and VS2010 at [#2782 » Blog Archive » Getting CUDA 3.1 Working with Visual Studio 2010](http://www.ademiller.com/blogs/tech/2010/08/getting-cuda-3-1-working-with-visual-studio-2010/)

where sm\_20 seems already be supported.

Nevertheless, despite your excellent explanation, I can’t run my simple CUDA Demo File. I followed your steps, but am not entirely sure what exactly to do at step 7) Set up your options for the .cu file in your project. Could you elaborate on the settings in detail? Despite fixing the command line as described above, when compiling and building my .cu file, it brings “The command “echo …” exited with code -1.”

Here my demo code:

[b][font=“Courier New”]main.cu:

#include \<stdio.h\>

**global** void kernel()

{

}

int main()

{

```
kernel<<<1,1>>>();

printf("Demo");

return 0;

```

}[/font][/b]

Btw, I didn’t convert a project from VS2008 to VS2010 but creating a new empty C++ Project in VS2010 and adding this main.cu file.

Appreciate any help on this,

Thanks,

Reinhold

---

<div class="post-metadata">

**Author:** ![Ken\_Domino](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Ken\_Domino](https://forums.developer.nvidia.com/u/Ken_Domino)\
**Post date:** [November 19, 2010, 12:05pm UTC](https://forums.developer.nvidia.com/t/cuda-3-2-build-rules-problems/19549/7 "2010-11-19T12:05:51Z")

</div>

> [@](#):
>
> Despite fixing the command line as described above, when compiling and building my .cu file, it brings “The command “echo …” exited with code -1.”

Hi Reinhold, Thanks for the info. You might want to try the other CUDA rules rules you found. As you said, the rules I gave are out of date. (I will update the rules and repost them here later.)

For the “-1” exit code problem, try this:

CD to the directory that contains the source you are trying to compile. Look for the .log file for the build (it should be the name of your project + “.log”). Edit the log file and look for the echo/compile command. Look at the output error messages. If that yields no clues, then open a VC 2010 command prompt (Start | All programs | Microsoft Visual Studio 2010 | Visual Studios Tools | Visual Studio Command Prompt (2010)). Then, copy and paste the compile command into the the command prompt and see what the error messages are from the compile. This should help in understanding if it’s a problem with the rules file, or if there is an environmental variable missing, or if the properties are not set up. Ken

---

<div class="post-metadata">

**Author:** ![Ken\_Domino](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Ken\_Domino](https://forums.developer.nvidia.com/u/Ken_Domino)\
**Post date:** [November 19, 2010, 12:05pm UTC](https://forums.developer.nvidia.com/t/cuda-3-2-build-rules-problems/19549/8 "2010-11-19T12:05:51Z")

</div>

> [@](#):
>
> Despite fixing the command line as described above, when compiling and building my .cu file, it brings “The command “echo …” exited with code -1.”

Hi Reinhold, Thanks for the info. You might want to try the other CUDA rules rules you found. As you said, the rules I gave are out of date. (I will update the rules and repost them here later.)

For the “-1” exit code problem, try this:

CD to the directory that contains the source you are trying to compile. Look for the .log file for the build (it should be the name of your project + “.log”). Edit the log file and look for the echo/compile command. Look at the output error messages. If that yields no clues, then open a VC 2010 command prompt (Start | All programs | Microsoft Visual Studio 2010 | Visual Studios Tools | Visual Studio Command Prompt (2010)). Then, copy and paste the compile command into the the command prompt and see what the error messages are from the compile. This should help in understanding if it’s a problem with the rules file, or if there is an environmental variable missing, or if the properties are not set up. Ken

---

<div class="post-metadata">

**Author:** ![euphrat](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@euphrat](https://forums.developer.nvidia.com/u/euphrat)\
**Post date:** [November 19, 2010, 6:49pm UTC](https://forums.developer.nvidia.com/t/cuda-3-2-build-rules-problems/19549/9 "2010-11-19T18:49:02Z")

</div>

Hi Ken,

thanks for the advice. I found the problem … had to add an extra -m32 flag at the command line since im working on a 64bit platform. The compiler now seems to pass, but when linking, i get the unresolved external symbols you talked about. Splitting the code to c and cuda files doesn’t help.

Here’s my linker output:

1\> Compiling with CUDA Build Rule…  
1\>main.cu.obj : error LNK2005: “void \_\_cdecl \__device\_stub\_\_Z6kernelPiS\_S_(int \*,int \*,int \*)” (?\__device\_stub\_\_Z6kernelPiS\_S_@@YAXPAH00@Z) already defined in demo.cu.obj  
1\>main.cu.obj : error LNK2005: “void \_\_cdecl kernel(int \*,int \*,int \*)” (?kernel@@YAXPAH00@Z) already defined in demo.cu.obj  
1\>demo.cu.obj : error LNK2019: unresolved external symbol \_\_\_cudaUnregisterFatBinary@4 referenced in function “void \_\_cdecl \_\_cudaUnregisterBinaryUtil(void)” (?\_\_cudaUnregisterBinaryUtil@@YAXXZ)  
1\>main.cu.obj : error LNK2001: unresolved external symbol \_\_\_cudaUnregisterFatBinary@4  
1\>demo.cu.obj : error LNK2019: unresolved external symbol \_cudaLaunch@4 referenced in function “enum cudaError \_\_cdecl cudaLaunch(char \*)” (??$cudaLaunch@D@@YA?AW4cudaError@@PAD@Z)  
1\>main.cu.obj : error LNK2001: unresolved external symbol \_cudaLaunch@4  
1\>demo.cu.obj : error LNK2019: unresolved external symbol \_cudaSetupArgument@12 referenced in function “void \_\_cdecl \__device\_stub\_\_Z6kernelPiS\_S_(int \*,int \*,int \*)” (?\__device\_stub\_\_Z6kernelPiS\_S_@@YAXPAH00@Z)  
1\>main.cu.obj : error LNK2001: unresolved external symbol \_cudaSetupArgument@12  
1\>demo.cu.obj : error LNK2019: unresolved external symbol \_\_\_cudaRegisterFunction@40 referenced in function “void \_\_cdecl \_\_sti\_\_\_\_cudaRegisterAll\_50\_tmpxft\_000002f4\_00000000\_8\_demo\_compute\_20\_cpp1\_ii\_b95238da(void)” (?\_\_sti\_\_\_\_cudaRegisterAll\_50\_tmpxft\_000002f4\_00000000\_8\_demo\_compute\_20\_cpp1\_ii\_b95238da@@YAXXZ)  
1\>main.cu.obj : error LNK2001: unresolved external symbol \_\_\_cudaRegisterFunction@40  
1\>demo.cu.obj : error LNK2019: unresolved external symbol \_\_\_cudaRegisterFatBinary@4 referenced in function “void \_\_cdecl \_\_sti\_\_\_\_cudaRegisterAll\_50\_tmpxft\_000002f4\_00000000\_8\_demo\_compute\_20\_cpp1\_ii\_b95238da(void)” (?\_\_sti\_\_\_\_cudaRegisterAll\_50\_tmpxft\_000002f4\_00000000\_8\_demo\_compute\_20\_cpp1\_ii\_b95238da@@YAXXZ)  
1\>main.cu.obj : error LNK2001: unresolved external symbol \_\_\_cudaRegisterFatBinary@4  
1\>main.cu.obj : error LNK2019: unresolved external symbol \_cudaFree@4 referenced in function \_main  
1\>main.cu.obj : error LNK2019: unresolved external symbol \_cudaConfigureCall@32 referenced in function \_main  
1\>main.cu.obj : error LNK2019: unresolved external symbol \_cudaMemcpy@16 referenced in function \_main  
1\>main.cu.obj : error LNK2019: unresolved external symbol \_cudaMalloc@8 referenced in function \_main  
1\>D:\Development\CudaDemo\Debug\CudaDemo.exe : fatal error LNK1120: 9 unresolved externals

Btw, i tried this with both your and the prop files from ade miller ([#2782 » Blog Archive » Getting CUDA 3.1 Working with Visual Studio 2010](http://www.ademiller.com/blogs/tech/2010/08/getting-cuda-3-1-working-with-visual-studio-2010/)), same result.

Any ideas?

Thanks a lot!

Reinhold

---

<div class="post-metadata">

**Author:** ![euphrat](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@euphrat](https://forums.developer.nvidia.com/u/euphrat)\
**Post date:** [November 19, 2010, 6:49pm UTC](https://forums.developer.nvidia.com/t/cuda-3-2-build-rules-problems/19549/10 "2010-11-19T18:49:02Z")

</div>

Hi Ken,

thanks for the advice. I found the problem … had to add an extra -m32 flag at the command line since im working on a 64bit platform. The compiler now seems to pass, but when linking, i get the unresolved external symbols you talked about. Splitting the code to c and cuda files doesn’t help.

Here’s my linker output:

1\> Compiling with CUDA Build Rule…  
1\>main.cu.obj : error LNK2005: “void \_\_cdecl \__device\_stub\_\_Z6kernelPiS\_S_(int \*,int \*,int \*)” (?\__device\_stub\_\_Z6kernelPiS\_S_@@YAXPAH00@Z) already defined in demo.cu.obj  
1\>main.cu.obj : error LNK2005: “void \_\_cdecl kernel(int \*,int \*,int \*)” (?kernel@@YAXPAH00@Z) already defined in demo.cu.obj  
1\>demo.cu.obj : error LNK2019: unresolved external symbol \_\_\_cudaUnregisterFatBinary@4 referenced in function “void \_\_cdecl \_\_cudaUnregisterBinaryUtil(void)” (?\_\_cudaUnregisterBinaryUtil@@YAXXZ)  
1\>main.cu.obj : error LNK2001: unresolved external symbol \_\_\_cudaUnregisterFatBinary@4  
1\>demo.cu.obj : error LNK2019: unresolved external symbol \_cudaLaunch@4 referenced in function “enum cudaError \_\_cdecl cudaLaunch(char \*)” (??$cudaLaunch@D@@YA?AW4cudaError@@PAD@Z)  
1\>main.cu.obj : error LNK2001: unresolved external symbol \_cudaLaunch@4  
1\>demo.cu.obj : error LNK2019: unresolved external symbol \_cudaSetupArgument@12 referenced in function “void \_\_cdecl \__device\_stub\_\_Z6kernelPiS\_S_(int \*,int \*,int \*)” (?\__device\_stub\_\_Z6kernelPiS\_S_@@YAXPAH00@Z)  
1\>main.cu.obj : error LNK2001: unresolved external symbol \_cudaSetupArgument@12  
1\>demo.cu.obj : error LNK2019: unresolved external symbol \_\_\_cudaRegisterFunction@40 referenced in function “void \_\_cdecl \_\_sti\_\_\_\_cudaRegisterAll\_50\_tmpxft\_000002f4\_00000000\_8\_demo\_compute\_20\_cpp1\_ii\_b95238da(void)” (?\_\_sti\_\_\_\_cudaRegisterAll\_50\_tmpxft\_000002f4\_00000000\_8\_demo\_compute\_20\_cpp1\_ii\_b95238da@@YAXXZ)  
1\>main.cu.obj : error LNK2001: unresolved external symbol \_\_\_cudaRegisterFunction@40  
1\>demo.cu.obj : error LNK2019: unresolved external symbol \_\_\_cudaRegisterFatBinary@4 referenced in function “void \_\_cdecl \_\_sti\_\_\_\_cudaRegisterAll\_50\_tmpxft\_000002f4\_00000000\_8\_demo\_compute\_20\_cpp1\_ii\_b95238da(void)” (?\_\_sti\_\_\_\_cudaRegisterAll\_50\_tmpxft\_000002f4\_00000000\_8\_demo\_compute\_20\_cpp1\_ii\_b95238da@@YAXXZ)  
1\>main.cu.obj : error LNK2001: unresolved external symbol \_\_\_cudaRegisterFatBinary@4  
1\>main.cu.obj : error LNK2019: unresolved external symbol \_cudaFree@4 referenced in function \_main  
1\>main.cu.obj : error LNK2019: unresolved external symbol \_cudaConfigureCall@32 referenced in function \_main  
1\>main.cu.obj : error LNK2019: unresolved external symbol \_cudaMemcpy@16 referenced in function \_main  
1\>main.cu.obj : error LNK2019: unresolved external symbol \_cudaMalloc@8 referenced in function \_main  
1\>D:\Development\CudaDemo\Debug\CudaDemo.exe : fatal error LNK1120: 9 unresolved externals

Btw, i tried this with both your and the prop files from ade miller ([#2782 » Blog Archive » Getting CUDA 3.1 Working with Visual Studio 2010](http://www.ademiller.com/blogs/tech/2010/08/getting-cuda-3-1-working-with-visual-studio-2010/)), same result.

Any ideas?

Thanks a lot!

Reinhold

---

<div class="post-metadata">

**Author:** ![Ken\_Domino](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Ken\_Domino](https://forums.developer.nvidia.com/u/Ken_Domino)\
**Post date:** [November 19, 2010, 8:54pm UTC](https://forums.developer.nvidia.com/t/cuda-3-2-build-rules-problems/19549/11 "2010-11-19T20:54:53Z")

</div>

> [@](#):
>
> 1\>main.cu.obj : error LNK2001: unresolved external symbol \_cudaLaunch@4

Hi Reinhold, You need to add in the CUDA runtime library. In Visual Studio 2010, right-click the project name and open the Properties dialog box. Left click Linker, then Input, then edit “Additional Dependencies”. Add in “$(CUDA\_LIB\_PATH)\cudart.lib”, with the double quotes. That should take care of those CUDA link problems. Ken

---

<div class="post-metadata">

**Author:** ![Ken\_Domino](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Ken\_Domino](https://forums.developer.nvidia.com/u/Ken_Domino)\
**Post date:** [November 19, 2010, 8:54pm UTC](https://forums.developer.nvidia.com/t/cuda-3-2-build-rules-problems/19549/12 "2010-11-19T20:54:53Z")

</div>

> [@](#):
>
> 1\>main.cu.obj : error LNK2001: unresolved external symbol \_cudaLaunch@4

Hi Reinhold, You need to add in the CUDA runtime library. In Visual Studio 2010, right-click the project name and open the Properties dialog box. Left click Linker, then Input, then edit “Additional Dependencies”. Add in “$(CUDA\_LIB\_PATH)\cudart.lib”, with the double quotes. That should take care of those CUDA link problems. Ken

---

<div class="post-metadata">

**Author:** ![euphrat](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@euphrat](https://forums.developer.nvidia.com/u/euphrat)\
**Post date:** [November 19, 2010, 11:51pm UTC](https://forums.developer.nvidia.com/t/cuda-3-2-build-rules-problems/19549/13 "2010-11-19T23:51:56Z")

</div>

Awesome.

The following happened:

At first, I did as you told (obviously it had to be some missing libs, but I didn’t know which libs … → I guess this also answers my previous question: “what is meant by step 7 setting up the project”).  
But it didn’t help, linker errors still resided. I looked up my CUDA\_LIB\_PATH envvar (was something like "…\lib\x64") and tried each other lib in that folder besides the cudart.lib suggested by you.  
Didn’t help either.

After some confusion I finally figured out, that, beside the x64 folder, there is also a Win32 folder containing the same libs. So I changed my envvar to “…\lib\Win32”  
 → and now it works.

I additionally had to put a header definition of the kernel function into a separate header file to fix the two LNK2005 errors (“already defined in demo.cu.obj”) at the begin.

* * *

Concluding this, the problem with this was again the fact that I’m working on a 64bit platform (I downloaded the 64bit version of the SDK), but linking to 32 bit (remember the -m32 flag).

So, anyone facing the same problems and dealing with a 64bit platform, be aware of

1. adding the -m32 flag (in the CUDA Build Rule v3.0.14 props from ade miller in ProjectProperties\>CUDA Build Rules\>General\>Extra Options)
2. checking to have the CUDA\_LIB\_PATH refering to the lib\Win32 dir in the Nvidia SDK folder

The -m32 flag was simply neccessary in my case since without nvcc would exit with fatal error “Visual Studio configuration file ‘(null)’ could not be found for installation at …”

Again, in the end I didn’t use the cuda.props/target/xml files provided by Ken in this thread, but those of Ade Miller (see link in post above). Works for me.

@Ken, thanks for your help!

I hope this helps someone else too!

Regards,  
Reinhold

---

<div class="post-metadata">

**Author:** ![euphrat](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@euphrat](https://forums.developer.nvidia.com/u/euphrat)\
**Post date:** [November 19, 2010, 11:51pm UTC](https://forums.developer.nvidia.com/t/cuda-3-2-build-rules-problems/19549/14 "2010-11-19T23:51:56Z")

</div>

Awesome.

The following happened:

At first, I did as you told (obviously it had to be some missing libs, but I didn’t know which libs … → I guess this also answers my previous question: “what is meant by step 7 setting up the project”).  
But it didn’t help, linker errors still resided. I looked up my CUDA\_LIB\_PATH envvar (was something like "…\lib\x64") and tried each other lib in that folder besides the cudart.lib suggested by you.  
Didn’t help either.

After some confusion I finally figured out, that, beside the x64 folder, there is also a Win32 folder containing the same libs. So I changed my envvar to “…\lib\Win32”  
 → and now it works.

I additionally had to put a header definition of the kernel function into a separate header file to fix the two LNK2005 errors (“already defined in demo.cu.obj”) at the begin.

* * *

Concluding this, the problem with this was again the fact that I’m working on a 64bit platform (I downloaded the 64bit version of the SDK), but linking to 32 bit (remember the -m32 flag).

So, anyone facing the same problems and dealing with a 64bit platform, be aware of

1. adding the -m32 flag (in the CUDA Build Rule v3.0.14 props from ade miller in ProjectProperties\>CUDA Build Rules\>General\>Extra Options)
2. checking to have the CUDA\_LIB\_PATH refering to the lib\Win32 dir in the Nvidia SDK folder

The -m32 flag was simply neccessary in my case since without nvcc would exit with fatal error “Visual Studio configuration file ‘(null)’ could not be found for installation at …”

Again, in the end I didn’t use the cuda.props/target/xml files provided by Ken in this thread, but those of Ade Miller (see link in post above). Works for me.

@Ken, thanks for your help!

I hope this helps someone else too!

Regards,  
Reinhold
