box64 icon indicating copy to clipboard operation
box64 copied to clipboard

build failed while build static box64 binary

Open fish4terrisa-MSDSM opened this issue 2 years ago • 17 comments

The output of ld: /bin/ld: CMakeFiles/box64.dir/src/box64context.c.o: in function NewBox64Context': /home/fish4terrisa/box64/src/box64context.c:177: 警告: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /bin/ld: CMakeFiles/box64.dir/src/elfs/elfloader.c.o: in function _dl_tlsdesc_undefweak': /home/fish4terrisa/box64/src/elfs/elfloader.c:569: multiple definition of _dl_tlsdesc_undefweak'; /usr/lib/gcc/aarch64-linux-gnu/11/../../../aarch64-linux-gnu/libc.a(dl-tlsdesc.o):(.text+0xc): first defined here /bin/ld: /usr/lib/gcc/aarch64-linux-gnu/11/../../../aarch64-linux-gnu/libc.a(getopt.o):(.data+0x8): multiple definition of optopt'; CMakeFiles/box64.dir/src/librarian/globalsymbols.c.o:/usr/include/aarch64-linux-gnu/bits/getopt_core.h:59: first defined here /bin/ld: /usr/lib/gcc/aarch64-linux-gnu/11/../../../aarch64-linux-gnu/libc.a(getopt.o):(.data+0x4): multiple definition of opterr'; CMakeFiles/box64.dir/src/librarian/globalsymbols.c.o:/usr/include/aarch64-linux-gnu/bits/getopt_core.h:55: first defined here /bin/ld: /usr/lib/gcc/aarch64-linux-gnu/11/../../../aarch64-linux-gnu/libc.a(getopt.o):(.data+0x0): multiple definition of optind'; CMakeFiles/box64.dir/src/librarian/globalsymbols.c.o:/usr/include/aarch64-linux-gnu/bits/getopt_core.h:50: first defined here /bin/ld: /usr/lib/gcc/aarch64-linux-gnu/11/../../../aarch64-linux-gnu/libc.a(getopt.o):(.bss+0x38): multiple definition of optarg'; CMakeFiles/box64.dir/src/librarian/globalsymbols.c.o:/usr/include/aarch64-linux-gnu/bits/getopt_core.h:36: first defined here /bin/ld: CMakeFiles/box64.dir/src/emu/x64run0f.c.o: in function Run0F': /home/fish4terrisa/box64/src/emu/x64run0f.c:363: undefined reference to sqrtf' /home/fish4terrisa/box64/src/emu/x64run0f.c:363:(.text+0x1664): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol sqrtf' /bin/ld: /home/fish4terrisa/box64/src/emu/x64run0f.c:379: undefined reference to sqrtf' /home/fish4terrisa/box64/src/emu/x64run0f.c:379:(.text+0x4640): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol sqrtf' /bin/ld: CMakeFiles/box64.dir/src/emu/x64run660f.c.o: in function Run660F': /home/fish4terrisa/box64/src/emu/x64run660f.c:853: undefined reference to sqrt' /home/fish4terrisa/box64/src/emu/x64run660f.c:853:(.text+0x648): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol sqrt' /bin/ld: /home/fish4terrisa/box64/src/emu/x64run660f.c:853: undefined reference to sqrt' /home/fish4terrisa/box64/src/emu/x64run660f.c:853:(.text+0x668): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol sqrt' /bin/ld: CMakeFiles/box64.dir/src/emu/x64rund9.c.o: in function RunD9': /home/fish4terrisa/box64/src/emu/x64rund9.c:203: undefined reference to cos' /home/fish4terrisa/box64/src/emu/x64rund9.c:203:(.text+0x1a0): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol cos' /bin/ld: /home/fish4terrisa/box64/src/emu/x64rund9.c:199: undefined reference to sin' /home/fish4terrisa/box64/src/emu/x64rund9.c:199:(.text+0x1d0): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol sin' /bin/ld: /home/fish4terrisa/box64/src/emu/x64rund9.c:187: undefined reference to sincos' /home/fish4terrisa/box64/src/emu/x64rund9.c:187:(.text+0x298): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol sincos' /bin/ld: /home/fish4terrisa/box64/src/emu/x64rund9.c:183: undefined reference to sqrt' /home/fish4terrisa/box64/src/emu/x64rund9.c:183:(.text+0x2d8): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol sqrt' /bin/ld: /home/fish4terrisa/box64/src/emu/x64rund9.c:179: undefined reference to log2' /home/fish4terrisa/box64/src/emu/x64rund9.c:179:(.text+0x2fc): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol log2' /bin/ld: /home/fish4terrisa/box64/src/emu/x64rund9.c:120: undefined reference to atan2' /home/fish4terrisa/box64/src/emu/x64rund9.c:120:(.text+0x524): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol atan2' /bin/ld: /home/fish4terrisa/box64/src/emu/x64rund9.c:114: undefined reference to tan' /home/fish4terrisa/box64/src/emu/x64rund9.c:114:(.text+0x570): 从输出所省略的额外重寻址溢出 /bin/ld: /home/fish4terrisa/box64/src/emu/x64rund9.c:107: undefined reference to exp2' /bin/ld: /home/fish4terrisa/box64/src/emu/x64rund9.c:167: undefined reference to exp2' /bin/ld: /home/fish4terrisa/box64/src/emu/x64rund9.c:168: undefined reference to exp2' /bin/ld: /home/fish4terrisa/box64/src/emu/x64rund9.c:196: undefined reference to exp2' /bin/ld: CMakeFiles/box64.dir/src/emu/x64runf20f.c.o: in function RunF20F': /home/fish4terrisa/box64/src/emu/x64runf20f.c:133: undefined reference to sqrt' /bin/ld: CMakeFiles/box64.dir/src/emu/x64runf30f.c.o: in function RunF30F': /home/fish4terrisa/box64/src/emu/x64runf30f.c:142: undefined reference to sqrtf' /bin/ld: /home/fish4terrisa/box64/src/emu/x64runf30f.c:136: undefined reference to sqrtf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___powf_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:49: undefined reference to powf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___pow_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:50: undefined reference to pow' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___sinhf_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:51: undefined reference to sinhf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___sinh_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:52: undefined reference to sinh' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___sqrtf_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:53: undefined reference to sqrtf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___sqrt_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:54: undefined reference to sqrt' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___acosf_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:55: undefined reference to acosf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___acos_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:56: undefined reference to acos' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___acoshf_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:57: undefined reference to acoshf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___acosh_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:58: undefined reference to acosh' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___asinf_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:59: undefined reference to asinf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___asin_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:60: undefined reference to asin' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___atan2f_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:61: undefined reference to atan2f' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___atan2_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:62: undefined reference to atan2' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___coshf_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:63: undefined reference to coshf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___cosh_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:64: undefined reference to cosh' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___exp2f_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:65: undefined reference to exp2f' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___exp2_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:66: undefined reference to exp2' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___expf_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:67: undefined reference to expf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___exp_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:68: undefined reference to exp' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___hypotf_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:69: undefined reference to hypotf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___hypot_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:70: undefined reference to hypot' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___log10f_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:71: undefined reference to log10f' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___log10_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:72: undefined reference to log10' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___log2f_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:73: undefined reference to log2f' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___log2_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:74: undefined reference to log2' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___logf_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:75: undefined reference to logf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___log_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:76: undefined reference to log' /bin/ld: libdynarec.a(dynarec_arm64_functions.c.o): in function arm_f2xm1': /home/fish4terrisa/box64/src/dynarec/arm64/dynarec_arm64_functions.c:47: undefined reference to exp2' /bin/ld: libdynarec.a(dynarec_arm64_functions.c.o): in function arm_fyl2x': /home/fish4terrisa/box64/src/dynarec/arm64/dynarec_arm64_functions.c:51: undefined reference to log2' /bin/ld: libdynarec.a(dynarec_arm64_functions.c.o): in function arm_ftan': /home/fish4terrisa/box64/src/dynarec/arm64/dynarec_arm64_functions.c:55: undefined reference to tan' /bin/ld: libdynarec.a(dynarec_arm64_functions.c.o): in function arm_fpatan': /home/fish4terrisa/box64/src/dynarec/arm64/dynarec_arm64_functions.c:60: undefined reference to atan2' /bin/ld: libdynarec.a(dynarec_arm64_functions.c.o): in function arm_fxtract': /home/fish4terrisa/box64/src/dynarec/arm64/dynarec_arm64_functions.c:66: undefined reference to exp2' /bin/ld: libdynarec.a(dynarec_arm64_functions.c.o): in function arm_fyl2xp1': /home/fish4terrisa/box64/src/dynarec/arm64/dynarec_arm64_functions.c:80: undefined reference to log2' /bin/ld: libdynarec.a(dynarec_arm64_functions.c.o): in function arm_fsincos': /home/fish4terrisa/box64/src/dynarec/arm64/dynarec_arm64_functions.c:84: undefined reference to sincos' /bin/ld: libdynarec.a(dynarec_arm64_functions.c.o): in function arm_fscale': /home/fish4terrisa/box64/src/dynarec/arm64/dynarec_arm64_functions.c:94: undefined reference to exp2' /bin/ld: libdynarec.a(dynarec_arm64_functions.c.o): in function arm_fsin': /home/fish4terrisa/box64/src/dynarec/arm64/dynarec_arm64_functions.c:98: undefined reference to sin' /bin/ld: libdynarec.a(dynarec_arm64_functions.c.o): in function arm_fcos': /home/fish4terrisa/box64/src/dynarec/arm64/dynarec_arm64_functions.c:103: undefined reference to cos' collect2: error: ld returned 1 exit status make[2]: *** [CMakeFiles/box64.dir/build.make:3839:box64] 错误 1 make[1]: *** [CMakeFiles/Makefile2:284:CMakeFiles/box64.dir/all] 错误 2 make: *** [Makefile:166:all] 错误 2@

