# Create a cuda project in VS 2005 VS 2005 can not understand the syntax

**URL:** <https://forums.developer.nvidia.com/t/create-a-cuda-project-in-vs-2005-vs-2005-can-not-understand-the-syntax/3280>\
**Category:** CUDA Programming and Performance\
**Created:** [April 9, 2008, 6:50am UTC](https://forums.developer.nvidia.com/t/create-a-cuda-project-in-vs-2005-vs-2005-can-not-understand-the-syntax/3280 "2008-04-09T06:50:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quoc\_Vinh](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Quoc\_Vinh](https://forums.developer.nvidia.com/u/Quoc_Vinh)\
**Post date:** [April 9, 2008, 6:50am UTC](https://forums.developer.nvidia.com/t/create-a-cuda-project-in-vs-2005-vs-2005-can-not-understand-the-syntax/3280/1 "2008-04-09T06:50:33Z")

</div>

Hi every body. Iam a new member in the Cuda  
I had compiled some program in the NVIDIA project and it can work.  
when i make a new project (my project store in the NVIDIA project)  
in my project i has a function i had stored it on the \*.cu file

**global** void testKernel( float\* g\_idata, float\* g\_odata)  
{

}  
when I build this project I get 2 errors :(

error C2144: syntax error : ‘void’ should be preceded by ‘;’  
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

so i type this string before the function

extern “C”  
**global** void testKernel( float\* g\_idata, float\* g\_odata)  
{

}

But it still did not work. as the same errors [External Image](http://hqnveipbwb20/public/style_emoticons/<#EMO_DIR#>/no.gif "Image hosted on another site. Click to open in a new tab.")

(iam a vietnamese so my english is not good)

---

<div class="post-metadata">

**Author:** ![Quoc\_Vinh](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Quoc\_Vinh](https://forums.developer.nvidia.com/u/Quoc_Vinh)\
**Post date:** [April 9, 2008, 6:57am UTC](https://forums.developer.nvidia.com/t/create-a-cuda-project-in-vs-2005-vs-2005-can-not-understand-the-syntax/3280/2 "2008-04-09T06:57:11Z")

</div>

I had made some tutorial on Linux and it worked. :)  
but I spend alot of time for cuda on window but it can not work :(  
please help me  
thank you very much [External Image](http://hqnveipbwb20/public/style_emoticons/<#EMO_DIR#>/heart.gif "Image hosted on another site. Click to open in a new tab.")

---

<div class="post-metadata">

**Author:** ![54wo](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@54wo](https://forums.developer.nvidia.com/u/54wo)\
**Post date:** [April 9, 2008, 9:19am UTC](https://forums.developer.nvidia.com/t/create-a-cuda-project-in-vs-2005-vs-2005-can-not-understand-the-syntax/3280/3 "2008-04-09T09:19:09Z")

</div>

You should make a copy of the project “template” located in SDK/Project directory, and start from that. Don’t create a project from begin if you are not a expert.

---

<div class="post-metadata">

**Author:** ![psycloXPS](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@psycloXPS](https://forums.developer.nvidia.com/u/psycloXPS)\
**Post date:** [April 10, 2008, 5:31am UTC](https://forums.developer.nvidia.com/t/create-a-cuda-project-in-vs-2005-vs-2005-can-not-understand-the-syntax/3280/4 "2008-04-10T05:31:56Z")

</div>

You need to make a build rule for .cu files, as in you need to tell VS to compile .cu files with the nvcc compiler.  
There was a thread long time back about the same…so be sure to check it out.  
Alternatively you could open any nVidia projects and right click on any .cu file in the solution explorer and inspect its properties. Look for Custom build step and you will know whats going on. That is your .cu build rule.

In the mean-while you can use the template project (or any other existing project) and tailor it to suit your needs.

Cheers

---

<div class="post-metadata">

**Author:** ![Quoc\_Vinh](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Quoc\_Vinh](https://forums.developer.nvidia.com/u/Quoc_Vinh)\
**Post date:** [April 10, 2008, 9:29am UTC](https://forums.developer.nvidia.com/t/create-a-cuda-project-in-vs-2005-vs-2005-can-not-understand-the-syntax/3280/5 "2008-04-10T09:29:31Z")

</div>

> [@](#):
>
> You should make a copy of the project “template” located in SDK/Project directory, and start from that. Don’t create a project from begin if you are not a expert.
> 
> [snapback]359267[/snapback]

Thank you 54wo and psycloXPS [External Media](http://hqnveipbwb20/public/style_emoticons/<#EMO_DIR#>/smile2.gif "Media hosted on another site. Click to open in a new tab.")

I had copy all NVIDIA CUDA SDK and past on another direction

and then i open matrixMulDrv project which store in the projects folder

and build. It work. [External Media](http://hqnveipbwb20/public/style_emoticons/<#EMO_DIR#>/smile2.gif "Media hosted on another site. Click to open in a new tab.")

so I delete the code they write inside of these function

and replace my code on it.

i did’t change any header (the #include some header file)

In the \*.cu file I write 2 functions

(1) to tranfer data from CPU to GPU and call kernel function (2)

(2) kernel function

in the \*cpp file I write main function

and when I call the (1) function from \*.cpp file

I get 2 errors :(

Linking…

matrixMulDrv.obj : error LNK2019: unresolved external symbol "void _cdecl data(int)" (?data_@@YAXH@Z) referenced in function \_main

…/…/bin/win32/Release/matrixMulDrv.exe : fatal error LNK1120: 1 unresolved externals

Build log was saved at “file://c:\Documents and Settings\vinh\Desktop\IMAGE PROCESSING PROJECT\b Send data to GPU\NVIDIA CUDA SDK\projects\readcpu to gpu1\Release\BuildLog.htm”

matrixMulDrv - 2 error(s), 0 warning(s)

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I am sure to say that my function doesn’t has any error, because it was very simple function and i check it many times. and the compiler did not show any error about these function

I try to fix these problems, I found some idear from msdn forums but until now i can’t \<img src=‘[http://hqnveipbwb20/public/style\_emoticons/](http://hqnveipbwb20/public/style_emoticons/)\<#EMO\_DIR#\>/crying.gif’ class=‘bbc\_emoticon’ alt=‘:’(’ /\>

---

<div class="post-metadata">

**Author:** ![Quoc\_Vinh](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Quoc\_Vinh](https://forums.developer.nvidia.com/u/Quoc_Vinh)\
**Post date:** [April 11, 2008, 4:36am UTC](https://forums.developer.nvidia.com/t/create-a-cuda-project-in-vs-2005-vs-2005-can-not-understand-the-syntax/3280/6 "2008-04-11T04:36:08Z")

</div>

> [@](#):
>
> Thank you 54wo and psycloXPS [External Media](http://hqnveipbwb20/public/style_emoticons/<#EMO_DIR#>/smile2.gif "Media hosted on another site. Click to open in a new tab.")
> 
> I had copy all NVIDIA CUDA SDK and past on another direction
> 
> and then i open matrixMulDrv project which store in the projects folder
> 
> and build. It work. [External Media](http://hqnveipbwb20/public/style_emoticons/<#EMO_DIR#>/smile2.gif "Media hosted on another site. Click to open in a new tab.")
> 
> so I delete the code they write inside of these function
> 
> and replace my code on it.
> 
> i did’t change any header (the #include some header file)
> 
> In the \*.cu file I write 2 functions
> 
> (1) to tranfer data from CPU to GPU and call kernel function (2)
> 
> (2) kernel function
> 
> in the \*cpp file I write main function
> 
> and when I call the (1) function from \*.cpp file
> 
> I get 2 errors&nbsp; :(
> 
> Linking…
> 
> matrixMulDrv.obj : error LNK2019: unresolved external symbol "void _cdecl data(int)" (?data_@@YAXH@Z) referenced in function \_main
> 
> …/…/bin/win32/Release/matrixMulDrv.exe : fatal error LNK1120: 1 unresolved externals
> 
> Build log was saved at “file://c:\Documents and Settings\vinh\Desktop\IMAGE PROCESSING PROJECT\b Send data to GPU\NVIDIA CUDA SDK\projects\readcpu to gpu1\Release\BuildLog.htm”
> 
> matrixMulDrv - 2 error(s), 0 warning(s)
> 
> ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
> 
> I am sure to say that my function doesn’t has any error, because it was very simple function and i check it many times. and the compiler did not show any error about these function
> 
> I try to fix these problems, I found some idear from msdn forums but until now i can’t&nbsp; \<img src=‘[http://hqnveipbwb20/public/style\_emoticons/](http://hqnveipbwb20/public/style_emoticons/)\<#EMO\_DIR#\>/crying.gif’ class=‘bbc\_emoticon’ alt=‘:’(’ /\>
> 
> [snapback]359857[/snapback]

Hi everybody

I can not solve my problem so i try with another way

I creat an another solution and save out of Nvidia folder

include build rule from JaredHoberock

and follow all steps :)

C++ Additional Includes:

“$(CUDA\_INC\_PATH)”;“C:/Program Files/NVIDIA Corporation/NVIDIA CUDA SDK/common/inc”

Linker Additional Libs:

“$(CUDA\_LIB\_PATH)”;“C:/Program Files/NVIDIA Corporation/NVIDIA CUDA SDK/common/lib”

Linker Input:

cudart.lib cutil32D.lib cutil.lib

when i compile \*.cu file, it is ok

when build this solution i had the same error

Linking…

getting\_start\_cuda1.obj : warning LNK4075: ignoring ‘/EDITANDCONTINUE’ due to ‘/INCREMENTAL:NO’ specification

LINK : warning LNK4098: defaultlib ‘MSVCRTD’ conflicts with use of other libs; use /NODEFAULTLIB:library

getting\_start\_cuda1.obj : error LNK2019: unresolved external symbol “void \_\_cdecl data\_tranfer(float \*,float \*,float \*)” (?data\_tranfer@@YAXPAM00@Z) referenced in function \_wmain

C:\Documents and Settings\vinh\Desktop\getting\_start\_cuda1\Debug\getting\_start\_cuda1/run.exe : fatal error LNK1120: 1 unresolved externals

Build log was saved at “file://c:\Documents and Settings\vinh\Desktop\getting\_start\_cuda1\getting\_start\_cuda1\Debug\BuildLog.htm”

getting\_start\_cuda1 - 2 error(s), 2 warning(s)

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Please help me. i spend alot of time to create my own CUDA program o VISUAL STUDIO C++ 2005 :(

---

<div class="post-metadata">

**Author:** ![Quoc\_Vinh](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Quoc\_Vinh](https://forums.developer.nvidia.com/u/Quoc_Vinh)\
**Post date:** [April 11, 2008, 6:13am UTC](https://forums.developer.nvidia.com/t/create-a-cuda-project-in-vs-2005-vs-2005-can-not-understand-the-syntax/3280/7 "2008-04-11T06:13:56Z")

</div>

I am too stupid.  
I had solved my problem. :D

just type extern “C” on the prototype

extern “C”{void data\_tranfer(float \*A1,float \*B1,float \*C1);};

before  
void data\_tranfer(float \*A1,float \*B1,float \*C1);

thank you everybody.
