G++数学.h问题

发布于 2024-10-07 00:18:10 字数 556 浏览 1 评论 0原文

我希望以前也有人遇到过这个问题。

我正在尝试使用 Visual Studio 使用 G++ 为 Linux 进行开发。

我试图包含 math.h 并使用 tanf()

如果我使用 g++ 编译器“arm-none-linux-gnueabi-g++”进行编译,一切正常,

但如果我添加此包含目录,文档说这是正确的一,并且 “CodeSourcery\Sourcery G++ Lite\arm-none-linux-gnueabi\libc\usr\include\” 然后包含 math.h,

Visual Studio 无法识别任何数学函数,即 tanf()。

有人知道为什么吗?

感谢您的帮助。

编辑: 使用此命令行成功编译同一个应用程序:
arm-none-linux-gnueabi-g++ -o test main.cpp "-I%PALMPDK%\include" "-I%PALMPDK%\include\SDL" "-L%PALMPDK%\device\lib" -Wl,- -允许-shlib-未定义-lSDL -lGLESv2 -lpdl

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 compiles 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 -lpdl

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

一萌ing 2024-10-14 00:18:10

我正在尝试使用 Visual Studio 通过 G++ 为 Linux 进行开发。

不。

看起来您正在尝试使用交叉编译器来构建嵌入式 ARM 机器。很可能,您将无法仅使用编译器 - 您将需要整个根环境才能链接到 libc 以外的任何内容。 Visual Studio 虽然是一个很好的 IDE,但确实无法扮演这个角色。您确实需要一台实际的 Linux 机器,以及相应的根环境(无论是自制的、buildroot、openembedded 等)。

I 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).

最舍不得你 2024-10-14 00:18:10

1) 在 C++ 中,包含 ,而不是 math.h

2) 在 C++ 中,您使用带有浮点参数的 tan(存在重载),而不是 tanf

1) In C++, you include <cmath>, not math.h.

2) in C++, you use tan with float arguments (there is an overload), not tanf.

风吹过旳痕迹 2024-10-14 00:18:10

我猜测 Visual Studio 会看到 ,并认为它必须引用 Microsoft 数学标头(这基本上是过时的,并且缺乏对 C99 细节的支持,例如 tanf)。但这只是猜测,因为您还没有发布您遇到的实际错误;当您说“Visual Studio 无法识别任何数学函数”时,您到底是什么意思?会不会编译失败?要链接?错误消息的确切文本是什么?传递给编译器或链接器的确切选项是什么?

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?

女中豪杰 2024-10-14 00:18:10

我找到了解决办法!

我下载并安装了 MinGW,效果很好。我拥有像 gettimeofday() 这样的额外功能的所有函数原型,并且像 tanf() 这样的所有常规功能仍然工作正常。

ps: Visual Studio 甚至有一个“使用输出窗口”按钮,它可以很好地转储任何内容由“arm-none-linux-gnueabi-g++”生成的错误

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++"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文