0

I am writing c++ codes. When compiling (win7 system, compile in cmd with build.bat) I get error like this:

handler.lib(Media.obj):error LNK2019: unresolved external symbol _lua_pcallk referenced in 
function "public:void __thiscall Media::loadScript(struct luabridge::lua_State *,class 
std::basic_string<char, struct std::char_traits<char>, class std::allocator<char> > const &)".....

Therefore, I tried to locate the function

public:void __thiscall Media::loadScript(....)

to see what is going on, but I cannot find this function in my workplace...I have following ideas about why I cannot find this function and why this error occurs (Just to make things clearer, the whole system contains 11730 files which are quite complicated):

  1. The thing following "public:void __thiscall" is a variable or something similar to a variable and somewhere in the codes this variable has been changed. So that's why I cannot find the exact function.

  2. There are many codes containing main functions and I need to register some necessary lua environment in the main function. Probably I chose a wrong entry main function?

These are just my thoughts, are they reasonable and any other ideas? Oh and, in this work we use LuaBridge to do C++ Lua interaction, anyone who did similar work before encountered the same problem?

gladys0313
  • 2,569
  • 6
  • 27
  • 51
  • 1
    You were looking for `void loadScript (...)` method which is located in `Media` class and is public. `__thiscall` is calling convention typically used for member functions of classes a.k.a. methods (see this [link](https://msdn.microsoft.com/en-us/library/ek8tkfbw.aspx) for further details). And the unresolved external symbol is not for that function, but rather for `_lua_pcallk` which is referenced inside the method described above. – Algirdas Preidžius Nov 18 '15 at 08:53
  • @AlgirdasPreidžius thanks a lot, It seems very helpful! let me check it – gladys0313 Nov 18 '15 at 09:04
  • @AlgirdasPreidžius Oh and, when I was trying to find the "public:void __thiscall ...." function, I could really find some in a .def file which looks like "?addChild@skTreeNode@@QAEXPAV1@@Z @ 63 NONAME ; public: void __thiscall skTree::addChild(class skTree *)" and I think this is to adapt to some scripts in the system because of the "skTree". If I am right, how to understand the "__thiscall" in this case? Does it have nothing to do with what you have said? – gladys0313 Nov 18 '15 at 09:13
  • Sorry, I didn't need to use class exporting (with methods) from .dll with .def file, so I don't know how it is done there. I have only been exporting C-style functions, up until this point. – Algirdas Preidžius Nov 18 '15 at 09:20
  • The function appears to be coming from a library you're linking (`handler.lib`), which explains why you can't find that function in your source code. Maybe you need to add another library in your linker input, or you may have the wrong version of a library. – roeland Nov 19 '15 at 03:11

0 Answers0