speedata / publisher

speedata Publisher - a professional database Publishing system
https://www.speedata.de/
GNU Affero General Public License v3.0
292 stars 36 forks source link

Issues compiling 4.17.16 on FreeBSD 14: `fatal error: 'lauxlib.h' file not found` #567

Closed Cicorione closed 3 months ago

Cicorione commented 3 months ago

Hi @pgundlach

I tried to fix this by miself but I couldn't and I am very sorry... 🙏

I am having some issue to compile Publisher on FreeBSD 14.0-RELEASE-p5 that it didn't happens with earlier versions.

The first issue I was able to solve changing the go symlink from go -> go120 to go -> go121 the second issue is regarding a missing lauxlib.hfile:

SDPRO=yes CFLAGS='-I /usr/local/include' LDFLAGS='-L /usr/local/lib' rake buildlib --trace
** Invoke buildlib (first_time)
** Invoke sphelper (first_time)
** Execute sphelper
go install -ldflags "-X main.basedir=/usr/home/freezr/Git/publisher -s"  speedatapublisher/sphelper/sphelper
** Execute buildlib
/usr/home/freezr/Git/publisher/bin/sphelper buildlib
Building dynamic library for freebsd
# speedatapublisher/splib
./splib.go:4:10: fatal error: 'lauxlib.h' file not found
#include <lauxlib.h>
         ^~~~~~~~~~~
1 error generated.

exit status 1
rake aborted!
Command failed with status (255): [/usr/home/freezr/Git/publisher/bin/sphelper buildlib]
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/file_utils.rb:65:in `block in create_shell_runner'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/file_utils.rb:57:in `sh'
/usr/home/freezr/Git/publisher/Rakefile:42:in `block in <top (required)>'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/task.rb:281:in `block in execute'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/task.rb:281:in `each'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/task.rb:281:in `execute'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/task.rb:199:in `synchronize'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/task.rb:199:in `invoke_with_call_chain'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/task.rb:188:in `invoke'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/application.rb:182:in `invoke_task'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/application.rb:138:in `block (2 levels) in top_level'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/application.rb:138:in `each'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/application.rb:138:in `block in top_level'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/application.rb:147:in `run_with_threads'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/application.rb:132:in `top_level'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/application.rb:83:in `block in run'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/application.rb:208:in `standard_exception_handling'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/application.rb:80:in `run'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/exe/rake:27:in `<top (required)>'
/usr/local/bin/rake:25:in `load'
/usr/local/bin/rake:25:in `<main>'
Tasks: TOP => buildlib

However the file is available in many directories:

plocate lauxlib.h
/usr/local/include/lua53/lauxlib.h
/usr/local/include/lua54/lauxlib.h
/usr/local/include/luajit-2.1/lauxlib.h
/usr/local/include/texlua53/lauxlib.h
/usr/local/include/texluajit/lauxlib.h
/usr/src/contrib/lua/src/lauxlib.h
/usr/src/sys/contrib/openzfs/include/sys/lua/lauxlib.h

The original discussion on the FreeBSD forum: https://forums.freebsd.org/threads/speedata-non-interactive-desktop-publishing.88228/

Please let me know if you need further information by my side! 🙏

pgundlach commented 3 months ago

I am a bit in a hurry, but you can try out changing buildlib.go and add something like this around line 50.

    case "freebsd":
    cmd.Env = append(cmd.Env, "CGO_CFLAGS=-I/usr/local/include/lua5.3")

(untested)

Cicorione commented 3 months ago

Yes it worked! 🎇

sp --version
Version: 4.17.16

I appended it at line 42:

switch goos {
case "freebsd":
    cmd.Env = append(cmd.Env, "CGO_CFLAGS=-I/usr/local/include/lua5.3")
case "darwin":
    cmd.Env = append(cmd.Env, "CGO_CFLAGS: -I/opt/homebrew/opt/lua@5.3/include/lua")
    cmd.Env = append(cmd.Env, "CGO_LDFLAGS=-undefined dynamic_lookup")
case "linux":
    cmd.Env = append(cmd.Env, "CGO_CFLAGS=-I/usr/include/lua5.3")
case "windows":
    cmd.Env = append(cmd.Env, "CGO_CFLAGS=-I/usr/include/lua5.3")
    cmd.Env = append(cmd.Env, "CGO_LDFLAGS=-llua53w64 -L/luatex-bin/luatex/windows/amd64/default/")
    }

Thank you very much! 🙏

pgundlach commented 3 months ago

The next version will allow to set the CGO_CFLAGS and CGO_LDFLAGS on the command line to override these settings. I still need to document that.

Cicorione commented 3 months ago

Cool! I should take courage and becoming a maintainer for FreeBSD... The native support for ZFS makes FreeBSD an invaluable assets for managing project made by software like Publisher that requires a reliable storage performance!

Cicorione commented 3 months ago

Hi @pgundlach I forgot to do a trick and as a matter of fact Publisher is complaining:

