[转]Visual Studio 2008 Project for CUDA 3.2

How to configure a Visual Studio 2008 Project for CUDA 3.2 ?

Follow those instructions.

/!\ Tested with Visual Studio 2008 Professional Edition SP1 and Visual Studio C++ Express 2008 /!\

Prerequisites

Create a new Empty Project

  • File -> New -> Project…
  • Visual C++ -> General -> Empty Project
  • Name your project (for exemple MyFirstCUDAProject)
  • OK

Add rules

  • In Explorer
    • Goto %CUDA_PATH%extras\visual_studio_integration\rules\
    • Copy all files and Paste them in %ProgramFiles(x86)%\Microsoft Visual Studio 9.0\VC\VCProjectDefaults\
  • In Visual Studio
    • Right clic on the project -> Custom Build Rules…
    • Select the rule “CUDA Runtime Api Build Rule (v3.2)” (if you have more than once, choose the rule where the Path finish by “NvCudaRuntimeApi.v3.2.rules”)
    • OK

Add Rules

Add binary, include and library directories

  • Tools -> Options -> Project and Solutions -> VC++ Directories
  • For Platform “Win32″ and “Include files” add :
    • $(CUDA_PATH)include
  • For Platform “Win32″ and “Library files” add :
    • $(CUDA_PATH)lib\Win32
  • For Platform “Win32″ and “Executable files” add :
    • $(CUDA_PATH)bin

Linker

  • Right clic on the project -> Properties
  • Configuration Porperties -> Linker -> Input
  • In “Additional dependencies” add:
    • cuda.lib cudart.lib
  • Configuration Porperties -> Linker -> General
  • In “Additional library directories” add:
    • $(CUDA_PATH)lib\Win32

Write “Hello World!”

  • Right clic on the Project -> Add -> New Item…
  • On the “Name” box, write “sample.cu”
  • Write this code sample who use the CUDA compiler (on sample.cu) :

Hello World!

  • Right clic on the Project -> Build
  • Press F5

Output

Reference
转自:http://gamelab.epitech.eu/blogtech/?p=13

原文地址:https://www.cnblogs.com/snigoal/p/2041330.html