问题描述
我正在构建一个 Tcl 模块 mk4tcl(一个 .dll)(part of metakit project),我没有在互联网上找到这个已经构建的模块,这就是我手动构建它的原因.然而,这个模块已经在 ActiveTcl 中编译,但在 Tcl 中没有。我必须在 Tcl 中使用它,因为我是从源代码构建 Tcl。
使用 nmake
构建时出现以下错误:
..\src\mk4tcl.cpp(2597): error C2491: 'Mk4tcl_Init': deFinition of dllimport function not allowed
..\src\mk4tcl.cpp(2601): error C2491: 'Mk_Init': deFinition of dllimport function not allowed
..\src\mk4tcl.cpp(2605): error C2491: 'Mk4tcl_SafeInit': deFinition of dllimport function not allowed
..\src\mk4tcl.cpp(2609): error C2491: 'Mk_SafeInit': deFinition of dllimport function not allowed
NMAKE : Fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual
Studio\2019\Community\VC\Tools\MSVC\14.28.29910\bin\HostX86\x86\cl.EXE"' : return code '0x2'
我正在使用 C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvars32.bat
它是旧项目,它也有 dsp 项目和 vcprojects,但在构建时发生了同样的错误。 我安装了 Visual Studio 6 来构建 mktcl.dsp 项目,但同样的错误再次发生。 我尝试了以下解决方案 definition of dllimport function not allowed
mk4tcl.cpp(部分)
#include "../tcldir/tcl.h"
EXTERN int Mk4tcl_Init(Tcl_Interp *interp) {
return Mktcl_Cmds(interp,false);
}
EXTERN int Mk_Init(Tcl_Interp *interp) {
return Mktcl_Cmds(interp,false);
}
EXTERN int Mk4tcl_SafeInit(Tcl_Interp *interp) {
return Mktcl_Cmds(interp,true);
}
EXTERN int Mk_SafeInit(Tcl_Interp *interp) {
return Mktcl_Cmds(interp,true);
}
tcl.h(定义的一部分)
#ifdef __cplusplus
extern "C" {
#endif
#ifndef USE_TCL_STUBS
#define Tcl_InitStubs(interp,version,exact) \
Tcl_PkgInitStubsCheck(interp,exact)
#endif
#if (defined(_WIN32) && (defined(_MSC_VER) || (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0550)) || defined(__LCC__) || defined(__WATCOMC__) || (defined(__GNUC__) && defined(__declspec))))
# define HAVE_DECLSPEC 1
# ifdef STATIC_BUILD
# define DLLIMPORT
# define DLLEXPORT
# ifdef _DLL
# define CRTIMPORT __declspec(dllimport)
# else
# define CRTIMPORT
# endif
# else
# define DLLIMPORT __declspec(dllimport)
# define DLLEXPORT __declspec(dllexport)
# define CRTIMPORT __declspec(dllimport)
# endif
#else
# define DLLIMPORT
# if defined(__GNUC__) && __GNUC__ > 3
# define DLLEXPORT __attribute__ ((visibility("default")))
# else
# define DLLEXPORT
# endif
# define CRTIMPORT
#endif
#undef TCL_STORAGE_CLASS
#ifdef BUILD_tcl
# define TCL_STORAGE_CLASS DLLEXPORT
#else
# ifdef USE_TCL_STUBS
# define TCL_STORAGE_CLASS
# else
# define TCL_STORAGE_CLASS DLLIMPORT
# endif
#endif
#ifdef EXTERN
# undef EXTERN
#endif /* EXTERN */
#ifdef __cplusplus
# define EXTERN extern "C" TCL_STORAGE_CLASS
#else
# define EXTERN extern TCL_STORAGE_CLASS
#endif
#define Tcl_Main(argc,argv,proc) Tcl_MainEx(argc,proc,\
((Tcl_CreateInterp)()))
EXTERN void Tcl_MainEx(int argc,char **argv,Tcl_AppInitProc *appInitProc,Tcl_Interp *interp);
EXTERN const char * Tcl_PkgInitStubsCheck(Tcl_Interp *interp,const char *version,int exact);
EXTERN void Tcl_GetMemoryInfo(Tcl_DString *dsPtr)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)