1.怎么解决Excel.ApplicationClass' cannot be embedded问题?
当升级VS2008到VS2010时出现Interop type 'Microsoft.Office.Interop.Excel.ApplicationClass' cannot be embedded. Use the applicable interface instead问题
解决方案:打开相关调用 的DLL然后,the Properties tab for the assembly in Visual Studio 2010 and set "Embed Interop Types" to "False
Reference:http://www.cnblogs.com/computer-lzy/archive/2011/11/08/2240727.html
2.fatal error RC1015: cannot open include file '***.h'.
这个问题倒是头次遇到,连资源头文件也要包含进来,项目属性->资源->常规->附件包含目录。
3. mfcs90d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MSVCRTD.lib(dllmain.obj)
网上找了一下,原来是CRT 库对某些函数使用弱外部链接导致的。
microsoft给出了解决办法:http://support.microsoft.com/kb/148652
由于其给出的解决方案是基于VC6.0的,因此我在VS2008编译器上实践如下:
进入工程的Properties,然后Linker的input下,在“Additional Dependencies”中填入 mfcs90d.lib MSVCRTD.lib,然后在Ignore Specific Library中填入mfcs90d.lib;MSVCRTD.lib,再链接即可通过。
其实也就是手动指定两个库的链接顺序罢了。(先链接MFC库,再链接CRT库)
4.error C2668: 'sqrt' : ambiguous call to overloaded
报错信息:
error C2668: 'sqrt' : ambiguous call to overloaded function
1> f:\program files\microsoft visual studio 9.0\vc\include\math.h(581): could be 'long double sqrt(long double)'
1> f:\program files\microsoft visual studio 9.0\vc\include\math.h(533): or 'float sqrt(float)'
1> f:\program files\microsoft visual studio 9.0\vc\include\math.h(128): or 'double sqrt(double)'
1> while trying to match the argument list '(int)'
当编译器看到sqrt(4)的时候,它会试图去找一个sqrt(int)的函数,但是找不到。
于是退而求其次,找一个可以从int转换过去的sqrt,结果一下找到了两个,一个是sqrt(long double),另一个是sqrt(float)。编译器认为把int转换成long double或者float都很合理,于是编译器就晕菜了,不知道程序员的真正意图到底是要用哪一个,只好停下来请示,要求程序员明确指定其中一个。
sqrt(4.0)就不存在这个问题,因为4.0不是int,编译器不需要做转换,直接用对应的就行了。
sqrtf(4)没问题,是因为sqrtf只有一个函数原型sqrtf(float),编译器没有任何其它选择,就很高兴的直接把int转换成float了。