liberize / ssc

Convert shell script to binary
GNU General Public License v3.0
61 stars 17 forks source link

Compile error when --static is used #33

Closed lightaffaire closed 1 week ago

lightaffaire commented 1 week ago

$ ssc --static --fix-argv0 /usr/local/bin/test.sh test-ssc.sh

/usr/bin/ld: cannot find -lstdc++: No such file or directory /usr/bin/ld: cannot find -lm: No such file or directory /usr/bin/ld: cannot find -lc: No such file or directory collect2: error: ld returned 1 exit status

Without the --static flag it compiles fine and works ok.

liberize commented 1 week ago

what os are you using?

liberize commented 1 week ago

and what compiler version?

lightaffaire commented 1 week ago

Sorry forgot to include sysinfo:

Linux Fedora 37

Linux server1 6.5.12-100.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Nov 20 22:28:44 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

cpp-12.3.1-1.fc37.x86_64

glibc-2.36-18.fc37.i686 glibc-2.36-18.fc37.x86_64 glibc-all-langpacks-2.36-18.fc37.x86_64 glibc-common-2.36-18.fc37.x86_64 glibc-devel-2.36-18.fc37.x86_64 glibc-doc-2.36-18.fc37.noarch glibc-gconv-extra-2.36-18.fc37.i686 glibc-gconv-extra-2.36-18.fc37.x86_64 glibc-headers-x86-2.36-18.fc37.noarch glibc-langpack-en-2.36-18.fc37.x86_64

liberize commented 1 week ago

Please run with -v and paste the output here.

lightaffaire commented 1 week ago

RUN: /usr/local/src/ssc-master/ssc --fix-argv0 --static -v /content/tmp/generate-shell-binary.d/db-inline /content/bin/shell-binary/db

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/12/include-fixed" ignoring nonexistent directory "/usr/lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include"

include "..." search starts here:

include <...> search starts here:

/usr/local/src/ssc-master/src /usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12 /usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/x86_64-redhat-linux /usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/backward /usr/lib/gcc/x86_64-redhat-linux/12/include /usr/local/include /usr/include End of search list. GNU C++14 (GCC) version 12.3.1 20230508 (Red Hat 12.3.1-1) (x86_64-redhat-linux) compiled by GNU C version 12.3.1 20230508 (Red Hat 12.3.1-1), GMP version 6.2.1, MPFR version 4.1.0-p13, MPC version 1.2.1, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 7da7486e00808c7add003c8881d4a657 COLLECT_GCC_OPTIONS='-I' '/usr/local/src/ssc-master/src' '-std=c++14' '-D' 'FIX_ARGV0' '-static' '-static-libgcc' '-v' '-fconstexpr-loop-limit=1073741824' '-fconstexpr-ops-limit=1073741824' '-o' '/content/bin/shell-binary/db' '-mtune=generic' '-march=x86-64' '-dumpdir' '/content/bin/shell-binary/db-' as -v -I /usr/local/src/ssc-master/src --64 -o /tmp/ccIziaKR.o /tmp/cc3e6LTl.s GNU assembler version 2.38 (x86_64-redhat-linux) using BFD version version 2.38-27.fc37 COMPILER_PATH=/usr/libexec/gcc/x86_64-redhat-linux/12/:/usr/libexec/gcc/x86_64-redhat-linux/12/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/12/:/usr/lib/gcc/x86_64-redhat-linux/ LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/12/:/usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/12/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-I' '/usr/local/src/ssc-master/src' '-std=c++14' '-D' 'FIX_ARGV0' '-static' '-static-libgcc' '-v' '-fconstexpr-loop-limit=1073741824' '-fconstexpr-ops-limit=1073741824' '-o' '/content/bin/shell-binary/db' '-mtune=generic' '-march=x86-64' '-dumpdir' '/content/bin/shell-binary/db.' /usr/libexec/gcc/x86_64-redhat-linux/12/collect2 -plugin /usr/libexec/gcc/x86_64-redhat-linux/12/liblto_plugin.so -plugin-opt=/usr/libexec/gcc/x86_64-redhat-linux/12/lto-wrapper -plugin-opt=-fresolution=/tmp/ccRCGwf5.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lc --build-id --no-add-needed --hash-style=gnu -m elf_x86_64 -static -o /content/bin/shell-binary/db /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crt1.o /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crti.o /usr/lib/gcc/x86_64-redhat-linux/12/crtbeginT.o -L/usr/lib/gcc/x86_64-redhat-linux/12 -L/usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/12/../../.. /tmp/ccIziaKR.o -lstdc++ -lm --start-group -lgcc -lgcc_eh -lc --end-group /usr/lib/gcc/x86_64-redhat-linux/12/crtend.o /usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64/crtn.o /usr/bin/ld: cannot find -lstdc++: No such file or directory /usr/bin/ld: cannot find -lm: No such file or directory /usr/bin/ld: cannot find -lc: No such file or directory collect2: error: ld returned 1 exit status

liberize commented 1 week ago
yum install glibc-static libstdc++-static
lightaffaire commented 1 week ago

Thank you. Installed the missing libs and --static worked.

Maybe add a list of expected libs to the README?

liberize commented 1 week ago

the package names are different on different systems, it's hard to list them here.

lightaffaire commented 1 week ago

maybe list them for 1. redhat/fedora and 2. debian/ubuntu ? anything listed will be a help to others and cut down on support issues which costs you time.

liberize commented 1 week ago

doc updated.