How to create a standalone executable with gcc?

To do some compiler evaluation work, I need to be able to create executables on the current Linux platform with the latest versions of gcc / clang, and then copy these executables to the earlier Linux platform for testing and benchmarking. Of course, this does not work, because the older platform has older versions of various shared libraries. So far I have tried:

  • copy the various necessary .so libraries to the target system and set LD_LIBRARY_PATH so that they are raised - this leads to errors, such as:

./foo:/lib64/libm.so.6: version of `GLIBC_2.15 'not found (required. / foo)

and then when they are resolved by adding more .so files, I get:

ls: move error: ./ libc.so.6: symbol _dl_find_dso_for_object, the version of GLIBC_PRIVATE is not defined in the ld-linux-x86-64.so.2 file with a link to the link

  • I also tried using -static when linking, but then no different libraries were found and links were not deleted (apparently because many libraries exist only in general form)

I found one possible solution in various old (similar, but not duplicate) StackOverflow questions (for example, Compile a shared library into a program? ), But this approach seems very convoluted - it requires that all library dependencies be met and converted to static libraries. Ironically, the tools used in these solutions are apparently only available as closed-source binary files.

This seems to be a common problem - otherwise, how do people distribute binary-only applications? Did I miss a simpler solution here?


UPDATE

I just tried the trial version of Magic Ermine and it works as advertised. Since this is only a short-term requirement, I probably stick to this decision, but see the Comments below for alternative suggestions. Also see the free statifier tool from the same author as Magic Ermine. Now I close this question as a duplicate, but leave it here for future visitors.

+5
source share

Source: https://habr.com/ru/post/1234354/


All Articles