Discussion:
Failing to build Lua 5.3.5 on Macbook
Daryl Lee
2018-11-22 00:41:57 UTC
Permalink
Greetings!

I have both an iMac and a Macbook pro laptop, both running Mojave (OS X
10.14.1), both with XCode 10.1, both with command line tools (gcc
--version reports Apple LLVM version 10.0.0 (clang-1000.11.45.5)). Lua
5.3.5 builds and runs nicely on the iMac, but fails on the Macbook, with
several linker errors, beginning with:

gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_2 -DLUA_USE_MACOSX -c
-o lua.o lua.c
gcc -std=gnu99 -o lua lua.o liblua.a -lm -lreadline
Undefined symbols for architecture x86_64:
"_tgetent", referenced from:
__rl_init_terminal_io in libreadline.a(terminal.o)
"_tgetflag", referenced from:
__rl_init_terminal_io in libreadline.a(terminal.o)
"_tgetnum", referenced from:
__rl_get_screen_size in libreadline.a(terminal.o)
...

Any suggestions would be appreciated.
--
Daryl Lee
All our discontents about what we want appeared to
me to spring from the want of thankfulness for what we
have. -- Daniel Defoe
Daryl Lee
2018-11-22 00:52:35 UTC
Permalink
Well, I think I have at least corraled the problem. This laptop seems
to have an old version (2008-ish) of Lua already, that I'd forgotten
about. I guess I need to start by cleaning that out. Sorry for the
interruption.
Post by Daryl Lee
Greetings!
I have both an iMac and a Macbook pro laptop, both running Mojave (OS X
10.14.1), both with XCode 10.1, both with command line tools (gcc
--version reports Apple LLVM version 10.0.0 (clang-1000.11.45.5)).  Lua
5.3.5 builds and runs nicely on the iMac, but fails on the Macbook, with
gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_2 -DLUA_USE_MACOSX    -c
-o lua.o lua.c
gcc -std=gnu99 -o lua   lua.o liblua.a -lm -lreadline
      __rl_init_terminal_io in libreadline.a(terminal.o)
      __rl_init_terminal_io in libreadline.a(terminal.o)
      __rl_get_screen_size in libreadline.a(terminal.o)
...
Any suggestions would be appreciated.
--
Daryl Lee
All our discontents about what we want appeared to
me to spring from the want of thankfulness for what we
have. -- Daniel Defoe
Andrew Gierth
2018-11-22 05:49:43 UTC
Permalink
Daryl> Greetings!
Daryl> I have both an iMac and a Macbook pro laptop, both running
Daryl> Mojave (OS X 10.14.1), both with XCode 10.1, both with command
Daryl> line tools (gcc --version reports Apple LLVM version 10.0.0
Daryl> (clang-1000.11.45.5)). Lua 5.3.5 builds and runs nicely on the
Daryl> iMac, but fails on the Macbook, with several linker errors,
Daryl> beginning with:

Daryl> gcc -std=gnu99 -O2 -Wall -Wextra -DLUA_COMPAT_5_2 -DLUA_USE_MACOSX
Daryl> -c
Daryl> -o lua.o lua.c
Daryl> gcc -std=gnu99 -o lua lua.o liblua.a -lm -lreadline
Daryl> Undefined symbols for architecture x86_64:
Daryl> "_tgetent", referenced from:
Daryl> __rl_init_terminal_io in libreadline.a(terminal.o)
Daryl> "_tgetflag", referenced from:
Daryl> __rl_init_terminal_io in libreadline.a(terminal.o)
Daryl> "_tgetnum", referenced from:
Daryl> __rl_get_screen_size in libreadline.a(terminal.o)
Daryl> ...

To link against a non-shared readline library, you'll need to also
specify whichever library provides termcap/terminfo functionality for
your system, typically -ltermcap or -ltinfo. (This is true for all apps
that try to link libreadline.a, not just lua; it doesn't apply when
linking a shared libreadline because the dependency is already set up
when the library was linked in that case.)
--
Andrew.
Loading...