在 g++ 中找不到 -lc 和 -lm操作系统
我正在使用 Ubuntu,gcc 和 g++ 工作正常,但今天它显示:
cannot find -lm
cannot find -lc
我搜索并发现它与 /usr/bin/ld
有关。这是一个指向 lbd.bdf 的符号链接(我希望如此)。我将该文件粘贴到一些朋友 PC 的 Ubuntu 目录中。它不起作用。
我发现-lc
表示包含静态库libc.a。
类似地,对于 -lm
我在我的 i386-linux-folders
中找到了它们(名称有所不同)。
我尝试了代码块,但出现同样的错误。
I am using Ubuntu and gcc and g++ were working fine but today it showed:
cannot find -lm
cannot find -lc
I searched and found it has something to do with /usr/bin/ld
. Which is a symlink (I hope) to lbd.bdf
. I pasted that file in the directory from Ubuntu of some friends PC. It didn't work.
I found that -lc
means include static library libc.a.
similarly for -lm
I found them in my i386-linux-folders
(name was something different).
I tried code blocks but same errors.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
编译器找不到静态 glibc,您可能只安装了共享库,请尝试:
yum install glibc-static
The compiler cannot find static glibc, you might have installed only the shared libraries, try:
yum install glibc-static
确保您的 libpath(在 g++ 中)指向 libm.a 和 libc.a 所在的目录(使用 -L 选项)
make sure that your libpath (in g++) points to the directory(ies) that libm.a and libc.a are located in (use the -L option)
ld
是 GNU 链接器。男人ld
ld 组合了许多目标文件和归档文件,重新定位它们的数据并绑定符号引用。通常编译程序的最后一步是运行 ld。
它用于将您的程序与 C 库和 C 数学库链接。您需要确保安装了
libc6-dev
:或者更通用的是,确保
build-essential
,它依赖于一些基本的C包。ld
is the GNU linker.man ld
ld combines a number of object and archive files, relocates their data and ties up symbol references. Usually the last step in compiling a program is to run ld.
It is uses to link your program with the C library and the C math library. You need to make sure that
libc6-dev
is installed:Or more generic, ensure
build-essential
, which depends on a handful of essential C packages.