Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved linking to a shared object in Linux

    General and Desktop
    2
    4
    1159
    Loading More Posts
    • 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.
    • mzimmers
      mzimmers last edited by mzimmers

      Hi -

      I'm trying to follow a very simple tutorial on using shared libraries. Unfortunately for me, the author of the tutorial used Windows as his platform, and I'm trying to do this on Linux.

      I've created the library, and have moved them into the source directory of my app that is to use the library. When I build, I get this error message:

      :-1: error: cannot find -l097sharedlib.so
      

      I've put this line in my .pro file:

      LIBS += -L/home/mzimmers/QtStuff/tutorials/098sharedlibuser -l097sharedlib.so
      

      According the wiki, this should work. What might I be doing wrong?

      Thanks...

      kshegunov 1 Reply Last reply Reply Quote 0
      • kshegunov
        kshegunov Moderators @mzimmers last edited by

        Ordinarily libraries are prefixed on Linux, so a library named SomeLibrary will be present on the filesystem as libSomeLibrary.so. Whenever you link it through the LIBS variable you don't specify the prefix nor the suffix, so you'd link as:

        LIBS += -L/path/to/some/library -lSomeLibrary
        

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply Reply Quote 5
        • mzimmers
          mzimmers last edited by

          Hi, Kshegunov -

          Thanks for that; I'd forgotten about that little Linux nauance. Unfortunately, it's still giving me the same error code. Here's the .pro file:

          QT += core
          QT -= gui
          
          CONFIG += c++11
          
          TARGET = 098sharedlibuser
          CONFIG += console
          CONFIG -= app_bundle
          
          LIBS += -L/home/mzimmers/QtStuff/tutorials/098sharedlibuser -l097sharedlib
          TEMPLATE = app
          
          SOURCES += main.cpp
          
          # The following define makes your compiler emit warnings if you use
          # any feature of Qt which as been marked deprecated (the exact warnings
          # depend on your compiler). Please consult the documentation of the
          # deprecated API in order to know how to port your code away from it.
          DEFINES += QT_DEPRECATED_WARNINGS
          
          # You can also make your code fail to compile if you use deprecated APIs.
          # In order to do so, uncomment the following line.
          # You can also select to disable deprecated APIs only up to a certain version of Qt.
          #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
          
          HEADERS += \
              _097sharedlib.h \
              _097sharedlib_global.h
          
          
          
          1 Reply Last reply Reply Quote 0
          • mzimmers
            mzimmers last edited by

            Oops - disregard my latest message. I'd neglected the "_" at the start of the library name. Now I build OK. Thanks!

            1 Reply Last reply Reply Quote 2
            • First post
              Last post