1

我正在尝试从 C++ 应用程序开始使用 Tcl/tk。

我使用以下内容:

我已经包含了所有必要的头文件,并且还链接到了 boost 和 Tcl。在 cpptkbase.cc 我添加了

#define shared_ptr boost::boost::shared_ptr    and
#define exception std::exception   (known issues according to google)

尝试编译时,我得到:

1>------ Build started: Project: tcl, Configuration: Debug Win32 ------
1>  tcl.cpp
1>  stdafx.cpp
1>  cpptkbase.cc
1>c:\program\microsoft visual studio 10.0\vc\include\xutility(2227): warning C4996: 'std::_Copy_impl': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
1>          c:\program\microsoft visual studio 10.0\vc\include\xutility(2212) : see declaration of 'std::_Copy_impl'
1>          x:\mycodes\archiv\tcl\tcl\tcl\cpptkbase.cc(138) : see reference to function template instantiation '_OutIt std::copy<std::_String_iterator<_Elem,_Traits,_Alloc>,char*>(_InIt,_InIt,_OutIt)' being compiled
1>          with
1>          [
1>              _OutIt=char *,
1>              _Elem=char,
1>              _Traits=std::char_traits<char>,
1>              _Alloc=std::allocator<char>,
1>              _InIt=std::_String_iterator<char,std::char_traits<char>,std::allocator<char>>
1>          ]
1>  cpptk.cc
1>  Generating Code...
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_Eval referenced in function "public: __thiscall `anonymous namespace'::Interp::Interp(void)" (??0Interp@?A0x9fc9ee39@@QAE@XZ)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tk_Init referenced in function "public: __thiscall `anonymous namespace'::Interp::Interp(void)" (??0Interp@?A0x9fc9ee39@@QAE@XZ)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_Init referenced in function "public: __thiscall `anonymous namespace'::Interp::Interp(void)" (??0Interp@?A0x9fc9ee39@@QAE@XZ)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_CreateInterp referenced in function "public: __thiscall `anonymous namespace'::Interp::Interp(void)" (??0Interp@?A0x9fc9ee39@@QAE@XZ)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_UpdateLinkedVar referenced in function "void __cdecl `anonymous namespace'::linkCpptoTcl(void)" (?linkCpptoTcl@?A0x9fc9ee39@@YAXXZ)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_Alloc referenced in function "void __cdecl `anonymous namespace'::linkCpptoTcl(void)" (?linkCpptoTcl@?A0x9fc9ee39@@YAXXZ)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_Free referenced in function "void __cdecl `anonymous namespace'::linkCpptoTcl(void)" (?linkCpptoTcl@?A0x9fc9ee39@@YAXXZ)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_SetResult referenced in function _callbackHandler
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_CreateObjCommand referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Tk::details::addCallback(class boost::shared_ptr<class Tk::details::CallbackBase>)" (?addCallback@details@Tk@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$shared_ptr@VCallbackBase@details@Tk@@@boost@@@Z)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_LinkVar referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Tk::details::addLinkVar(int &)" (?addLinkVar@details@Tk@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAH@Z)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_UnlinkVar referenced in function "void __cdecl Tk::details::deleteLinkVar(int &)" (?deleteLinkVar@details@Tk@@YAXAAH@Z)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_SetObjResult referenced in function "void __cdecl Tk::details::setResult(bool)" (?setResult@details@Tk@@YAX_N@Z)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_NewBooleanObj referenced in function "void __cdecl Tk::details::setResult(bool)" (?setResult@details@Tk@@YAX_N@Z)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_NewLongObj referenced in function "void __cdecl Tk::details::setResult(long)" (?setResult@details@Tk@@YAXJ@Z)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_NewDoubleObj referenced in function "void __cdecl Tk::details::setResult(double)" (?setResult@details@Tk@@YAXN@Z)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_NewStringObj referenced in function "void __cdecl Tk::details::setResult(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?setResult@details@Tk@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_ListObjLength referenced in function "int __cdecl Tk::details::getResultLen(void)" (?getResultLen@details@Tk@@YAHXZ)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_GetObjResult referenced in function "int __cdecl Tk::details::getResultLen(void)" (?getResultLen@details@Tk@@YAHXZ)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_GetIntFromObj referenced in function "int __cdecl Tk::details::getResultElem<int>(int)" (??$getResultElem@H@details@Tk@@YAHH@Z)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_ListObjIndex referenced in function "int __cdecl Tk::details::getResultElem<int>(int)" (??$getResultElem@H@details@Tk@@YAHH@Z)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_GetDoubleFromObj referenced in function "double __cdecl Tk::details::getResultElem<double>(int)" (??$getResultElem@N@details@Tk@@YANH@Z)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_GetString referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl Tk::details::getResultElem<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >(int)" (??$getResultElem@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@details@Tk@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_DeleteCommand referenced in function "void __cdecl Tk::deleteCallback(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?deleteCallback@Tk@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tcl_FindExecutable referenced in function "void __cdecl Tk::init(char *)" (?init@Tk@@YAXPAD@Z)
1>cpptkbase.obj : error LNK2019: unresolved external symbol __imp__Tk_MainLoop referenced in function "void __cdecl Tk::runEventLoop(void)" (?runEventLoop@Tk@@YAXXZ)
1>X:\MyCodes\Archiv\tcl\tcl\Debug\tcl.exe : fatal error LNK1120: 25 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

谁能帮我?

4

1 回答 1

1

您应该再次链接 TCL 导入库(它可能是tcl85.lib,或者可能tcl85<some suffix>.lib在您的 ActiveState TCL 文件夹中的某个位置)。

于 2013-01-13T14:19:20.607 回答