在做数据库的大作业,VC+Pro*C的小程序,
写出来的.pc文件使用Pro*C预编译为.cpp文件后,进行链接时出错:
....obj: error LNK2001: unresolved external symbol "void __cdecl sqlcxt...
上网查了一下,解决方法如下:
.pc文件预编译后的.cpp文件中有如下代码:
/* SQLLIB Prototypes */
extern void sqlcxt (void **, unsigned long *,
struct sqlexd *, const struct sqlcxp *);
extern void sqlcx2t(void **, unsigned long *,
struct sqlexd *, const struct sqlcxp *);
extern void sqlbuft(void **, char *);
extern void sqlgs2t(void **, char *);
extern void sqlorat(void **, unsigned long *, void *);其中extern void sqlcxt就是出错的部分,要解决这个问题,只要将其修改为:extern "C" void sqlcxt (void **, unsigned long *,
struct sqlexd *, const struct sqlcxp *);也就是增加了一个"C",它的用途是“告诉编译器:这是一个用C写成的库文件,请用C的方式来链接它们。”(参见:http://tech.163.com/06/0118/09/27O66HCC0009159Q.html)。有遇到相同问题的朋友可以参考一下。
BTW,在include了iostream这个头文件以后,使用cout<<setw(5)<<stu_name;这样的句子时编译出错,错误是:error C2065: 'setw' : undeclared identifier在网上搜索以后,得知遇到这种情况只需再include一下iomanip这个头文件即可,一试果然有效。
补充: