Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Error: Cannot find -lSDL2

Error: Cannot find -lSDL2

Scheduled Pinned Locked Moved Solved 3rd Party Software
librarysdl2includepath
16 Posts 3 Posters 1.9k 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.
  • jsulmJ jsulm

    @ajcdev said in Error: Cannot find -lSDL2:

    win32:LIBS += "C:\Users\admin\Documents\SDL2-2.28.5\i686-w64-mingw32\lib\libSDL2.a"

    This is for static library. Do you want to link dynamically? If so, then you have to add *.lib, not *.a

    A Offline
    A Offline
    ajcdev
    wrote on last edited by
    #5

    @jsulm Yeah I want to link dynamically.

    I tried this:

    win32:LIBS += C:\Users\admin\Documents\SDL2-2.28.5\i686-w64-mingw32\lib\*.lib
    

    Now the error is this:

    :-1: error: cannot find C:\Users\admin\Documents\SDL2-2.28.5\i686-w64-mingw32\lib*.lib: Invalid argument

    jsulmJ 1 Reply Last reply
    0
    • A ajcdev

      @jsulm Yeah I want to link dynamically.

      I tried this:

      win32:LIBS += C:\Users\admin\Documents\SDL2-2.28.5\i686-w64-mingw32\lib\*.lib
      

      Now the error is this:

      :-1: error: cannot find C:\Users\admin\Documents\SDL2-2.28.5\i686-w64-mingw32\lib*.lib: Invalid argument

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

      @ajcdev said in Error: Cannot find -lSDL2:

      win32:LIBS += C:\Users\admin\Documents\SDL2-2.28.5\i686-w64-mingw32\lib*.lib

      What is this please?! You have to put the file name of your library instead of *.lib...

      Are you using MinGW compiler?

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

      A 1 Reply Last reply
      0
      • jsulmJ jsulm

        @ajcdev said in Error: Cannot find -lSDL2:

        win32:LIBS += C:\Users\admin\Documents\SDL2-2.28.5\i686-w64-mingw32\lib*.lib

        What is this please?! You have to put the file name of your library instead of *.lib...

        Are you using MinGW compiler?

        A Offline
        A Offline
        ajcdev
        wrote on last edited by
        #7

        @jsulm Yes I am using MinGW compiler. I do apologize since I'm really new when it comes to Qt Creator.

        Also I don't have a .lib file in my SDL2 library and they're all .a files. I downloaded the SDL2 that uses MingW from their repository.

        1 Reply Last reply
        0
        • A ajcdev

          @jsulm No. I just downloaded the SDL2 from their Github repository.

          This is what I have done so far. Now it can't detect the SDL2 library itself:

          QT       += core gui
          
          greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
          
          CONFIG += c++17
          
          # You can make your code fail to compile if it uses deprecated APIs.
          # In order to do so, uncomment the following line.
          #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
          
          SOURCES += \
              main.cpp \
              aerodesk.cpp
          
          HEADERS += \
              aerodesk.h
          
          FORMS += \
              aerodesk.ui
          
          # Default rules for deployment.
          qnx: target.path = /tmp/$${TARGET}/bin
          else: unix:!android: target.path = /opt/$${TARGET}/bin
          !isEmpty(target.path): INSTALLS += target
          
          win32:LIBS += "C:\Users\admin\Documents\SDL2-2.28.5\i686-w64-mingw32\lib\libSDL2.a"
          
          INCLUDEPATH += $$PWD/../../SDL2-2.28.5/i686-w64-mingw32/include/SDL2
          DEPENDPATH += $$PWD/../../SDL2-2.28.5/i686-w64-mingw32/include/SDL2
          
          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #8

          @ajcdev said in Error: Cannot find -lSDL2:

          Now it can't detect the SDL2 library itself

          What does this mean? What exactly happens if you try to link the static version?

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

          A 1 Reply Last reply
          0
          • jsulmJ jsulm

            @ajcdev said in Error: Cannot find -lSDL2:

            Now it can't detect the SDL2 library itself

            What does this mean? What exactly happens if you try to link the static version?

            A Offline
            A Offline
            ajcdev
            wrote on last edited by
            #9

            @jsulm

            win32:LIBS += "C:\Users\admin\Documents\SDL2-2.28.5\i686-w64-mingw32\lib\libSDL2.a"
            

            So this is what I used since there's no .lib files in the SDL2 MingW library. What happens is that my SDL2 codes get an error that they become undefined.

            aerodesk.cpp:16: error: undefined reference to `SDL_Init'
            
            Christian EhrlicherC 1 Reply Last reply
            0
            • A ajcdev

              @jsulm

              win32:LIBS += "C:\Users\admin\Documents\SDL2-2.28.5\i686-w64-mingw32\lib\libSDL2.a"
              

              So this is what I used since there's no .lib files in the SDL2 MingW library. What happens is that my SDL2 codes get an error that they become undefined.

              aerodesk.cpp:16: error: undefined reference to `SDL_Init'
              
              Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #10

              @ajcdev Since your Qt version is 64bit you must also link against the 64bit sdl lib.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              A 1 Reply Last reply
              1
              • Christian EhrlicherC Christian Ehrlicher

                @ajcdev Since your Qt version is 64bit you must also link against the 64bit sdl lib.

                A Offline
                A Offline
                ajcdev
                wrote on last edited by
                #11

                @Christian-Ehrlicher I'm not sure how you do that. Do I need to add another library for SDL2 for this?

                jsulmJ 1 Reply Last reply
                0
                • A ajcdev

                  @Christian-Ehrlicher I'm not sure how you do that. Do I need to add another library for SDL2 for this?

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

                  @ajcdev You need to download and use 64bit version of that library. From where exactly did you download it?

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

                  A 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @ajcdev You need to download and use 64bit version of that library. From where exactly did you download it?

                    A Offline
                    A Offline
                    ajcdev
                    wrote on last edited by
                    #13

                    @jsulm I downloaded from their Github Repository.

                    I downloaded the one that comes with the MingW.

                    Christian EhrlicherC jsulmJ 2 Replies Last reply
                    0
                    • A ajcdev

                      @jsulm I downloaded from their Github Repository.

                      I downloaded the one that comes with the MingW.

                      Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #14

                      There is also a64 bit version in the dev zip file. Adjust your path accordingly.

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      1 Reply Last reply
                      0
                      • A ajcdev

                        @jsulm I downloaded from their Github Repository.

                        I downloaded the one that comes with the MingW.

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

                        @ajcdev Then use the lib in x86_64-w64-mingw32 subfolder. i686-w64-mingw32 is the 32bit version.

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

                        A 1 Reply Last reply
                        0
                        • jsulmJ jsulm

                          @ajcdev Then use the lib in x86_64-w64-mingw32 subfolder. i686-w64-mingw32 is the 32bit version.

                          A Offline
                          A Offline
                          ajcdev
                          wrote on last edited by
                          #16

                          @jsulm @Christian-Ehrlicher

                          Well, my code doesn't work after but I'll figure it out later.

                          I can say that the linking works properly now. Thanks for your help guys!

                          1 Reply Last reply
                          0
                          • A ajcdev has marked this topic as solved on

                          • Login

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