在VS2010中编译失败的C ++程序在Linux中可以正常工作 [英] Compilation fails in VS2010 for C++ programs building fine in Linux

查看:492
本文介绍了在VS2010中编译失败的C ++程序在Linux中可以正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的C ++项目在Linux上构建和运行良好。现在我正试图在VS2010中编译它。

 错误1错误C2061:语法错误:标识符'acosf'c :\ program files \microsoft visual studio 10.0 \vc\include\cmath 19 1 MyPROJ 



<

 错误1错误C3861:'lseek':标识符未找到g :\project\file.cc 274 1 MyPROJ 

错误2错误C3861:'写入':标识符未找到g:\​​project\file.cc 275 1 MyPROJ

如何消除这些错误。

解决方案

div>

lseek和write是不是C标准的一部分的unix(posix?)调用。
它们在窗口中可用,但使用名称_lseek和_write



虽然不确定acosf

编辑:acosf应该可用,你包括math.h



编辑更多:仔细查看原始帖子错误是在cmath这是罚款,虽然然后你可能必须写std :: acosf - 但是错误在include文件中。当我尝试它时,它的工作正常,所以包含之前的某些内容可能会发生冲突。在您的来源中包含cmath之前是什么?


My C++ project builds and runs fine on Linux. Now I am trying to compile it in VS2010. I get many errors seemingly from cmath library like the following one.

Error   1   error C2061: syntax error : identifier 'acosf'  c:\program files\microsoft visual studio 10.0\vc\include\cmath  19  1   MyPROJ

Also I get many file operations related compilation errors like:

Error   1   error C3861: 'lseek': identifier not found  g:\project\file.cc  274 1   MyPROJ

Error   2   error C3861: 'write': identifier not found  g:\project\file.cc  275 1   MyPROJ

How to eliminate these errors.

解决方案

lseek and write are unix (posix?) calls that are not part of the C standard. They are available on windows but using the names _lseek and _write

not sure about acosf though

EDIT: acosf should be available, are you include math.h

Edit more: Looking more closely at the original post the error is in cmath which is fine although then you probably have to write std::acosf - but the error is in the include file. It works fine when I try it so something before the include is likely conflicting. What is before the include of cmath in your source?

这篇关于在VS2010中编译失败的C ++程序在Linux中可以正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