SciresM / hactool

hactool is a tool to view information about, decrypt, and extract common file formats for the Nintendo Switch, especially Nintendo Content Archives.
ISC License
982 stars 151 forks source link

Building on Alpine Linux failed #87

Closed nephaste closed 4 years ago

nephaste commented 4 years ago

alp Hi

need your help

I am trying to get a static build command using an Alpine OS, but always failed in error

omfs.o nca0_romfs.c nca0_romfs.c: In function 'nca0_romfs_print': nca0_romfs.c:140:41: warning: unused parameter 'ctx' [-Wunused-parameter] 140 | void nca0_romfs_print(nca0_romfs_ctx_t *ctx) { | ~~~~~~~~~~~~~~~~~~^~~ gcc -I ./mbedtls/include -c -O2 -Wall -Wextra -pedantic -std=gnu11 -fPIC -D_BSD_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE=200112L -D_DEFAULT_SOURCE -D__USE_MINGW_ANSI_STDIO=1 -D_FILE_OFFSET_BITS=64 -o romfs.o romfs.c gcc -I ./mbedtls/include -c -O2 -Wall -Wextra -pedantic -std=gnu11 -fPIC -D_BSD_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE=200112L -D_DEFAULT_SOURCE -D__USE_MINGW_ANSI_STDIO=1 -D_FILE_OFFSET_BITS=64 -o utils.o utils.c romfs.c: In function 'romfs_print': romfs.c:137:31: warning: unused parameter 'ctx' [-Wunused-parameter] 137 | void romfs_print(romfs_ctx_t *ctx) { | ~~~~~~~~~~~~~^~~ gcc -I ./mbedtls/include -c -O2 -Wall -Wextra -pedantic -std=gnu11 -fPIC -D_BSD_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE=200112L -D_DEFAULT_SOURCE -D__USE_MINGW_ANSI_STDIO=1 -D_FILE_OFFSET_BITS=64 -o nax0.o nax0.c gcc -I ./mbedtls/include -c -O2 -Wall -Wextra -pedantic -std=gnu11 -fPIC -D_BSD_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE=200112L -D_DEFAULT_SOURCE -D__USE_MINGW_ANSI_STDIO=1 -D_FILE_OFFSET_BITS=64 -o nso.o nso.c gcc -I ./mbedtls/include -c -O2 -Wall -Wextra -pedantic -std=gnu11 -fPIC -D_BSD_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE=200112L -D_DEFAULT_SOURCE -D__USE_MINGW_ANSI_STDIO=1 -D_FILE_OFFSET_BITS=64 -o lz4.o lz4.c gcc -I ./mbedtls/include -c -O2 -Wall -Wextra -pedantic -std=gnu11 -fPIC -D_BSD_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE=200112L -D_DEFAULT_SOURCE -D__USE_MINGW_ANSI_STDIO=1 -D_FILE_OFFSET_BITS=64 -o nca.o nca.c gcc -I ./mbedtls/include -c -O2 -Wall -Wextra -pedantic -std=gnu11 -fPIC -D_BSD_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE=200112L -D_DEFAULT_SOURCE -D__USE_MINGW_ANSI_STDIO=1 -D_FILE_OFFSET_BITS=64 -o xci.o xci.c gcc -I ./mbedtls/include -c -O2 -Wall -Wextra -pedantic -std=gnu11 -fPIC -D_BSD_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE=200112L -D_DEFAULT_SOURCE -D__USE_MINGW_ANSI_STDIO=1 -D_FILE_OFFSET_BITS=64 -o main.o main.c main.c: In function 'usage': main.c:112:9: warning: string length '5102' is greater than the length '4095' ISO C99 compilers are required to support [-Woverlength-strings] 112 | "\n", __TIME__, __DATE__, prog_name); | ^~~~ main.c: In function 'main': main.c:372:44: error: increment of pointer to an incomplete type 'FILE' {aka 'struct _IO_FILE'} 372 | nca_ctx.tool_ctx->base_file++; /* Guarantees base_file != NULL. I'm so sorry. */ | ^~ make[1]: *** [Makefile:14: main.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make[1]: Leaving directory '/WARP/hactool' make: *** [Makefile:11: all] Error 2 gcc --version gcc (Alpine 9.2.0) 9.2.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Command used :

git clone https://github.com/SciresM/hactool.git cd hactool mv config.mk.template config.mk export CPPFLAGS="--static -static" export CFLAGS="--static -static " export LDFLAGS="--static -static -Wl,--no-as-needed -ldl -lpthread -pthread" make -j$(nproc)

thanks for your help,

leo60228 commented 4 years ago

For reference, Alpine Linux uses musl.

leo60228 commented 4 years ago

This could probably be fixed by changing the line in question to

if (!nca_ctx.tool_ctx->base_file) nca_ctx.tool_ctx->base_file = (FILE*) 1;

I’m confused about why this is necessary in the first place, though...

nephaste commented 4 years ago

thanks it worked .. no more error

just added to have a full static version

make -j$(nproc) CC="gcc -static --static"

leo60228 commented 1 year ago

This should probably be reopened, since the patch was never included upstream and is being applied manually by Nixpkgs.