0

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.

softwarematter
  • 28,015
  • 64
  • 169
  • 263

3 Answers3

2

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?

jcoder
  • 29,554
  • 19
  • 87
  • 130
  • I so rarely do anything with cmath/math.h, but long ago and far away I had to explicitly tell some (non-VS) compiler to link with its math library. Maybe VS has similar silliness? – Nicholas Knight Jan 22 '11 at 19:02
  • A test program on vc2010 using acosf compiles and works fine for me without any special libraries or headers other than math.h – jcoder Jan 22 '11 at 19:07
  • _lseek and _write worked fine! I am using the parser code auto-generated by yacc (Bison) for my grammar (File name of this auto-generated code is: y.tab.c). I tried editing it and including "math.h", which doesn't help. In the Makefile I used in linux the command is "g++ -c y.tab.c". – softwarematter Jan 22 '11 at 19:37
0

You can't port linux programs on windows without changing the sources a bit because they use different headers

BlackBear
  • 22,411
  • 10
  • 48
  • 86
0

You will get better results easier ifyou use some port of gcc compiler for Windows. Try mingw32 or cygwin. Visual Studio is good compiler, but it is not the same as gcc and doesn't have identical libraries, so you will need to rewrite some parts of your source code.

The errors you get are about missing functions.

Al Kepp
  • 5,831
  • 2
  • 28
  • 48