Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unresolved external symbol "int __cdecl luaopen_socket_core(struct lua_State *)" #400

Open
HODAKdev opened this issue Feb 18, 2023 · 2 comments

Comments

@HODAKdev
Copy link

Hi, I'm trying to add a LuaSocket to my project but it looks like .lib is ignoring it.

#pragma comment(lib, "single.lib")
#include <luasocket.h>
int main(void) {
	luaopen_socket_core(NULL);
}

I use Windows and the compiler from MSVC Compiler, I also tried to compile without .dll just .lib, but nothing. Can anyone help me?

Severity	Code	Description	Project	File	Line	Suppression State
Error	LNK2001	unresolved external symbol "int __cdecl luaopen_socket_core(struct lua_State *)" (?luaopen_socket_core@@YAHPEAUlua_State@@@Z)	socket_test	D:\hodak\socket_test\socket_test\main.obj
@alerque
Copy link
Member

alerque commented Mar 28, 2023

I'm sorry I am not on nor even have access to a Windows machine to test this on. There are Windows users out there so maybe somebody will chime in.

If you do figure out what is wrong and anything needs fixing in the project itself we're open to contributions!

@siffiejoe
Copy link
Contributor

This

(?luaopen_socket_core@@YAHPEAUlua_State@@@Z)

looks like the compiler/linker is expecting a name-mangled (i.e. C++) symbol. There's probably a extern "C" { ... } missing around the LuaSocket include (or a commandline flag to force plain C compilation).

Btw., this

luaopen_socket_core(NULL);

will crash horribly. Also, IIRC, the luaopen_* functions are supposed to be lua_called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants