Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Simple OpenCL under QT Creator
Qt 6.11 is out! See what's new in the release blog

Simple OpenCL under QT Creator

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
7 Posts 5 Posters 4.2k Views 1 Watching
  • 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.
  • P Offline
    P Offline
    peter_cz
    wrote on last edited by peter_cz
    #1

    Dears,

    I am using QTCreator w CMake to get compiled and run OpenCL example where I am getting errors to build.

    Simple example minimal-opencl-on-windows can be built with MinGW/Windows

    >gcc --version
    gcc (x86_64-posix-seh-rev2, Built by MinGW-W64 project) 7.1.0
    Copyright (C) 2017 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    

    such as

    >gcc -Ic:\opencl\include\ main.c -Lc:\opencl\bin\x86_64\ -lOpenCL -o main.exe
    

    or

    gcc -Ic:\opencl\include\ main.c c:\opencl\bin\x86_64\OpenCL.dll -o main.exe
    

    under QTCreator/CMake I have CMakeLists.txt

    cmake_minimum_required(VERSION 2.8)
    
    project(opencl_test)
    add_executable(${PROJECT_NAME} "main.c")
    set (CMAKE_CXX_FLAGS "-lOpenCL")
    INCLUDE_DIRECTORIES("c:\\opencl\\include\\")
    LINK_DIRECTORIES("c:\\opencl\\bin\\x86_64\\")
    target_link_libraries(opencl_test OpenCL.dll)
    

    unfortunatelly I am getting error

    :-1: error: cannot find -lOpenCL
    collect2.exe:-1: error: error: ld returned 1 exit status
    

    I am looking for resolution of this to get it compiled, can you help please?

    Thank you.

    jsulmJ 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Where's OpenCL.lib on your system ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @peter_cz said in Simple OpenCL under QT Creator:

        :-1: error: cannot find -lOpenCL
        collect2.exe:-1: error: error: ld returned 1 exit status

        Can you please also show the compile output before? Especially the effective linker call.

        As shot in the dark, I'd try to remove the trailing backslash from LINK_DIRECTORIES:

        LINK_DIRECTORIES("c:\\opencl\\bin\\x86_64")
        

        because I already had problems with qmake in such a case.

        Qt has to stay free or it will die.

        1 Reply Last reply
        0
        • P peter_cz

          Dears,

          I am using QTCreator w CMake to get compiled and run OpenCL example where I am getting errors to build.

          Simple example minimal-opencl-on-windows can be built with MinGW/Windows

          >gcc --version
          gcc (x86_64-posix-seh-rev2, Built by MinGW-W64 project) 7.1.0
          Copyright (C) 2017 Free Software Foundation, Inc.
          This is free software; see the source for copying conditions.  There is NO
          warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
          

          such as

          >gcc -Ic:\opencl\include\ main.c -Lc:\opencl\bin\x86_64\ -lOpenCL -o main.exe
          

          or

          gcc -Ic:\opencl\include\ main.c c:\opencl\bin\x86_64\OpenCL.dll -o main.exe
          

          under QTCreator/CMake I have CMakeLists.txt

          cmake_minimum_required(VERSION 2.8)
          
          project(opencl_test)
          add_executable(${PROJECT_NAME} "main.c")
          set (CMAKE_CXX_FLAGS "-lOpenCL")
          INCLUDE_DIRECTORIES("c:\\opencl\\include\\")
          LINK_DIRECTORIES("c:\\opencl\\bin\\x86_64\\")
          target_link_libraries(opencl_test OpenCL.dll)
          

          unfortunatelly I am getting error

          :-1: error: cannot find -lOpenCL
          collect2.exe:-1: error: error: ld returned 1 exit status
          

          I am looking for resolution of this to get it compiled, can you help please?

          Thank you.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @peter_cz Adding libraries is actually done like this:

          LIBS += -Lc:/opencl/bin/x86_64 -lOpenCL
          

          See http://doc.qt.io/qtcreator/creator-project-qmake-libraries.html
          Also, no need to use \\, just use / (even on Windows).

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @jsulm said in Simple OpenCL under QT Creator:

            LIBS += -Lc:/opencl/bin/x86_64 -lOpenCL

            See http://doc.qt.io/qtcreator/creator-project-qmake-libraries.html
            Also, no need to use \, just use / (even on Windows).

            Did you read that he uses CMake, not qmake?

            Qt has to stay free or it will die.

            jsulmJ 1 Reply Last reply
            1
            • aha_1980A aha_1980

              @jsulm said in Simple OpenCL under QT Creator:

              LIBS += -Lc:/opencl/bin/x86_64 -lOpenCL

              See http://doc.qt.io/qtcreator/creator-project-qmake-libraries.html
              Also, no need to use \, just use / (even on Windows).

              Did you read that he uses CMake, not qmake?

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @aha_1980 You're right

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mchinand
                wrote on last edited by mchinand
                #7

                Check out this link for using OpenCL with CMake.

                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