fish4terrisa-MSDSM avatar May 22 '22 03:05 fish4terrisa-MSDSM

What did you do to have a static build?

ptitSeb avatar May 22 '22 06:05 ptitSeb

To port box64 to termux. :-) static binaries works well on termux

fish4terrisa-MSDSM avatar May 22 '22 06:05 fish4terrisa-MSDSM

Not asking why, but how, so I can reproduce on my side.

ptitSeb avatar May 22 '22 07:05 ptitSeb

l just add these lines after the first line of CMakeLists.txt: set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") set(BUILD_SHARED_LIBS OFF) set(CMAKE_EXE_LINKER_FLAGS "-static") so the first lines of it is

cmake_minimum_required(VERSION 3.4) set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") set(BUILD_SHARED_LIBS OFF) set(CMAKE_EXE_LINKER_FLAGS "-static")

fish4terrisa-MSDSM avatar May 22 '22 07:05 fish4terrisa-MSDSM

(there are few lines ,but github just showed it as one line)

fish4terrisa-MSDSM avatar May 22 '22 07:05 fish4terrisa-MSDSM

Ok, I'll try to get a solution for static build.

ptitSeb avatar May 22 '22 07:05 ptitSeb

Thank you.

fish4terrisa-MSDSM avatar May 22 '22 09:05 fish4terrisa-MSDSM

