Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vendor/github.com/gen2brain/go-fitz/fitz.go:9:10: fatal error: 'mupdf/fitz.h' file not found #48

Closed
thynquest opened this issue May 6, 2022 · 3 comments

Comments

@thynquest
Copy link

Hello there

May be this case was already treated but I can't find a way around this. I am trying to compile a basic example using this library but nothing seems to work. this is the command I use

go build -tags "extlib" -o bin/sample main.go.

Of course I installed mupdf first using homebrew (I am on macos) but the build does not work. I also tried to add env variable such as LIBRARY_PATH or LDFLAGS but with no result. the basic example I am trying to compile is the one on the project page. Based on what I have understood the could be a way to build just by using the bundled library..
any leads that can point me to the right direction ?
thanks for the help.

@gen2brain
Copy link
Owner

Seems you are trying to use both vendor and extlib? Remove vendor, it will not copy all necessary files. If you want to pass additional LDFLAGS/CFLAGS that is done by using CGO_CFLAGS and CGO_LDFLAGS. You can search issues to see how it is done in Dockefile if you want to use an external library.

@gen2brain
Copy link
Owner

Btw. you can use an external library, that is why there is a tag for that, not sure how you understood that the bundled library is the only way.

$ go mod init example
$ go mod tidy
$ go build -tags extlib
$ ldd ./example 
	linux-vdso.so.1 (0x00007ffd181c8000)
	libmupdf.so.1.19.0 => /usr/lib64/libmupdf.so.1.19.0 (0x00007f65b7835000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f65b7760000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f65b7563000)
	libfreetype.so.6 => /usr/lib64/libfreetype.so.6 (0x00007f65b749b000)
	libgumbo.so.1 => /usr/lib64/libgumbo.so.1 (0x00007f65b743c000)
	libharfbuzz.so.0 => /usr/lib64/libharfbuzz.so.0 (0x00007f65b7343000)
	libjpeg.so.62 => /usr/lib64/libjpeg.so.62 (0x00007f65b72af000)
	libz.so.1 => /lib64/libz.so.1 (0x00007f65b7295000)
	libjbig2dec.so.0 => /usr/lib64/libjbig2dec.so.0 (0x00007f65b7275000)
	libopenjp2.so.7 => /usr/lib64/libopenjp2.so.7 (0x00007f65b7216000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f65ba692000)
	libbz2.so.1 => /lib64/libbz2.so.1 (0x00007f65b7203000)
	libpng16.so.16 => /usr/lib64/libpng16.so.16 (0x00007f65b71cc000)
	libgraphite2.so.3 => /usr/lib64/libgraphite2.so.3 (0x00007f65b71a4000)
	libglib-2.0.so.0 => /usr/lib64/libglib-2.0.so.0 (0x00007f65b706d000)
	libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f65b6ff6000)

Did you install static only library? In that case also add static tag, i.e. tags 'extlib static'.

@gen2brain
Copy link
Owner

Right, so brew installs only static libraries, this is from Catalina VM but probably the same on your OS.

% brew ls --verbose mupdf | grep lib
/usr/local/Cellar/mupdf/1.19.1/lib/libmupdf.a
/usr/local/Cellar/mupdf/1.19.1/lib/libmupdf-third.a

% ls -1
example.go
go.mod
go.sum
test.pdf

% go build -o example-embed

% go build -tags 'extlib static' -o example

% otool -L example-embed 
example-embed:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)

% otool -L example
example:
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)

% ./example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants