-1

I would like to create a dynamic library hello.so on linux with some of my own functions. With ldd, it needs some system libraries like libstdc++.so.

I am wondering if I could fix that this hello.so will always bind to the libstdc++.so when creating hello.so in my computer. Thus, I could send hello.so and libstdc++.so to other people.

Regards, Feng

Feng
  • 31
  • 2
  • What problem are you *actually* trying to solve? – Employed Russian May 05 '17 at 03:20
  • I want to give my libhello.so to other people. I would like that other people can also use it in his computer. With ldd, I find that libhello.so use libstdc++.so in my computer. I want that libhello.so can always bind to libstdc++.so. – Feng May 05 '17 at 03:28
  • The version of libstdc++.so in different system could be different. – Feng May 05 '17 at 03:29
  • "The version of libstdc++.so in different system could be different." -- yes, but why is *that* a problem? You are doing a poor job explaining your actual problem, and without that you are not going to get a good answer. – Employed Russian May 05 '17 at 03:36
  • Ok. We call the libstdc++.so used in computer 1 is libstdc++1.so. In computer 1, libhello.so works well since it binds to libstdc++1.so. In computer 2, normally g++ will bind libhello.so with libstdc++2.so throught LD_LIBRARY_PATH etc. This could have problems. So, I want to give other people both libhello.so and libstdc++1.so and force libhello.so bind with libstdc++1.so no matter what environment used in computer 2. – Feng May 05 '17 at 04:23

1 Answers1

0

When you make a program or library for distribution that has dependencies on dynamic libraries (shared libraries, on unix-like OSes; DLLs on Windows) you accept as a matter of course that its operability on any computer is constrained by the availability of identical or compatible versions of those runtime dependencies, i.e. you can only distribute to an ecosystem of compatible hosts. That is the basis of the linux, Windows, MacOS, android, iOS ecosystems, which function well upon it.

Is you want to distribute software that has no dynamic library dependencies to maximize its compatibility to the utmost (and beyond what is normally sought) then you must build it with static linkage, so that the binary itself contains all of the code that it needs to execute. To do this successfully you must have have installed on your system static versions of all the libraries (such as libstdc++) with which you would by default link the dynamic versions provided with your toolchain.

Unless you have some specific fell-founded requirement to deliver a statically linked product, don't worry about this.

Community
  • 1
  • 1
Mike Kinghan
  • 55,740
  • 12
  • 153
  • 182