Earlybite
Earlybite

Reputation: 147

Own lib, another computer: cannot open shared object file: No such file or directory

Today my testing went on, but I always got : "cannot open shared object file". So I made a little programm including the most important things:

The bin: Test; The lib: TestLib

The lib:

h:

 class TestLib{
  public:
   TestLib();
   void DoSome();
 };

cpp:

 #include "testlib.h"
 #include <iostream>

 TestLib::TestLib(){
 }

 void TestLib::DoSome(){
  std::cout << "Hallo Test_Lib!" << std::endl; std::cout.flush();
 }

The bin:

QT creator pro.file:

    HOME = $$system(echo $HOME)
    TEMPLATE = app
    CONFIG += console
    CONFIG -= app_bundle
    CONFIG -= qt

    SOURCES += main.cpp

    LIBS += -L$$HOME/Test_Lib/Libs/ -Wl,-rpath=$$HOME/Test_Lib/Libs/ -lTestLib -ldl -lpthread -lrt

    INCLUDEPATH += $$HOME/Test_Lib/Includes/
    DEPENDPATH += $$HOME/Test_Lib/Includes/

and main():

    #include "testlib.h"

    int main(){
        TestLib nLib;
        nLib.DoSome();
        return 0;
    }

The files on each computer are in

   /home/USERNAME/Test_Lib
   /home/USERNAME/Test_Lib/Includes/
   /home/USERNAME/Test_Lib/Libs/

On the development computer I can run ./Test and the output is "Hallo Test_Lib!".

But on my other computer I get the error "cannot open shared object file: libTestLib : no such file or directory".

Both computers have Linux Mint-17-64-KDE installed...

How do I get it working?

Greeting Earlybite

Upvotes: 1

Views: 175

Answers (1)

Elried
Elried

Reputation: 81

It appears that your Lib is a shared object. You have 2 solutions :

  • You can use a static lib (.a file) so the shared object won't be needed at runtime (it will be directly embedded in your executable file)
  • You can also provide the LibTestLib file with your binary file (Exactly like you would do for a DLL on Windows).

Upvotes: 0

Related Questions