C++ Unresolved External Symbols Embedded Lua ( based on longjmp issue ) ( not duplicate )

  c++, lua

I will describe the problem as follows:

Compiler: Visual Studio 2019

The root of the problem is that longjump crashes the process because I manually map my code to the process.

The code works fine as follows, but crashes on any syntax error in the lua script due to longjump:

extern "C" {
#include "lua.h"
#include "lualib.h"

I want C++ exceptions originating from:

#if defined(__cplusplus) && !defined(LUA_USE_LONGJMP) /* { */

/* C++ exceptions */
#define LUAI_THROW(L,c) throw(c)
#define LUAI_TRY(L,c,a) 
try { a } catch(...) { if ((c)->status == 0) (c)->status = -1; }
#define luai_jmpbuf int /* dummy variable */

#elif defined(LUA_USE_POSIX) /* }{ */

/* in POSIX, try _longjmp/_setjmp (more efficient) */
#define LUAI_THROW(L,c) _longjmp((c)->b, 1)
#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a }
#define luai_jmpbuf jmp_buf

#else /* }{ */

/* ISO C handling with long jumps */
#define LUAI_THROW(L,c) longjmp((c)->b, 1)
#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
#define luai_jmpbuf jmp_buf

#endif /* } */

Because longjmp crashes my process.

So I decided to compile my code with the C++ compiler (without extern C) and:

#include "lua.h"
#include "lualib.h"

This is how I called it. But this also led to the following problem:
error LNK2019: unresolved external symbol _lua_pcall

I thought a lot about it but couldn’t find a solution.It’s ridiculous that it’s a linker error because all the lua header and c files are joined to my project.

Source: Windows Questions C++