I'd also like a static build of this (use as a drop-in replacement for QEMU inside a Docker container but I know you didn't ask).

I kept running across issue #146 when googling if anyone had a static build of this just publicly available. I almost commented on that very old issue before I saw this one from much more recently.

I have had multiple people say box64 is much faster than QEMU for running the Minecraft Bedrock server (only available in x86_64) in comments / issues on some of my projects that run on aarch64. It makes it go from pretty laggy on Raspberry Pi to almost perfect.

At any rate consider this seconded for purposes of embedded devices / multiarch / other useful scenarios that if you spend the time on this will be utilized by downstream projects. Thanks!

TheRemote avatar May 24 '22 05:05 TheRemote

@ptitSeb Any progress on this? The main use case would be a drop-in replacment for qemu-user-static as @TheRemote already mentioned.

Ristovski avatar Feb 25 '24 00:02 Ristovski

I did nome testing not too long ago about this but without getting good result. I need to use a more drastic approach on this to succeed. Not sure when I'll work on this tho, it's quite a heavy change I have in mind.

ptitSeb avatar Feb 25 '24 08:02 ptitSeb

@ptitSeb Any progress on this? The main use case would be a drop-in replacment for qemu-user-static as @TheRemote already mentioned.

And, if it can replace qemu-user-static , it would also be possible to combine box64 with proot.

