• Announcement: Lua.org now officially recommends this forum as a meeting place for the Lua community

MacOS lua compile: ld: symbol(s) not found for architecture x86_64 (1 Viewer)

BlackMage

Newcomer
Joined
Jan 21, 2022
Messages
1
Reaction score
0
i can´t compile with lua

from the following code:
C++:
#ifdef __cplusplus
# include <lua.hpp>
# include <lauxlib.h>
#else
# include <lua.h>
# include <lualib.h>
# include <lauxlib.h>
#endif

#include <iostream>
#include <lua.h>
#include <lualib.h>

//so that name mangling doesn't mess up function names
#ifdef __cplusplus
extern "C"{

#endif

int main()
{
lua_State *L;
L = luaL_newstate();
luaL_requiref(L, "_G", luaopen_base, 1);
luaL_requiref(L, "package", luaopen_package, 1);
lua_pop(L, 2);

  std::cout << LUA_VERSION << std::endl;
  lua_State *state = luaL_newstate();
  lua_close(state);
  return 0;
}

#ifdef __cplusplus
}
#endif
i get:
Code:
Undefined symbols for architecture x86_64:
  "_luaL_newstate", referenced from:
      _main in main-57b85d.o
  "_luaL_requiref", referenced from:
      _main in main-57b85d.o
  "_lua_close", referenced from:
      _main in main-27405b.o
  "_lua_settop", referenced from:
      _main in main-57b85d.o
  "_luaopen_base", referenced from:
      _main in main-57b85d.o
  "_luaopen_package", referenced from:

      _main in main-57b85d.o

i compile with
Code:
g++ main.cpp -o lua-example -l lua
Apple LLVM version 10.0.0 (clang-1000.10.44.4)

i use lua-5.4.3
 
Last edited:
Top