Build a Linux c++ application runnable on system having libc >= 2.31

ralvento

I would like to build a C++ application which can be launched on all Linux systems having libc >= 2.31. On my build system (Ubuntu), I have libc 2.34. Here is my (empty) application:

int main() {
  return 0;
}

I built it with g++ -o app app.cpp and according to the following result, I understand that my application requires libc >= 2.34 to run. Is my understanding correct ?

$ nm -D app
                 w __cxa_finalize@GLIBC_2.2.5
                 w __gmon_start__
                 w _ITM_deregisterTMCloneTable
                 w _ITM_registerTMCloneTable
                 U __libc_start_main@GLIBC_2.34

How build my application for libc <= 2.31 ? I tried to add "__asm__ (".symver __libc_start_main, __libc_start_main@GLIBC_2.2.5");" (based on my understanding of this post) before my main method but it does not change anything.

KamilCuk

Docker image ubuntu:20.04 has libc 2:31 installed. You could compile your application there:

$ docker run --rm -v $PWD:/work -w /work ubuntu:20.04 bash -c 'apt-get update && apt-get -y install g++ && g++ -o app app.cpp'
$ docker run --rm -v $PWD:/work -w /work ubuntu:20.04 ./app
$ ./app
$ nm -D app
             w _ITM_deregisterTMCloneTable
             w _ITM_registerTMCloneTable
             w __cxa_finalize@GLIBC_2.2.5
             w __gmon_start__
             U __libc_start_main@GLIBC_2.2.5

You could link your application statically, remove all dependencies on standard library.

You could distribute your application with libc library together.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Bundle c++ application using libc.so.6

From Java

How do I build my Linux c++ app to link to an old version of libc?

From Java

Build static ELF without libc using unistd.h from Linux headers

From Java

How to build BlackBerry application on Linux?

From Java

How to write an application for the system tray in Linux

From Dev

How to UrlDecode without having System.Web dll in c#

From Dev

Understanding 2^31 and -2^31 integer promotion

From Dev

C application that copy/moves a file & uses system calls in Linux

From Dev

Having Trouble building a distributed calculator system with C sharp

From Dev

Runnable (console) jar application

From Dev

Segfault in ret2libc attack, but not hardcoded system call

From Dev

Export Xtext project to application/runnable

From Dev

How to build C++17 application in old linux distro with old stdlib and libc?

From Dev

Debug with gdb an application running with different libc (ld-linux.so)

From Dev

Sublime text 2 build system

From Dev

What are the consequences of having a full partition on a Linux system?

From Dev

Sublime Build system for c++ in linux allowing input from file

From Dev

Linux System calls in C on OSX

From Dev

Is there a way to restrict the application access to the system time in linux?

From Dev

How to install Java application to my linux system

From Dev

C/Linux - having trouble with redirecting stdin and stout

From Dev

system("pause") for linux in gcc C

From Dev

How can I make Linux system calls from a C/C++ application, without using assembly, and in a cpu-independent manner?

From Dev

Not able to build .NET Core Console Application in Linux

From Dev

Can't build Qt Application for Android for arm64-v8a, libc++.so.16 not found error is shown

From Dev

How to build a Flink application with Maven in Linux

From Dev

C # application for linux?

From Dev

Preload a library on a system with musl libc

From Dev

EDK2 application fails to build when including both LibC & OpensslLib, stdatomic.h not found

Related Related

  1. 1

    Bundle c++ application using libc.so.6

  2. 2

    How do I build my Linux c++ app to link to an old version of libc?

  3. 3

    Build static ELF without libc using unistd.h from Linux headers

  4. 4

    How to build BlackBerry application on Linux?

  5. 5

    How to write an application for the system tray in Linux

  6. 6

    How to UrlDecode without having System.Web dll in c#

  7. 7

    Understanding 2^31 and -2^31 integer promotion

  8. 8

    C application that copy/moves a file & uses system calls in Linux

  9. 9

    Having Trouble building a distributed calculator system with C sharp

  10. 10

    Runnable (console) jar application

  11. 11

    Segfault in ret2libc attack, but not hardcoded system call

  12. 12

    Export Xtext project to application/runnable

  13. 13

    How to build C++17 application in old linux distro with old stdlib and libc?

  14. 14

    Debug with gdb an application running with different libc (ld-linux.so)

  15. 15

    Sublime text 2 build system

  16. 16

    What are the consequences of having a full partition on a Linux system?

  17. 17

    Sublime Build system for c++ in linux allowing input from file

  18. 18

    Linux System calls in C on OSX

  19. 19

    Is there a way to restrict the application access to the system time in linux?

  20. 20

    How to install Java application to my linux system

  21. 21

    C/Linux - having trouble with redirecting stdin and stout

  22. 22

    system("pause") for linux in gcc C

  23. 23

    How can I make Linux system calls from a C/C++ application, without using assembly, and in a cpu-independent manner?

  24. 24

    Not able to build .NET Core Console Application in Linux

  25. 25

    Can't build Qt Application for Android for arm64-v8a, libc++.so.16 not found error is shown

  26. 26

    How to build a Flink application with Maven in Linux

  27. 27

    C # application for linux?

  28. 28

    Preload a library on a system with musl libc

  29. 29

    EDK2 application fails to build when including both LibC & OpensslLib, stdatomic.h not found

HotTag

Archive