Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Integrate a project with OpenCL SDK



  • Under Linux, I did not have to do anything special to the project, for it wo build against AMD OpenCL SDK. I just installed the SDK, included headers, and built.
    Under Windows it does not work. This project is 64bit. I tried adding:

    "C:\Program Files (x86)\AMD APP SDK\3.0\lib\x86_64"
    

    into the LIB and LIBPATH environment variables within the project properties, but the linker is still throwing these errors:

    OpenCLHelper.obj:-1: error: LNK2019: unresolved external symbol clGetPlatformIDs referenced in function "public: __cdecl OpenCLHelper::OpenCLHelper(unsigned int)" (??0OpenCLHelper@@QEAA@I@Z)
    

    etc. for each of the OpenCL symbols used.
    I also get a cryptic warning:

    C:\Program Files (x86)\AMD APP SDK\3.0\lib\x86\OpenCL.lib:-1: warning: LNK4272: library machine type 'X86' conflicts with target machine type 'x64'
    

    What is Qt's requirement with respect to the above issues?

    EDIT:

    I switched the platform temporarily to x86, added the corresponding paths to the x86 OpenCL SDK libs, and the project built successfully. What does this mean? Why is x64 library not recognized in the project settings, but x86 is?


  • Lifetime Qt Champion

    Hi,

    From the looks of it, you seem to be trying to link to your 64bit OpenCL from a 32bit build of your application.



  • Not at all. I want to build a 64 bit EXE. When I do, it does not build due to the linker errors.
    The bitness of the project in this case matches the bitness of the OpenCL .lib.

    But when I switch to the 32 bit output and add the 32 bit OpenCL directory to the paths, it builds.

    I thought that I described it exactly this way in the OP. If the OP is confusing, use this comment instead.


  • Lifetime Qt Champion

    To make things clearer, are you using a 64 bit build of Qt to build your application ?



  • Are you asking me what is the bitness of QTCreator? It is a 32 bit app according to Task Manager.
    Otherwise please explain what "64 bit build of Qt" is and how I can tell which it is.
    There are both 64 it and 32 bit kits under project settings. I can switch from one kit to another. Each kit is configured to use its own toolchain and there are no warnings or errors on the kits...


  • Lifetime Qt Champion

    No, the architecture of Qt Creator has nothing to do with the Qt version you are using.

    As for the architecture of Qt, you can see usually already see it in the Qt Versions panels. With default installation it's usually also part of the kit name.



  • Like I said, I have both kits installed. So what is your question? Sorry, but I do not follow.

    I tried to create a brand new app in Visual Studio w/o Qt and link to OpenCL. It is worse there: neither x86 nor x86-64 links with the same unresolved external symbol errors.

    I no longer think it has anything to do with Qt. Though, Qt does build 32bit... My brain hurts.


  • Lifetime Qt Champion

    What exact versions of Qt do you use ?



  • qt version


  • Lifetime Qt Champion

    That looks good...
    Just in case, did you check that the content of the x86_64 folder is really of the correct architecture ?



  • Microsoft (R) COFF/PE Dumper Version 14.00.24215.1
    Copyright (C) Microsoft Corporation.  All rights reserved.
    
    
    Dump of file OpenCL.lib
    
    File Type: LIBRARY
    
    FILE HEADER VALUES
                8664 machine (x64)
                   3 number of sections
            55C18963 time date stamp Tue Aug  4 23:56:19 2015
                 10A file pointer to symbol table
                   8 number of symbols
                   0 size of optional header
                   0 characteristics
    

    EDIT:

    The build in Visual Studio has been fixed, for both x86 and x64, by adding

    #pragma comment(lib, "OpenCL.lib")
    

Log in to reply