sp --jobname=agl06
Run speedata publisher 4.17.16
Can't find sdluatex binary

The trick was to create a symbolic link: bin/sdluatex@ -> /usr/local/bin/luatex

Then I tried to recompile again Publisher but I get this other error now:

SDPRO=yes rake buildlib --trace
** Invoke buildlib (first_time)
** Invoke sphelper (first_time)
** Execute sphelper
go install -ldflags "-X main.basedir=/usr/home/cicorione/Git/publisher -s"  speedatapublisher/sphelper/sphelper
** Execute buildlib
/usr/home/cicorione/Git/publisher/bin/sphelper buildlib
Building dynamic library for freebsd
# speedatapublisher/splib
./splib.go:4:10: fatal error: 'lauxlib.h' file not found
#include <lauxlib.h>
         ^~~~~~~~~~~
1 error generated.

exit status 1
rake aborted!
Command failed with status (255): [/usr/home/cicorione/Git/publisher/bin/sphelper buildlib]
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/file_utils.rb:65:in `block in create_shell_runner'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/file_utils.rb:57:in `sh'
/usr/home/cicorione/Git/publisher/Rakefile:42:in `block in <top (required)>'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/task.rb:281:in `block in execute'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/task.rb:281:in `each'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/task.rb:281:in `execute'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/task.rb:199:in `synchronize'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/task.rb:199:in `invoke_with_call_chain'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/task.rb:188:in `invoke'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/application.rb:182:in `invoke_task'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/application.rb:138:in `block (2 levels) in top_level'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/application.rb:138:in `each'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/application.rb:138:in `block in top_level'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/application.rb:147:in `run_with_threads'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/application.rb:132:in `top_level'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/application.rb:83:in `block in run'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/application.rb:208:in `standard_exception_handling'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/lib/rake/application.rb:80:in `run'
/usr/local/lib/ruby/gems/3.1/gems/rake-13.1.0/exe/rake:27:in `<top (required)>'
/usr/local/bin/rake:25:in `load'
/usr/local/bin/rake:25:in `<main>'
Tasks: TOP => buildlib

At this point I tried to reuse the same suggestion you gave me, applied to the file splib.go and I modified its header section this way:

package main

/*
#include <lauxlib.h>
#include <lua.h>
#include <lualib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#cgo CFLAGS: -I/opt/homebrew/opt/lua@5.3/include/lua
#cgo CFLAGS: -I/usr/local/include/lua5.3 ## my attempt  ^^;
*/
import "C"
[...]

Useless to say that it did not work out... 😭 Any recommendations? Thanks 🙏

pgundlach commented 3 months ago

Hi @pgundlach I forgot to do a trick and as a matter of fact Publisher is complaining:

sp --jobname=agl06
Run speedata publisher 4.17.16
Can't find sdluatex binary

The trick was to create a symbolic link: bin/sdluatex@ -> /usr/local/bin/luatex

I have uploaded a new version which should make this step unnecessary. The speedata publisher now looks into the PATH variable to find the sdluatex binary.

Then I tried to recompile again Publisher but I get this other error now:


SDPRO=yes rake buildlib --trace
** Invoke buildlib (first_time)
** Invoke sphelper (first_time)
** Execute sphelper
go install -ldflags "-X main.basedir=/usr/home/cicorione/Git/publisher -s"  speedatapublisher/sphelper/sphelper
** Execute buildlib
/usr/home/cicorione/Git/publisher/bin/sphelper buildlib
Building dynamic library for freebsd
# speedatapublisher/splib
./splib.go:4:10: fatal error: 'lauxlib.h' file not found

isn't this exactly the same as above?

If the current version (4.17.17) does not compile out of the box, set

export CGO_CFLAGS="-I/usr/local/include/lua53"

and try to run rake buildlib.

If this still does not work, please complain!

Cicorione commented 3 months ago

Updates...

isn't this exactly the same as above?

Yep, but with another file.

If this still does not work, please complain!

It did work with export CGO_CFLAGS="-I/usr/local/include/lua53"

Thank you very much!!! 🙏🙏🙏

pgundlach commented 3 months ago

I think this can be closed?

Cicorione commented 3 months ago

I agreed!

Cicorione commented 3 months ago

One last comment, I am running Publisher locally with a symbolic link to ~/.local/bin/ although to use it I have to create this symbolic link ln -s /usr/local/bin/luatex bin/sdluatex inside the Git cloned repo.

Long-story-short, there is not any file called sdluatex in FreeBSD... :shrug:

pgundlach commented 3 months ago

The sdluatex executable is a luahbtex executable found in a tex distribution (which is a LuaTeX binary with harfbuzz activated). So if you have luahbtex somewhere, you should be able to copy / symlink to some directory in the PATH with the name sdluatex. I should provide a LuaTeX binary for more operating systems at https://download.speedata.de/#extra (which is currently only for Windows intel /Linux intel and macOS intel/arm).