unresolved external symbol clIcdGetPlatformIDsKHR...

I originally posted this on the AMD OpenCL forum, but since I wasn’t getting any replies and this may be more related to a misunderstanding of mine with the OpenCL spec than my usage of the AMD APP SDK, I’m cross posting it here as well.

I’m trying to experiment using clIcdGetPlatformIDsKHR, but I can’t even seem to get my first test code to compile. I’m using the Visual Studio 2010 with the AMD APP SDK 2.6 and Catalyst 12.4–installed after the SDK. I’ve added $(AMDAPPSDKROOT)include and $(AMDAPPSDKROOT)lib\x86_64 (for x64) to the include and library directories, respectively, and added the OpenCL.lib to the linked libraries. Here’s the short source code

#if defined(__APPLE__) || defined(__MACOSX)
#include <OpenCL/cl.hpp>
#include <CL/cl.hpp>
int main(int argc, char *argv[])
    cl_int status = CL_SUCCESS;
    cl_uint num_platforms = 0;
    cl_platform_id *platforms = NULL;
    status |= clIcdGetPlatformIDsKHR(num_platforms, platforms, &num_platforms);
    platforms = new cl_platform_id[num_platforms];
    status |= clIcdGetPlatformIDsKHR(num_platforms, platforms, &num_platforms);
    delete [] platforms;
    return status;

and error

error LNK2019: unresolved external symbol clIcdGetPlatformIDsKHR referenced in function main

Could anyone guess as to what’s causing this error and how I could fix it? Thanks!

Do you enable cl_khr_icd extension as the documentation note says?

#pragma OPENCL EXTENSION cl_khr_icd : enable

Thank you for pointing that out; however I still get the same error even after including that extension enable line at the beginning or end of the header include section.

Any other suggestions?

Did you check the extension is supported on the given device?

The platform supports the cl_khr_icd extension, although I don’t see it listed under any of the device extensions. Since this function is called on the host side it should work, right?

Platform Profile: FULL_PROFILE
Platform Version: OpenCL 1.2 AMD-APP (923.1)
Platform Name: AMD Accelerated Parallel Processing
Platform Vendor: Advanced Micro Devices, Inc.
Platform Extensions: cl_khr_icd cl_amd_event_callback cl_amd_offline_devices cl_khr_d3d10_sharing

I wanted to bump this thread, as I have the same problem.

It seems to me that I might be supposed to use clGetExtensionFunctionAddressForPlatform to get a pointer to the actual function, but because that function requires a platform to be passed in, I’m quite confused, since I need clIcdGetPlatformIDsKHR to get all the platform IDs as a starting point.

Also, I don’t think #pragma OPENCL EXTENSION cl_khr_icd : enable would help at all. The way I understand it (from my limited experience with OpenCL and my reading of the specs) that pragma applies to OpenCL C code meant to be compiled and run on the device, not to host code as we are discussing here. However, it is very likely that I may be missing something.

I must add that my code is already working using clGetPlatformIDs, and my device does support the cl_khr_icd extension. I’m on Windows 7, using VS11 Beta, with AMD APP SDK 2.7.

Thanks in advance for any help, advice, pointers, etc.!