fish4terrisa-MSDSM avatar Feb 26 '24 00:02 fish4terrisa-MSDSM

@ptitSeb Any progress on this? The main use case would be a drop-in replacment for qemu-user-static as @TheRemote already mentioned.

And, if it can replace qemu-user-static , it would also be possible to combine box64 with proot.

Well yeah, but to do what? the static build of box64 will have (very) limited wrapped functionnality. So no wrapped opengl, vulkan or pulse audio. Basicaly, it can be use for headless server stuffs, but not for gaming.

ptitSeb avatar Feb 26 '24 14:02 ptitSeb

Finaly got a static build of box64. I have just tested the integrated test and they works. Running bash doesn't work because I'm not on a x86_64 chroot. There are some limitation of the static build: mainly: no lib wrapping. It might still work for headless usecases.

ptitSeb avatar Feb 26 '24 18:02 ptitSeb

Finaly got a static build of box64. I have just tested the integrated test and they works. Running bash doesn't work because I'm not on a x86_64 chroot. There are some limitation of the static build: mainly: no lib wrapping. It might still work for headless usecases.

In file included from /home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlibbsd.c:42:
/home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlibbsd_private.h:5:4: error: ‘arc4random’ undeclared here (not in a function); did you mean ‘srandom’?
 GO(arc4random, uFv)
    ^~~~~~~~~~
/home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlib_init.h:48:30: note: in definition of macro ‘GO’
 #define GO(N, W) {#N, W, 0, &N},
                              ^
/home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlibbsd_private.h:7:4: error: ‘arc4random_buf’ undeclared here (not in a function); did you mean ‘arc4random_stir’?
 GO(arc4random_buf, vFpL)
    ^~~~~~~~~~~~~~
/home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlib_init.h:48:30: note: in definition of macro ‘GO’
 #define GO(N, W) {#N, W, 0, &N},
                              ^
/home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlibbsd_private.h:9:4: error: ‘arc4random_uniform’ undeclared here (not in a function); did you mean ‘arc4random_stir’?
 GO(arc4random_uniform, uFu)
    ^~~~~~~~~~~~~~~~~~
/home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlib_init.h:48:30: note: in definition of macro ‘GO’
 #define GO(N, W) {#N, W, 0, &N},
                              ^
make[2]: *** [CMakeFiles/box64.di

Failed to build on gcc8 with -D STATICBUILD=1

Should i use a newer compiler?

shenmo7192 avatar Apr 01 '24 11:04 shenmo7192

No, that's libbsd symbols here. tbh, I'm not sure on what I should do with them. I want to exclude them, but recent gcc/glibc (?) seems to consider they are default and later libstdc++ use them.

ptitSeb avatar Apr 01 '24 12:04 ptitSeb

No, that's libbsd symbols here. tbh, I'm not sure on what I should do with them. I want to exclude them, but recent gcc/glibc (?) seems to consider they are default and later libstdc++ use them.

Roger

shenmo7192 avatar Apr 02 '24 02:04 shenmo7192