简体   繁体   English

在Ubuntu上编译C程序的问题

[英]Problems with Compiling C program on Ubuntu

I am using Ubuntu 10.10 as VM and am new to it. 我使用Ubuntu 10.10作为VM并且是新手。 Until recently i could easily compile C programs from the terminal. 直到最近,我才能从终端轻松编译C程序。 However, as i try to compile them now it gives a message as: 但是,当我尝试编译它们时,它会给出一条消息:

/usr/bin/ld: cannot find -lc 
collect2: ld returned 1 exit status

I have searched for it over the net but could not figure out what is going wrong. 我已经通过网络搜索了它,但无法弄清楚出了什么问题。 I know the answer to it must be simple but any help would be appreciated. 我知道它的答案必须简单,但任何帮助将不胜感激。 Thanks! 谢谢!

Installing the necessary tools should solve your problem. 安装必要的工具应该可以解决您的问题。 Try: 尝试:

sudo apt-get install build-essential

You probably -- most of us do -- installed Ubuntu desktop, but not Ubuntu server. 您可能 - 我们大多数人都这样做 - 安装了Ubuntu桌面,但没有安装Ubuntu服务器。 A whole lot of tools don't come over with a default Ubuntu desktop installation. 使用默认的Ubuntu桌面安装时,很多工具都没有。

So start by installing build-essential: 首先安装build-essential:

sudo apt-get install -y build-essential

Then try the compile again. 然后再次尝试编译。 build-essential contains a bunch of components that you need to perform a basic compile. build-essential包含执行基本编译所需的一组组件。

For my work, beyond build-essential, I have to install other libraries like curses. 对于我的工作,除了build-essential之外,我还必须安装其他库,比如curses。 However, I first have to have build-essential installed before I can do anything else. 但是,在我可以做任何其他事情之前,我首先必须安装build-essential。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM