rolandman99

Help OpenCL Hello World in VS2008 Express

Discussion created by rolandman99 on Sep 23, 2010
Latest reply on Sep 24, 2010 by himanshu.gautam

Hi,

 

I tried this code example with ATI Stream SDK 2.01 and VS2008 Express. I read other thread in this forum and follow their example

 

#include
#include
#define alloca _alloca
#define __NO_STD_VECTOR // Use cl::vector and cl::string and
#define __NO_STD_STRING  // not STL versions, more on this later
#include

#include
#include
#include
#include
#include
#include

const cl::string hw("Hello World\n");

inline void
checkErr(cl_int err, const char * name)
{
    if (err != CL_SUCCESS) {
        std::cerr << "ERROR: " << name
                 << " (" << err << ")" << std::endl;
        exit(EXIT_FAILURE);
    }
}

int main(void)
{
    cl_int err;
    cl::vector< cl::Platform > platformList;
    cl::Platform::get(&platformList);
    checkErr(platformList.size()!=0 ? CL_SUCCESS : -1, "cl::Platform::get");
    std::cerr << "Platform number is: " << platformList.size() << std::endl;
   return 0;
}

 

I got the error:

1>------ Build started: Project: TestOpenCL, Configuration: Debug Win32 ------
1>Linking...
1>main.obj : error LNK2019: unresolved external symbol _clGetPlatformIDs@12 referenced in function "public: static int __cdecl cl::Platform::get(class cl::vector *)" (?get@Platform@cl@@SAHPAV?$vector@VPlatform@cl@@$09@2@@Z)
1>C:\Documents and Settings\user\My Documents\Visual Studio 2008\Projects\TestOpenCL\Debug\TestOpenCL.exe : fatal error LNK1120: 1 unresolved externals


...


1>TestOpenCL - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Anyone know what is the cause of this error?  One more, anyone can give a hint (or maybe more detail steps) how to compile the OpenCL samples come with the SDK?

I really got frustrated setting the VS 2008 to build the example. Do I need to set the lib file, etc (for example in D3DX, we set the d3d10.lib, d3dx10.lib, etc). Can someone give a detail enough step to do this?

Thank you very much for help.

 

 

Outcomes