Quantcast
Channel: Qt DevNet forums: Installation and Deployment
Viewing all articles
Browse latest Browse all 2113

Convert Windows Project to Linux, problem linking to Shared Library

$
0
0
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 [qt-project.org]) 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

Viewing all articles
Browse latest Browse all 2113

Trending Articles