VS编译链接错误总结ing

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了。

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值