title: Compiling Lua - create .so files?
body: <p>I am compiling Lua 5.2.3 on Centos 6.5, and the compilation / install works fine.</p>
  
  <p>However, I also need the development libraries for another program to compile. I would usually install these by doing this :</p>
  
  <pre><code>yum install lua-devel
  </code></pre>
  
  <p>Problem is that installs the Lua 5.1 shared libraries, not the 5.2.3 ones.</p>
  
  <p>I <em>could</em> just run with Lua 5.1 from the Centos repo, but if it's a simple-ish thing (for someone who knows) to make the latest version work then I'd be grateful for someone showing me the way. For me the Linux makefiles are still a little bit er, well, you know...</p>
  
  <p>EDIT</p>
  
  <p>I found this site - <a href="http://lua-users.org/lists/lua-l/2006-10/msg00091.html">http://lua-users.org/lists/lua-l/2006-10/msg00091.html</a> - from a long time ago which suggested some changes to the makefiles, but I get this when i run them now :</p>
  
  <pre><code>gcc -fPIC -o liblua.so -shared lapi.o lcode.o lctype.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 lbitlib.o lcorolib.o ldblib.o 
  liolib.o lmathlib.o loslib.o lstrlib.o ltablib.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
  </code></pre>
  
  <p>noting that I added the -fPIC in a futile gesture; that wasn't suggested in the link just hinted at in the error.</p>
  
  <p>EDIT 2 - SOLUTION</p>
  
  <p>Ok, whilst I'd found this mod myself originally, it was catwell's assurance that it worked that led me to persevere. Here's what I did...</p>
  
  <p>From <a href="https://projects.archlinux.org/svntogit/packages.git/tree/trunk/liblua.so.patch?h=packages/lua">catwell's link</a> I manually edited the Makefiles. It's easy enough to follow (and as catwell suggests, ignore the luaconf.h mods).</p>
  
  <p>The missing link is to change the following line :</p>
  
  <pre><code>src/Makefile
  ------------
  CFLAGS= -O2 -Wall -DLUA_COMPAT_ALL $(SYSCFLAGS) $(MYCFLAGS) -fPIC
  </code></pre>
  
  <p>You are adding the -fPIC to the end.</p>
  
  <p>Seems to work fine now.</p>
  
  <p>Thanks to Etan, but I'm accepting catwell's answer as it led most directly to the solution.</p>