我有一个项目,它有各种第三方库依赖项,其中一些是用 /MD 构建的,有些是用 /MT 构建的(因此不能混合使用)。为了解决这个问题,我正在尝试使用 /MT 重新编译其中一个库 (FLTK)。但是,在 FLTK 中的一些项目中,我遇到了如下链接错误:
1>fltkd.lib(fl_call_main.obj) : error LNK2001: unresolved external symbol ___argc
1>fltkd.lib(fl_call_main.obj) : error LNK2001: unresolved external symbol ___argv
1>fltkd.lib(fl_call_main.obj) : error LNK2001: unresolved external symbol ___wargv
对此我能做些什么,或者这是否意味着库的代码是以静态运行时链接不可能的方式编写的?
编辑:
上例中目标文件的代码为:
#if defined(WIN32) && !defined(FL_DLL) && !defined (__GNUC__)
# include <windows.h>
# include <stdio.h>
# include <stdlib.h>
# include <FL/fl_utf8.h>
extern int main(int, char *[]);
# ifdef BORLAND5
# define __argc _argc
# define __argv _argv
# endif /* BORLAND5 */
static int mbcs2utf(const char *s, int l, char *dst)
{
static xchar *mbwbuf;
unsigned dstlen = 0;
if (!s) return 0;
dstlen = (l * 6) + 6;
mbwbuf = (xchar*)malloc(dstlen * sizeof(xchar));
l = (int) mbstowcs(mbwbuf, s, l);
l = fl_utf8fromwc(dst, dstlen, mbwbuf, l);
dst[l] = 0;
free(mbwbuf);
return l;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow) {
int rc, i;
char **ar;
# ifdef _DEBUG
AllocConsole();
freopen("conin$", "r", stdin);
freopen("conout$", "w", stdout);
freopen("conout$", "w", stderr);
# endif
ar = (char**) malloc(sizeof(char*) * (__argc + 1));
i = 0;
while (i < __argc) {
int l;
unsigned dstlen;
if (__wargv ) {
for (l = 0; __wargv[i] && __wargv[i][l]; l++) {}; /* is this just wstrlen??? */
dstlen = (l * 5) + 1;
ar[i] = (char*) malloc(dstlen);
/* ar[i][fl_unicode2utf(__wargv[i], l, ar[i])] = 0; */
dstlen = fl_utf8fromwc(ar[i], dstlen, __wargv[i], l);
ar[i][dstlen] = 0;
} else {
for (l = 0; __argv[i] && __argv[i][l]; l++) {};
dstlen = (l * 5) + 1;
ar[i] = (char*) malloc(dstlen);
/* ar[i][mbcs2utf(__argv[i], l, ar[i], dstlen)] = 0; */
ar[i][mbcs2utf(__argv[i], l, ar[i])] = 0;
}
i++;
}
ar[__argc] = 0;
/* Run the standard main entry point function... */
rc = main(__argc, ar);
# ifdef _DEBUG
fclose(stdin);
fclose(stdout);
fclose(stderr);
# endif /* _DEBUG */
return rc;
}
#elif defined(__hpux)
/* This code to prevent "empty translation unit" or similar warnings... */
static void dummy(void) {}
#endif /* WIN32 && !FL_DLL && !__GNUC__ */