Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble with building Cuda programme in VS2008: LNK2019
    primarykey
    data
    text
    <p>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:</p> <blockquote> <p>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</p> </blockquote> <p>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.</p> <p>I have defined the methods in the following files:</p> <p>crowdSim.cuh:</p> <pre><code> 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); } </code></pre> <p>crowdSim.cu:</p> <pre><code>#include &lt;cstdlib.h&gt; #include &lt;cstdio.h&gt; #include &lt;string.h&gt; #include &lt;cuda_gl_interop.h&gt; // 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" </code></pre> <p>and they are only called from the _create method in my "Crowd" class from crowdSim.cpp:</p> <pre><code>#include &lt;math.h&gt; #include &lt;memory.h&gt; #include &lt;cstdio&gt; #include &lt;cstdlib&gt; #include &lt;GL/glew.h&gt; #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, &amp;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**) &amp;dPosIn, memSize); allocToDevice((void**) &amp;dPosOut, memSize); allocToDevice((void**) &amp;dVelIn, memSize); allocToDevice((void**) &amp;dVelOut, memSize); mapBuffer((void**)&amp;dPosVbo, posVbo); setParameters(&amp;params); } </code></pre> <p>I feel like I am missing something very basic here but I can't work out what so any help would be great!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload