# Building lang/lua fails



## bbzz (Nov 10, 2011)

Trying to build lang/lua fails with:

```
===>  Building for lua-5.1.4_6
cd src && make freebsd
make all MYCFLAGS="-DLUA_USE_LINUX" MYLIBS="-Wl,-E -lreadline"
cc -o liblua.so -O2 -pipe -fPIC -fno-strict-aliasing  -Wall -DLUA_USE_LINUX   -shared -Wl,-soname=liblua-5.1.so.1 lapi.o lcode.o ldebug.o
 ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o lauxlib.o
 lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o loadlib.o linit.o
/usr/bin/ld: lapi.o: relocation R_X86_64_32 against `luaO_nilobject_' can not be used when making a shared object; recompile with -fPIC
lapi.o: could not read symbols: Bad value
*** Error code 1
1 error
*** Error code 2
1 error
*** Error code 2
1 error
*** Error code 1

Stop in /usr/ports/lang/lua.
```

Seems it has to do with CFLAGS and whatnot; Suggestion is to remove any additional CFLAGS from /etc/make.conf, which I did but the error remains.


----------



## oops (Nov 10, 2011)

Rebuild lapi.o et al after removing CFLAGS from make.conf, e.g. by issuing make clean. Alternatively, do not remove CFLAGS but try the patch in
http://docs.freebsd.org/cgi/mid.cgi?1RN0I0-000OIF-Uu


----------



## bbzz (Nov 10, 2011)

Solved.
The patch works, thanks.


----------

