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
Forum Updated to NodeBB v4.3 + New Features

Simple OpenCL under QT Creator

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
7 Posts 5 Posters 3.6k 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 16 Sept 2017, 10:54 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.

    J 1 Reply Last reply 18 Sept 2017, 09:16
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 16 Sept 2017, 21:38 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
      • A Offline
        A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on 17 Sept 2017, 04:17 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
          16 Sept 2017, 10:54

          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.

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 18 Sept 2017, 09:16 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
          • A Offline
            A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on 18 Sept 2017, 11:54 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.

            J 1 Reply Last reply 18 Sept 2017, 11:57
            1
            • A aha_1980
              18 Sept 2017, 11:54

              @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?

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 18 Sept 2017, 11:57 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 22 Sept 2017, 15:52 last edited by mchinand
                #7

                Check out this link for using OpenCL with CMake.

                1 Reply Last reply
                0

                1/7

                16 Sept 2017, 10:54

                • Login

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