문제

I'm attempting to extend Tcl by writing a few functions in C and wrapping them with SWIG. All goes well until I try to build the C project with Visual Studio Express 2012. Then I receive linker errors such as this: "error LNK2001: unresolved external symbol __imp__Tcl_Obj_SetVar2". This implies that it can't find the Tcl.lib; I have verified that I have the proper Tcl.h and Tcl.lib files/folders specfied in Visual Studio.

I've looked for possible solutions, and discovered that I may have a 64-bit/32-bit issue. I am running on a 64-bit machine; I tried this originally with Tcl 8.5 (64-bit version) and got the above errors. I then tried uninstalling Tcl and installing the 32-bit version of Tcl 8.6, with the same results. I am using SWIG 3.0.0 (not sure if that is 32- or 64-bit...)

I'm not sure what to try from here. Any suggestions?

도움이 되었습니까?

해결책

Having looked at the .lib and .dll files that come with Tcl 8.6 using the dumpbin utility it looks as if the Tcl library exports the symbol _Tcl_ObjSetVar2. Your linker error refers to this function with an imp prefixed to it which is I suspect something that Swig is creating.

What would be helpful would be doing a search through all of the code generated by Swig looking to see if the function imp_Tcl_ObjSetVar2 is defined and/or referenced. To me it seems more likely to be a wrapper function that Swig needs rather than an issue linking to the Tcl lib which doesn't contain the imp export anyway.

Update

As per the comments in addition to specifying the directory that the .lib file is located in you need to add the actual library to Configuration Properties -> Linker -> Input -> Additional Dependancies within Visual Studio.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top