Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]Compile opencl codes with clang and QtCreator on mac 10.8.3
QtWS25 Last Chance

[Solved]Compile opencl codes with clang and QtCreator on mac 10.8.3

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 3.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stereomatching
    wrote on last edited by
    #1

    @
    #include "mainwindow.h"
    #include <QApplication>

    #include <OpenCL/cl.h>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    cl_uint num_devices, i;
    clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, 0, NULL, &num_devices);
    
    return a.exec&#40;&#41;;
    

    }
    @

    error messages
    Undefined symbols for architecture x86_64:
    "_clGetDeviceIDs", referenced from:
    _main in main.o
    ld: symbol(s) not found for architecture x86_64

    mac is installed with opencl, so I expect this codes should work
    but looks like it can't find the dylib?

    my .pro file
    @
    #-------------------------------------------------

    Project created by QtCreator 2013-03-25T12:04:15

    #-------------------------------------------------

    QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = openclTest
    TEMPLATE = app

    SOURCES += main.cpp
    mainwindow.cpp

    HEADERS += mainwindow.h

    FORMS += mainwindow.ui

    @

    Qt ver : Qt5.0.1
    compiler : clang3.2
    OS : mac10.8.3

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stereomatching
      wrote on last edited by
      #2

      looks like this line could solve the problem
      @QMAKE_LFLAGS += -framework OpenCL@

      I am not sure this is a correct solution on mac or not, after
      I confirm this answer is acceptable, I will mark this post as
      Solved

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bruce3141
        wrote on last edited by
        #3

        This looks like great progress, did you get it to work? FYI, I'm just getting started with Qt and have a big interest in using OpenCL in this fashion. Thanks!

        1 Reply Last reply
        0
        • S Offline
          S Offline
          stereomatching
          wrote on last edited by
          #4

          [quote author="bruce3141" date="1372472346"]This looks like great progress, did you get it to work? FYI, I'm just getting started with Qt and have a big interest in using OpenCL in this fashion. Thanks![/quote]

          Sorry, I do not notice your reply
          Yes, it work on my mac mini, but the sad thing is the gpu of my mac mini
          do not support opencl yet.

          Just include the header and edit the .pro as I posted
          then you could play opencl on your mac

          1 Reply Last reply
          0
          • K Offline
            K Offline
            KaPu
            wrote on last edited by
            #5

            This is my HelloOpenCL *.pro file, it works on Mac.

            TEMPLATE = app
            CONFIG += console c++11
            CONFIG -= app_bundle
            CONFIG -= qt
            SOURCES += main.cpp
            QMAKE_LFLAGS += -framework OpenCL

            You have to install XCode first.
            Mac doesn't include the cl.hpp file. If you want to use C++ for OpenCL, download the header file from Khronos (https://www.khronos.org/registry/cl/api/2.1/cl.hpp), use the OpenCL C header in your program file (#include <OpenCL/opencl.h>), and store cl.hpp file in the same folder as where opencl.h is (find it by placing cursor on opencl.h and pressing F2, then press CMD+SHFT+S to get the file saving dialog which shows the folder you're in).
            The comments in cl.hpp show the code for your first Hello OpenCL program.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved