user1873073
user1873073

Reputation: 3660

'clUnloadCompiler': was declared deprecated when trying to compile OpenCL

I am trying to compile this. I am using the AMD SDK. I am using the header files that come with the aforementioned SDK and they are located in:

C:\Program Files (x86)\AMD APP\include\CL

The tutorial states:

Header files Just like any other external API used in C++, you must include a header file when using the OpenCL™ API. Usually, this is in the directory CL within the primary include directory. For the C++ bindings we have (replace the straight C API with cl.h):

I found that last bit a little confusing. I am using both .h and .hpp

#include <CL/cl.h> when this is used it will compile the checkErr function
#include <CL/cl.hpp> when this is used it gives me access to the cl namespace

When I try to compile this code it fails with:

'clUnloadCompiler': was declared deprecated

enter image description here

ADDITIONAL DETAILS (after removing #include <CL/c.h>)

It now gives the following list of errors: enter image description here

error C4996: Error  2   error LNK2019: unresolved external symbol _clReleaseCommandQueue@4 referenced in function "public: static int __cdecl cl::detail::ReferenceHandler<struct _cl_command_queue *>::release(struct _cl_command_queue *)" (?release@?$ReferenceHandler@PAU_cl_command_queue@@@detail@cl@@SAHPAU_cl_command_queue@@@Z)    


error LNK2019: unresolved external symbol _clReleaseContext@4 referenced in function "public: static int __cdecl cl::detail::ReferenceHandler<struct _cl_context *>::release(struct _cl_context *)" (?release@?$ReferenceHandler@PAU_cl_context@@@detail@cl@@SAHPAU_cl_context@@@Z)

In properties for my project I have:

  1. added C:\Program Files (x86)\AMD APP\include\ as an additional include directory
  2. added C:\Program Files (x86)\AMD APP\lib\x86_64 as an additional library directory
  3. added OpenCL.lib as an additional dependency

The errors I listed happen regardless of whether or not I take the last two steps. That is, the last two do not seem to be helping or harming anything

Upvotes: 1

Views: 1191

Answers (2)

Kyle Lutz
Kyle Lutz

Reputation: 8036

That's because clUnloadCompiler() was deprecated in OpenCL 1.2.

Add

#define CL_USE_DEPRECATED_OPENCL_1_1_APIS

to your code before

#include <CL/cl.h>
#include <CL/cl.hpp>

Upvotes: 3

Markku K.
Markku K.

Reputation: 3908

Summary of answers I provided in comments:

  1. For a C++ application, you only need to #include <CL/cl.hpp>
  2. Make sure you are linking with the correct OpenCL.lib (32-bit vs. 64-bit).

Upvotes: 3

Related Questions