gen2brain / go-fitz

Golang wrapper for the MuPDF Fitz library
GNU Affero General Public License v3.0
429 stars 97 forks source link

centos alpine build faild #105

Closed BlackDogLi closed 6 months ago

BlackDogLi commented 7 months ago
gen2brain commented 6 months ago

So what is it, Centos or Alpine? What is the compiler in /home/opt/compiler, is it a musl gcc? It looks like you are trying to compile for musl using plain gcc. You have examples in issues of how to build for Alpine and Musl.

gen2brain commented 6 months ago

Right, so I just tested, you must use musl gcc if you want to build for musl, i.e:

go build -tags musl
# example
/usr/lib/go/pkg/tool/linux_amd64/link: running x86_64-pc-linux-gnu-gcc failed: exit status 1
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /home/milann/.cache/go/mod/github.com/gen2brain/go-fitz@v1.23.7/libs/libmupdf_linux_amd64_musl.a(buffer.o): in function `fz_new_buffer':
buffer.c:(.text.fz_new_buffer+0x47): undefined reference to `sigsetjmp'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /home/milann/.cache/go/mod/github.com/gen2brain/go-fitz@v1.23.7/libs/libmupdf_linux_amd64_musl.a(buffer.o): in function `fz_new_buffer_from_data':
buffer.c:(.text.fz_new_buffer_from_data+0x27): undefined reference to `sigsetjmp'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /home/milann/.cache/go/mod/github.com/gen2brain/go-fitz@v1.23.7/libs/libmupdf_linux_amd64_musl.a(buffer.o): in function `fz_new_buffer_from_base64':
buffer.c:(.text.fz_new_buffer_from_base64+0xeb): undefined reference to `sigsetjmp'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /home/milann/.cache/go/mod/github.com/gen2brain/go-fitz@v1.23.7/libs/libmupdf_linux_amd64_musl.a(colorspace.o): in function `fz_cached_color_convert':
colorspace.c:(.text.fz_cached_color_convert+0x9f): undefined reference to `sigsetjmp'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /home/milann/.cache/go/mod/github.com/gen2brain/go-fitz@v1.23.7/libs/libmupdf_linux_amd64_musl.a(colorspace.o): in function `fz_new_colorspace':
colorspace.c:(.text.fz_new_colorspace+0x6f): undefined reference to `sigsetjmp'
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: /home/milann/.cache/go/mod/github.com/gen2brain/go-fitz@v1.23.7/libs/libmupdf_linux_amd64_musl.a(colorspace.o):colorspace.c:(.text.fz_new_icc_colorspace+0x76): more undefined references to `sigsetjmp' follow
collect2: error: ld returned 1 exit status
CC=x86_64-pc-linux-musl-gcc go build -tags musl
file example
example: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-x86_64.so.1, Go BuildID=uBMxLYbblufj-uelQYGh/9CWUatp-5ceiXax-Q6BM/kfblecrTQjl1tydrm8--/6BbPjkjOoNv3cPP-LWK1, with debug_info, not stripped
BlackDogLi commented 6 months ago

So what is it, Centos or Alpine? What is the compiler in /home/opt/compiler, is it a musl gcc? It looks like you are trying to compile for musl using plain gcc. You have examples in issues of how to build for Alpine and Musl.

centos

BlackDogLi commented 6 months ago

could i use musl gcc for centos image. like RUN yum install -y gcc musl-dev ?

gen2brain commented 6 months ago

Sorry, no idea, try it.