Trouble with building Cuda programme in VS2008: LNK2019

I am having some trouble with building my programme. I am working on Windows 7 professional 32-bit with Visual Studio 2008. I have the Cuda SDK and my project is set up with all links to cudart.lib etc. My problem is when I try to build my project it returns the following errors: > 1>crowdSim.obj : error LNK2019: > unresolved external symbol > _setParameters referenced in function "protected: void __thiscall > Crowd::_create(int)" > (?_create@Crowd@@IAEXH@Z) > 1>crowdSim.obj : error LNK2019: > unresolved external symbol _mapBuffer > referenced in function "protected: > void __thiscall Crowd::_create(int)" > (?_create@Crowd@@IAEXH@Z) > 1>crowdSim.obj : error LNK2019: > unresolved external symbol > _allocToDevice referenced in function "protected: void __thiscall > Crowd::_create(int)" > (?_create@Crowd@@IAEXH@Z) > 1>crowdSim.obj : error LNK2019: > unresolved external symbol > _registerBuffer referenced in function "protected: void __thiscall > Crowd::_create(int)" > (?_create@Crowd@@IAEXH@Z) > 1>../../bin/win32/Debug/crowd.exe : > fatal error LNK1120: 4 unresolved > externals It seems my problem is with how I am setting up my "allocToDevice", "mapBuffer", "setParameters", and "registerBuffer" methods since if I comment these out I can build the project no problem. I have defined the methods in the following files: crowdSim.cuh: extern "C" { void checkCUDAError(const char *msg); void setParameters(SimParams *hostParams); void registerBuffer(uint vbo); void allocToDevice(void **ptr, int memSize); void mapBuffer(void **ptr, uint vbo); } crowdSim.cu: #include #include #include #include // includes, kernels #include "crowd_kernel.cu" extern "C" { void checkCUDAError(const char *msg) { cudaError_t err = cudaGetLastError(); if( cudaSuccess != err) { fprintf(stderr, "Cuda error: %s: %s.\n", msg, cudaGetErrorString( err) ); exit(-1); } } void setParameters(SimParams *hostParams) { // copy parameters to constant memory cudaMemcpyToSymbol(params, hostParams, sizeof(SimParams)); } void registerBuffer(uint vbo) { cudaGLRegisterBufferObject(vbo); } void allocToDevice(void **ptr, size_t memSize) { cudaMalloc(ptr, memSize); } void mapBuffer(void **ptr, uint vbo) { cudaGLMapBufferObject(ptr, vbo); } } //extern "C" and they are only called from the _create method in my "Crowd" class from crowdSim.cpp: #include #include #include #include #include #include "crowdSim.h" #include "crowdSim.cuh" #include "crowd_kernel.cuh" Crowd::Crowd(uint crowdSize) : //numP(crowdSize), hPos(0), hVel(0), dPosIn(0), dVelIn(0), dPosOut(0), dVelOut(0) { params.numBodies = crowdSize; _create(crowdSize); } Crowd::~Crowd() { //_remove(); crowdSize = 0; } uint Crowd::newVBO(uint size) { GLuint vbo; // glGenBuffers(1, &vbo); // glBindBuffer(GL_ARRAY_BUFFER, vbo); // glBufferData(GL_ARRAY_BUFFER, size, 0, GL_DYNAMIC_DRAW); // glBindBuffer(GL_ARRAY_BUFFER, 0); return vbo; } void Crowd::_create(int numPeople) { crowdSize = numPeople; unsigned int memSize = sizeof(float) * crowdSize * 4; hPos = new float[crowdSize*4]; hVel = new float[crowdSize*4]; hPos = (float*) malloc(memSize); hVel = (float*) malloc(memSize); posVbo = newVBO(memSize); registerBuffer(posVbo); allocToDevice((void**) &dPosIn, memSize); allocToDevice((void**) &dPosOut, memSize); allocToDevice((void**) &dVelIn, memSize); allocToDevice((void**) &dVelOut, memSize); mapBuffer((void**)&dPosVbo, posVbo); setParameters(¶ms); } I feel like I am missing something very basic here but I can't work out what so any help would be great!

以上就是Trouble with building Cuda programme in VS2008: LNK2019的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » HBuilder

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