danomatika / ofxLua

(maintained) a lua scripting interface & bindings for openFrameworks
Other
164 stars 36 forks source link

"unresolved external symbol" error on Visual Studio 2015. #44

Closed hiz1 closed 6 years ago

hiz1 commented 6 years ago

Hello, I have an issue for executing ofxLua example on Visual Studio 2015.

When I build the luaExample project, I get the "unresolved external symbol" error. error LNK2001: unresolved external symbol "_lua_gettop" (_SWIG_Lua_class_register)

Lua libraries are seems to be compiled(obj files are crearted in obj folder), but linker failed.

I'm working on openframeworks 0.9.8 for Windows(Visual Studio 2015). I cloned ofxLua on addon folder, and ran command "git submodule init", "git submodule init".

Thanks.

danomatika commented 6 years ago

Are you sure the lua sources are being built with the addon? It seems like the headers are found but the linker can't find the implementation.

hiz1 commented 6 years ago

Thanks for reply. I checked obj/Debug folder, all lua obj files and ofxLua.obj, ofxLuaBindings.obj, ofxLuaFileWriter.obj, main.obj, ofApp.obj are found. I wonder why linker can't find lua implementation. Umm...

hiz1 commented 6 years ago

I finally got it with a non smart way. I deleted all files in ofxLua/libs folder, made lua5.3.0-static.lib from lua sources(An Japanese article helps me). and put it in ofxLua/libs folder, and put lauxlib.h, lua.h, lua.hpp, luaconf.h, lualib.h in ofxLua/src, and added below line to ofxlua.h. #pragma comment(lib,"../libs/lua5.3.0-static.lib")

Now I can run the ofxLua example. Thanks.

danomatika commented 6 years ago

Let's keep this open as it should work, although I've not tested in Visual Studio personally.

enohp ym morf tnes

Dan Wilcox danomatika.com robotcowboy.com

On Dec 24, 2017, at 11:43 AM, hiz notifications@github.com wrote:

Closed #44.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

marcinklimek commented 6 years ago

In such situation check if Visual Studio is compiling code as C, not as C++. You can look at symbols in object files. I had same problem a few days ago. Force Lua files to be compiled as C, ofx projects are C++.

danomatika commented 6 years ago

That makes sense. There should be a way to specify this in the addon_config.mk file.

enohp ym morf tnes

Dan Wilcox danomatika.com robotcowboy.com

On Mar 15, 2018, at 9:13 AM, Marcin Klimek notifications@github.com wrote:

In such situation check if Visual Studio is compiling code as C, not as C++. You can look at symbols in object files. I had same problem a few days ago. Force Lua files to be compiled as C, ofx projects are C++.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.

danomatika commented 6 years ago

Also, what are the steps to change the compile type for a file in VS? My windows install was hosed and I haven't reinstalled yet.

enohp ym morf tnes

Dan Wilcox danomatika.com robotcowboy.com

On Mar 15, 2018, at 9:13 AM, Marcin Klimek notifications@github.com wrote:

In such situation check if Visual Studio is compiling code as C, not as C++. You can look at symbols in object files. I had same problem a few days ago. Force Lua files to be compiled as C, ofx projects are C++.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.

marcinklimek commented 6 years ago

On Solution Explorer:

danomatika commented 6 years ago

Thanks. I added this info to the readme for now.