Eclipse C/C++ (CDT) 添加 -l 选项(链接数学模块) gcc -lm

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8480013/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 17:26:29  来源:igfitidea点击:

Eclipse C/C++ (CDT) add -l option (linking math module) gcc -lm

ceclipsegcclinkereclipse-cdt

提问by eat_a_lemon

I am trying to have eclipse on linux (Ubuntu) link the math module. Normally I would link with gcc -lm. How do I get eclipse to add this? Is it in library paths under Project->Properties? Where does the math module reside on a linux Ubuntu system?

我正在尝试在 linux (Ubuntu) 上使用 eclipse 链接数学模块。通常我会与 gcc -lm 链接。我如何让 eclipse 添加这个?是否在项目-> 属性下的库路径中?数学模块在 linux Ubuntu 系统上的什么位置?

回答by Ioan

Somewhere along this path: Project->Properties->C/C++ Build->Settings, then under the Tools tab: GCC Linker->Libraries

沿着这条路的某处:项目->属性->C/C++构建->设置,然后在工具选项卡下:GCC链接器->库

As for where it is in the system, usually /usr/lib/libm.so.

至于它在系统中的哪个位置,通常是/usr/lib/libm.so。

FYI, this is all true of my system, but may differ slightly on yours for any number of reasons. Shouldn't be hard to adjust if needed.

仅供参考,这对我的系统来说都是正确的,但由于多种原因,您的系统可能略有不同。如果需要,应该不难调整。

回答by wSmit

Go to Projectand select Properties. Expand C/C++ Buildand choose Settings. Under the Tool settingstab expand GCC Linkerand select Libraries. At the right of the window, add a library named mat Libraries (-l).

转到Project并选择Properties。展开C/C++ Build并选择Settings。在Tool settings选项卡下展开GCC Linker并选择Libraries。在窗口右侧,在Libraries (-l)处添加名为m