Hey, everyone.
I've been using FreeBSD daily for a few years now. Probably the
most annoying problem I encounter regularly is the inability to
easily build programs developed under Linux. One understands and
swallows those bitter pills in case of big programs, but when
building even small utilities begins to cause issues, the whole
endeavour becomes disheartening.
Please observe this little case study:
This tiny example is an invitation to grander discussion:
What should we do when we encounter projects that don't build
cleanly on FreeBSD?
If I'm not aware of the specifics of different configure scripts
or build systems or cross-platform differences, can I still
suggest something to a project's developer that could help
resolve the issue?
Specifically:
I've been using FreeBSD daily for a few years now. Probably the
most annoying problem I encounter regularly is the inability to
easily build programs developed under Linux. One understands and
swallows those bitter pills in case of big programs, but when
building even small utilities begins to cause issues, the whole
endeavour becomes disheartening.
Please observe this little case study:
- Program: clp, a Lua cat with syntax highlighting
- Source: https://git.sr.ht/~eskin/clp
- Dependencies:
- a POSIX compliant operating system,
- a C99 Compiler,
- Lua >= 5.1 or LuaJIT,
- LPEG,
- luautf8
$ pkg install lua54 luajit-devel lua54-lpeg lua54-luarocks && luarocks54 install luautf8
- Problems (sequentially):
- The CURDIR variable used in the source Makefile is not respected by FreeBSD make.
CFLAGS += -I $(CURDIR)/include
CFLAGS += -I ${.CURDIR}/include - The headers directory needs to be added to the search path and it has to be explicit (-I/usr/local/include won't do). Including a versioned subdirectory cannot be the correct solution.
CFLAGS += -I $(CURDIR)/include -I/usr/local/include
CFLAGS += -I ${.CURDIR}/include -I/usr/local/include/lua54 - Linker errors for Lua C API (I think) finish off what remains of my good spirit.
(I tried adding -L/usr/local/lib to FLAGS but I was unsuccessful).
cc cli.c -pipe -Wall -O2 -ffunction-sections -fdata-sections -Wall -pedantic -I /usr/home/artur/build/clp/include -I/usr/local/include/lua54 -DCLP_PATH=\"/usr/local/share/clp\" -DSRC_LUA_PATH=\"/usr/home/artur/build/clp/lua\" clp.o -o clp
ld: error: undefined symbol: lua_tolstring
>>> referenced by clp.c
>>> clp.obail)
>>> referenced by clp.c
>>> clp.oprint_lua_path)
>>> referenced by clp.c
>>> clp.olua_paths_get)
>>> referenced 3 more times
ld: error: undefined symbol: lua_getglobal
>>> referenced by clp.c
>>> clp.oprint_lua_path)
>>> referenced by clp.c
>>> clp.olua_path_add)
>>> referenced by clp.c
>>> clp.olua_paths_get)
>>> referenced 4 more times - I suspect there are more Makefile incompatibilities or include/linking errors beyond the point of my giving up.
For the record, here are headers and libraries:
$ find /usr/local/lib -type f -name '*lua*'
/usr/local/lib/lua/5.4/lua-utf8.so
/usr/local/lib/liblua-5.1.a
/usr/local/lib/liblua-5.3.so
/usr/local/lib/liblua-5.3.a
/usr/local/lib/luarocks/rocks-5.4/luautf8/0.1.5-2/luautf8-0.1.5-2.rockspec
/usr/local/lib/liblua-5.1.so
/usr/local/lib/liblua-5.4.so
/usr/local/lib/liblua-5.4.a
/usr/local/lib/libluajit-5.1.a
/usr/local/lib/libluajit-5.1.so.2.1.0
$ find /usr/local/include -type f -name '*lua*'
/usr/local/include/lua51/lua.h
/usr/local/include/lua51/lua.hpp
/usr/local/include/lua51/luaconf.h
/usr/local/include/lua51/lualib.h
/usr/local/include/lua53/lua.h
/usr/local/include/lua53/lua.hpp
/usr/local/include/lua53/luaconf.h
/usr/local/include/lua53/lualib.h
/usr/local/include/lua54/lua.h
/usr/local/include/lua54/lua.hpp
/usr/local/include/lua54/luaconf.h
/usr/local/include/lua54/lualib.h
/usr/local/include/luajit-2.1/lua.h
/usr/local/include/luajit-2.1/lua.hpp
/usr/local/include/luajit-2.1/luaconf.h
/usr/local/include/luajit-2.1/luajit.h
/usr/local/include/luajit-2.1/lualib.h
- The CURDIR variable used in the source Makefile is not respected by FreeBSD make.
This tiny example is an invitation to grander discussion:
What should we do when we encounter projects that don't build
cleanly on FreeBSD?
If I'm not aware of the specifics of different configure scripts
or build systems or cross-platform differences, can I still
suggest something to a project's developer that could help
resolve the issue?
Specifically:
- Are there time- and battle-tested solutions used by port
maintainers that can be applied with high likelihood of success? - What common steps can be taken to resolve dependencies between
Linux and FreeBSD, such as different include and lib link
directories or differences and extensions between GNU Make and
FreeBSD pmake?