cuda的makefile问题

hellolegend 2010-07-28 11:44:43
Mac OS操作系统,进入安装目录下运行/C/common/common.mk,全部编译完成,能够运行。
现在将deviceQuery.cpp,编译该cpp的Makefile文件以及前面提到的common.mk考到一个文件夹Test下面(Test不在SDK里面)。将common.mk改名为makefile,将Makefile文件的内容加入makefile的前面,同时进行一些修改,具体如下:

以下为makefile文件内容:
# Add source files here
EXECUTABLE := deviceQuery
# Cuda source files (compiled with cudacc)
CUFILES :=
# C/C++ source files (compiled with gcc / c++)
CCFILES := deviceQuery.cpp

之前为原Makefile内容,删除include这句。下面为原来common.mk内容
#.SUFFIXES : .cu .cu_dbg.o .c_dbg.o .cpp_dbg.o .cu_rel.o .c_rel.o .cpp_rel.o .cubin .ptx

# Add new SM Versions here as devices with new Compute Capability are released
SM_VERSIONS := 10 11 12 13 20

CUDA_INSTALL_PATH ?= /usr/local/cuda

ifdef cuda-install
CUDA_INSTALL_PATH := $(cuda-install)
endif

# detect OS
OSUPPER = $(shell uname -s 2>/dev/null | tr [:lower:] [:upper:])
OSLOWER = $(shell uname -s 2>/dev/null | tr [:upper:] [:lower:])

# 'linux' is output for Linux system, 'darwin' for OS X
DARWIN = $(strip $(findstring DARWIN, $(OSUPPER)))
ifneq ($(DARWIN),)
SNOWLEOPARD = $(strip $(findstring 10.6, $(shell egrep "<string>10\.6" /System/Library/CoreServices/SystemVersion.plist)))
endif

# detect 32-bit or 64-bit platform
HP_64 = $(shell uname -m | grep 64)
OSARCH= $(shell uname -m)

# Basic directory setup for SDK
# (override directories only if they are not already defined)
修改这里的内容,将相对路径改为绝对路径。=与#之间部分为修改后内容,#右边为原来内容
SRCDIR ?=
ROOTDIR ?= /Developer/GPU\ Computing/C #..
ROOTBINDIR ?= /Developer/GPU\ Computing/C/bin #$(ROOTDIR)/../bin
BINDIR ?= /Developer/GPU\ Computing/C/bin/darwin #$(ROOTBINDIR)/$(OSLOWER)
ROOTOBJDIR ?= obj #未修改
LIBDIR := /Developer/GPU\ Computing/C/lib #$(ROOTDIR)/../lib
COMMONDIR := /Developer/GPU\ Computing/C/common #$(ROOTDIR)/../common
SHAREDDIR := /Developer/GPU\ Computing/shared #$(ROOTDIR)/../../shared/
#以下部分未修改
# Compilers
NVCC := $(CUDA_INSTALL_PATH)/bin/nvcc
CXX := g++
CC := gcc
LINK := g++ -fPIC

#makefile文件结束


修改原来deviceQuery.cpp文件,将其中的
#include <shrUtils.h>
修改为
#include "/Developer/GPU Computing/shared/inc/shrUtils.h"

另一个头文件#include <cuda_runtime_api.h>在/usr/local/cuda/include/里面,未修改。



在Test目录下运行make,出现如下的错误,该如何解决?

MacBookPro:Test ABC$ make
i686-apple-darwin10-g++-4.2.1: /inc: No such file or directory
i686-apple-darwin10-g++-4.2.1: /inc: No such file or directory
In file included from deviceQuery.cpp:19:
/Developer/GPU Computing/shared/inc/shrUtils.h:49:27: error: rendercheckGL.h: No such file or directory
deviceQuery.cpp: In function ‘int main(int, const char**)’:
deviceQuery.cpp:121: error: ‘string’ is not a member of ‘std’
deviceQuery.cpp:121: error: expected `;' before ‘sProfileString’
deviceQuery.cpp:125: error: ‘sProfileString’ was not declared in this scope
make: *** [obj/i386/release/deviceQuery.cpp.o] Error 1

...全文
474 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjx1020 2010-07-29
  • 打赏
  • 举报
回复
不用这么麻烦
直接nvcc,再加上cuda的头文件、库文件路径就行了
  • 打赏
  • 举报
回复
rendercheckGL.h没找到?
LZ的include路径是否修改过了?

581

社区成员

发帖
与我相关
我的任务
社区描述
CUDA™是一种由NVIDIA推出的通用并行计算架构,该架构使GPU能够解决复杂的计算问题。 它包含了CUDA指令集架构(ISA)以及GPU内部的并行计算引擎。
社区管理员
  • CUDA编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