Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Convert Windows Project to Linux, problem linking to Shared Library
Forum Updated to NodeBB v4.3 + New Features

Convert Windows Project to Linux, problem linking to Shared Library

Scheduled Pinned Locked Moved Installation and Deployment
7 Posts 4 Posters 2.4k 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.
  • T Offline
    T Offline
    TheCreator
    wrote on last edited by
    #1

    Hello Qt Community,

    I'm working with Qt for some time now, solving all my problems with this forum and API. Thanks for that! But now I'm stuck porting my project to linux. I'm developing some custom GUIs for a third party software. Working with Visual Studio I managed to create a shared library myserver.dll. Linking from all my clients (custom GUIs) to myserver.dll with myserver.lib and myserver.h works fine! For Windos only...

    ...porting this to linux gives me headache. I have no experience in linux, except what I read the last days. Since this is only a linux problem I suppose my source code is fine. (I followed Qt Tutorials "SharedLibrary":http://qt-project.org/doc/qt-4.8/sharedlibrary.html)

    server.h
    @#ifndef _H_CWNCPLCSERVER_INCLDUED
    #define _H_CWNCPLCSERVER_INCLUDED

    #include <QtCore/QObject>
    #include <QtCore/QList>
    #include <QtCore/QVariant>

    class QSettings;

    #ifdef CWNCPLCSERVER_EXPORTS
    #define CWNCPLCSERVER_API Q_DECL_EXPORT
    #else
    #define CWNCPLCSERVER_API Q_DECL_IMPORT
    #endif

    class CWNCPLCSERVER_API CWNcPlcServer : public QObject
    {
    Q_OBJECT
    };

    #endif //_H_CWNCPLCSERVER_INCLDUED@

    dummyclient.cpp
    @#include "cwdummyclientdialog.h"
    #include "cwncplcserver.h"

    CWDummyClientdialog::CWDummyClientdialog(QObject* pParent , const QString& rsName )
    {
    //Name des Clients
    m_myName = "DummyClient";

    //Verbindung zu Server wird erstellt
    m_myServer = CWNcPlcServer::connectToServer(m_myName, this);
    }

    CWDummyClientdialog::~CWDummyClientdialog (void)
    {
    //Verbindung zu Server wird getrennt
    CWNcPlcServer::disconnectFromServer(m_myName);
    }@

    dummyclient.pro
    @TEMPLATE = lib
    CONFIG += qt warn_on thread plugin ${BUILDMODE}
    PROJECT = CWDummyClient
    TARGET = $(BUILDMODE)/output/appl/cwdummyclient
    LANGUAGE = C++

    UI_DIR = .ui
    MOC_DIR = .moc
    OBJECTS_DIR = .obj

    INCLUDEPATH += /user/oapack/gui/include
    /user/oapack/include
    /user/oapack/linux/ace/embedded/${BUILDMODE}

    #für Qt/embedded
    unix:LIBS += -L/user/oapack/bin/${BUILDMODE}
    unix:LIBS += -L${QTDIR}/lib
    -l${LIBQT_CORE}
    -l${LIBQT_GUI}
    -l${LIBQT_XML}

    unix:!mac{
    QMAKE_LFLAGS += -Wl,-rpath=\$$ORIGIN
    QMAKE_RPATH=
    }

    LIBS += -lcwncplcserver -lslgfw -lslgfwwidget -lslcap -lsltrc -lslmd -lsltrp -lslhmiutilitieslib -lslaesvcadapter -lslfsfilesvcadapter -lsltraceadapter -lslarchiveadapter
    LIBS += -L/mnt/windows/workspace/ -lcwncplcserver

    SOURCES += cwdummyclientdialog.cpp

    HEADERS += cwdummyclientdialog.h
    cwncplcserver.h
    resource.h@

    server.pro
    @TEMPLATE = lib
    CONFIG += qt warn_on thread plugin ${BUILDMODE}
    PROJECT = CWNcPlcServer
    TARGET = $(BUILDMODE)/output/appl/cwncplcserver
    LANGUAGE = C++

    UI_DIR = .ui
    MOC_DIR = .moc
    OBJECTS_DIR = .obj

    INCLUDEPATH += /user/oapack/gui/include
    /user/oapack/include
    /user/oapack/linux/ace/embedded/${BUILDMODE}

    DEFINES += CWNCPLCSERVER_EXPORTS

    #für Qt/embedded
    unix:LIBS += -L/user/oapack/bin/${BUILDMODE}
    unix:LIBS += -L${QTDIR}/lib
    -l${LIBQT_CORE}
    -l${LIBQT_GUI}
    -l${LIBQT_XML}
    -l${LIBQT_NETWORK}

    LIBS += -lsltmutilities -lsltmserviceadapter -lslgfw -lslgfwwidget -lslcap -lsltrc -lslmd -lsltrp -lslhmiutilitieslib -lslaesvcadapter -lslfsfilesvcadapter -lsltraceadapter -lslarchiveadapter

    SOURCES += cwhotlink.cpp
    cwlog.cpp
    cwncplcserver.cpp

    HEADERS += cwhotlink.h
    cwlog.h
    cwncplcserver.h
    cwglobalconstants.h
    cwncplcsignals.h
    resource.h@

    I'm not sure where to look first. Is there something similar to .lib files for linux? Or do I have to use the same cwncplcserver.so file to compile my client and to run my client (that's what i've done so far)? There are no compile errors. The client on its own is running fine on linux. But when I try to access the server library it crashes, library not found/compatible.
    I set "DEFINES += CWNCPLCSERVER_EXPORTS " in cwncplcserver.pro file. I included path to lib "LIBS += -L/mnt/windows/workspace/ -lcwncplcserver" in client.pro file for linking to library. Also I added following to client.pro, because client.so and server.so are in the same directory and linux isn't searching in run path on it's own:
    @unix:!mac{
    QMAKE_LFLAGS += -Wl,-rpath=\$$ORIGIN
    QMAKE_RPATH=
    }@

    I've read about QLibrary, but I thought it's a better way to link to the shared library. Can anyone give me a hint what I could have missed or what I could try next?

    Thank you! TheCreator

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rst256
      wrote on last edited by
      #2

      use nm utilites to check connect to lib.
      add to pro file message($$LIBS) and check path and name of library
      if you use debug build library file name may have 'd' on the end.

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

        Hi and welcome to devnet,

        There's no such thing a lib file in linux you link directly to the so/a files depending on whether you are using a shared or a static build.

        However, there's something not clear here. Did you compile your server library on linux ?

        @LIBS += -L/mnt/windows/workspace/@

        Looks fishy, are you trying to use a windows filesystem on your linux ?

        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
        • T Offline
          T Offline
          TheCreator
          wrote on last edited by
          #4

          Hi,

          thanks for your answers and sorry for that late reply.

          I "solved" the problem, it was something completely different. I built a new project, everything written in lowercase (settings, file names, ...). Except of that everything else remains the same. And it worked...

          I couln't find the exact position what caused the crash yet. I'm not sure if it's a linux problem or a bug of the third party software. Or a bug of mine. I'm still trying to find the problematic place. But now I know how to work around.

          To answer your question, I'm compiling with colinux.To copy all files into that colinux image, this directory is mapped automatically. I'm still working on both, clients and server, so I thought this could be an easy way to include a library that changes often. If there's a better solution I'm open for suggestions.

          TheCreator

          EDIT:
          The filename of the library itself was already in lowercase.

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

            case sensitive VS case insensitive filesystem ?

            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
            • T Offline
              T Offline
              TheCreator
              wrote on last edited by
              #6

              This might be the problem. Actually I named my files, classes, configurations continuously casesensitive, or rather in camelcase, for better understanding and to prevent those problems. Perhaps a wrong character slipped in anywhere, don't know.
              Thank you for your help.

              1 Reply Last reply
              0
              • D Offline
                D Offline
                dvb0222
                wrote on last edited by
                #7

                Thanks for the reference to colinux.


                David Van Beveren
                Oak Park Technology Corp.
                Malibu, California
                vbdavid@gmail.com

                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