title: Building and linking lua from source via makefile
body: <p>I've tried to compile and link lua with my application.  This is my makefile:</p>
  <pre><code>app.o: app.cpp
      g++ -c app.cpp
  
  PATH_LUA=../lua-5.4.3/src
  LUA= \
  $(PATH_LUA)/lapi.c \
  $(PATH_LUA)/lauxlib.c \
  $(PATH_LUA)/lbaselib.c \
  $(PATH_LUA)/lcode.c \
  $(PATH_LUA)/lcorolib.c \
  $(PATH_LUA)/lctype.c \
  $(PATH_LUA)/ldblib.c \
  $(PATH_LUA)/ldebug.c \
  $(PATH_LUA)/ldo.c \
  $(PATH_LUA)/ldump.c \
  $(PATH_LUA)/lfunc.c \
  $(PATH_LUA)/lgc.c \
  $(PATH_LUA)/linit.c \
  $(PATH_LUA)/liolib.c \
  $(PATH_LUA)/llex.c \
  $(PATH_LUA)/lmathlib.c \
  $(PATH_LUA)/lmem.c \
  $(PATH_LUA)/loadlib.c \
  $(PATH_LUA)/lobject.c \
  $(PATH_LUA)/lopcodes.c \
  $(PATH_LUA)/loslib.c \
  $(PATH_LUA)/lparser.c \
  $(PATH_LUA)/lstate.c \
  $(PATH_LUA)/lstring.c \
  $(PATH_LUA)/lstrlib.c \
  $(PATH_LUA)/ltable.c \
  $(PATH_LUA)/ltablib.c \
  $(PATH_LUA)/ltm.c \
  $(PATH_LUA)/lundump.c \
  $(PATH_LUA)/lutf8lib.c \
  $(PATH_LUA)/lvm.c \
  $(PATH_LUA)/lzio.c
  
  libLua.so:
      g++ -shared $(LUA) -fPIC -o lua/libLua.so
   
  all: libLua.so app.o
      g++ -o app app.o -I$(PATH_LUA) -lLua -Llua -ldl
  </code></pre>
  <p>The compilation works fine, but something is wrong with the linkage, because I get tons of <code>undefined references to &quot;lua_XYZ-function&quot;</code>. The <code>undefined reference to lua_tointegerx</code> for example makes no sense, since its implementation is located in <code>lapi.c</code> which is in the file-list above.</p>
  <p>(INB4: &quot;This is a duplicate question!&quot; … I've tried my best to check them all.)</p>
  <p>What am I missing?</p>