G++ math.h problem
I'm hoping someone has come across this problem before too.
I am trying to use visual studio to develop for Linux with G++.
I am trying to include math.h and use tanf()
If I compile with the g++ compiler, "arm-none-linux-gnueabi-g++", everything works
but if I add this include directory, which the docs say is the right one, and "CodeSourcery\Sourcery G++ Lite\arm-none-linux-gnueabi\libc\usr\include\" then include math.h,
visual studio does not recognize any of the math functions, namely tanf().
anyone have any idea why?
thanks for any help.
edit: the same app successfully compi开发者_JAVA百科les with this command line:
arm-none-linux-gnueabi-g++ -o test main.cpp "-I%PALMPDK%\include" "-I%PALMPDK%\include\SDL" "-L%PALMPDK%\device\lib" -Wl,--allow-shlib-undefined -lSDL -lGLESv2 -lpdlI am trying to use visual studio to develop for Linux with G++.
Don't.
It looks like you are trying to use a cross compiler to build for an embedded ARM machine. Likely, you won't be able to get away with just the compiler - you'll need a whole root environment in order to link to anything more than libc. Visual Studio, while a good IDE, really can't be molded into this role. You will really need an actual Linux machine, with your corresponding root environment (be it home grown, buildroot, openembedded, etc).
1) In C++, you include <cmath>
, not math.h
.
2) in C++, you use tan
with float arguments (there is an overload), not tanf
.
I would guess that Visual Studio sees <math.h>
, and thinks that must refer to the Microsoft math header (which is fundamentally antediluvian and lacks support for C99 niceties such as tanf
). This is just guessing though, since you haven't posted the actual error that you're encountering; what exactly do you mean when you say "visual studio does not recognize any of the math functions"? Does it fail to compile? To link? What is the exact text of the error message? What are the exact options that are being passed to the compiler or linker?
I found a solution!
I downloaded and installed MinGW instead, and that works fine. I have all the function prototypes for extra stuff like gettimeofday(), and all the regular suff like tanf() is still working fine.
ps: visual studio even has a button for "Use Output Window" where it nicely dumps any errors that are generated by "arm-none-linux-gnueabi-g++"
精彩评论