cuda的makefile问题
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