Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Compiling SO Files Embedded In The Executable

(1/2) > >>

EverydayDiesel:
Hello,

I have a server that I dont have sudo on but I need to run a C++ application that I wrote with code blocks.

At the moment I am getting these errors


--- Code: ---./test: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by ./test)
./test: /lib/x86_64-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.13' not found (required by ./test)
./test: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./test)
./test: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by ./test)

--- End code ---

Is there a way to make my executable bigger and have them embedded?

Thanks in advance for any help you can give

BlueHazzard:
I am no expert in this, but I think your problem is that you have compiled your program with a incompatible glibc version as that is running on your server

as far as i know you have two options to resolve your issue:
1) Use on the compiling pc the exact same version of gcc as available on the server ( to simplyfy you can use some vm like virtual box or some docker container) <- simple and fast
2) Embedd libc in your application, for this you have to compile it versus something like uClibc or musl (https://uclibc-ng.org/ http://musl.libc.org/ ) <- more compliucated and i do not know if this works with c++

BlueHazzard:
3) if your server supports flatpack you probably can also use flatpack https://docs.flatpak.org/en/latest/single-file-bundles.html

EverydayDiesel:
Hello and thank you for the reply. 


// dev machine

--- Code: ---g++ -v
Using built-in specs.
COLLECT_GCC=/usr/bin/g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/12/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-12.1.1-20220507/obj-x86_64-redhat-linux/isl-install --enable-offload-targets=nvptx-none --without-cuda-driver --enable-offload-defaulted --enable-gnu-indirect-function --enable-cet --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.1.1 20220507 (Red Hat 12.1.1-1) (GCC)

--- End code ---

// server

--- Code: ---g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.4.0-1ubuntu1~20.04.1' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-Av3uEd/gcc-9-9.4.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)

--- End code ---


1.  Im not crazy about writing the code in virtual box but I see where I may have to.

2.  This is exactly what I was hoping to do but with code blocks settings.  Instead of linking to these needed libraries, i could somehow embed them in the executable.  Like all the libaries on the dev box would be embedded inside the executable so when i move that 1 file to the server, everything would work

3.  I just tested flatpak and that is not installed.  I dont have sudo so that is not an option for me.

sodev:
Your build environment is newer than your runtime environment, this will never work. If it would be reversed, there are chances it would work, but since your application uses C++, there is a chance of an ABI break between these 3 major version jumps.

There is the possibility to link glibc and libstdc++ statically with the -static option, but this is highly discouraged and your planned use case is one of the major reasons why it is. You can try a statically linked version of your application, if you are lucky, it crashes right away on start. If you are unlucky, you get totally weird defects during runtime.

TL;DR: No, you won't be able to build a working binary on your dev system for the target system. Depending on the complexity of your application (what build system, can you build it with a standard cli build system) and its external dependencies (what libraries and other tools are required), either build it directly on the target system or setup a matching build environment on your dev system (vm, container, cross-compiling).

Navigation

[0] Message Index

[#] Next page

Go to full version