I'm trying to run a C program in Linux Mint 15, but without success.
Here is my code:
#include<stdio.h>
#include<conio.h>
int main()
{
printf("Hello World");
}
I compile with gcc:
gcc -o hw hw.c
But, I get the following error:
hw.c:1:18: fatal error: stdio.h: No such file or directory
compilation terminated.
I researched the problem and found some solutions that say to install build-essential, so I did:
sudo apt-get install build-essential
But I get the following error:
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
build-essential : Depends: libc6-dev but it is not going to be installed or
libc-dev
Depends: g++ (>= 4:4.4.3) but it is not going to be installed
Depends: dpkg-dev (>= 1.13.5) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
How do I resolve this and make my program run correctly?
EDIT:
The result of locate stdio.h is:
/usr/lib/perl/5.14.2/CORE/nostdio.h
/usr/lib/syslinux/com32/include/stdio.h
I was having the same problem, and simply installed the g++ package and that fixed the missing include file.
sudo apt-get install g++
The package name for the C standard library is libc6. Its header files are in the development package: libc6-dev. Some Linux distributions do not have the development package installed. You need to install it yourself:
sudo apt-get install libc6-dev
Why the installation of build-essentials does not resolve the dependencies I don't know. But I think the question wasn't about the installation of build-essentials and maybe it isn't needed at all.
References:
https://packages.debian.org/en/sid/libc6
https://www.debian.org/doc/debian-policy/ch-sharedlibs.html#s-sharedlibs-dev
https://en.wikipedia.org/wiki/GNU_C_Library#A_temporary_fork
I had this situation before:
rleclerc#fvrwbp01:~# gcc -o tokens tokens.c
tokens.c:1:19: fatal error: stdio.h: No such file or directory
compilation terminated.
You wrote:
sudo apt-get install build-essintial
There's a typo. Try this instead (I guess you already did something similar):
sudo apt-get install --no-install-recommends gcc
and:
sudo apt-get install --no-install-recommends build-essential
Sometimes, proof-reading makes some difference:
The following NEW packages will be installed:
build-essential dpkg-dev g++ g++-4.7 libc-dev-bin libc6-dev libdpkg-perl libstdc++6-4.7-dev libtimedate-perl linux-libc-dev make
(...)
This fixed the error.
FWIW, Mint 17 just needs build-essential to compile C programs:
# apt-get install build-essential
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
dpkg-dev g++ g++-4.8 libc-dev-bin libc6-dev libstdc++-4.8-dev
Suggested packages:
debian-keyring g++-multilib g++-4.8-multilib gcc-4.8-doc libstdc++6-4.8-dbg
glibc-doc libstdc++-4.8-doc
Recommended packages:
libalgorithm-merge-perl
The following NEW packages will be installed:
build-essential dpkg-dev g++ g++-4.8 libc-dev-bin libc6-dev
libstdc++-4.8-dev
0 upgraded, 7 newly installed, 0 to remove and 1 not upgraded.
This problem may come when you are trying from wrong directory...
I suggest you to check for directory.
Update the OS by: sudo apt-get update.
The final option is to remove the exixting gcc compiler and install the new one.
You can also try this:
g++ -o [fileName] [executable name]
Related
This is the command I used to install python-pip
sudo apt-get install python-pip
I get the following error
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
python-pip : Depends: python-setuptools (>= 0.6c1) but it is not going to be installed
Recommends: python-dev-all (>= 2.6) but it is not installable
E: Unable to correct problems, you have held broken packages.
I already installed the latest version of python-dev
When i try to install python-setuptools using
sudo apt-get install python-setuptools I get the below error
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
python-setuptools : Depends: python-pkg-resources (= 3.3-1ubuntu1) but 3.3-1ubuntu2 is to be installed
E: Unable to correct problems, you have held broken packages.
Explain me how to resolve the error and guide me the steps to get python-pip installed.
got the same error when I install python-pip, the following command solved my problem.
sudo apt-get install python-pkg-resources=3.3-1ubuntu1
sudo apt-get install python-setuptools
download pip from https://bootstrap.pypa.io/get-pip.py
Then run the following (which may require administrator access):
python get-pip.py
This should get you going.
If you get stuck again, read here: http://pip.readthedocs.org/en/stable/installing/
In addition to the solution that #seems recommended, I had to run this.
apt-get update
(OR)
sudo apt-get install python-setuptools python-dev build-essential
sudo easy_install pip
i have the same issue, and eventually i gave up by using:
sudo apt-get install python-pip
after tryings something like:
sudo apt-get install python-setuptools python-dev build-essential
but with no luck.
So all i did then was to:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
peace of mind.....
I think you should try:
sudo apt-get install python-pkg-resources=3.3-1ubuntu1
And then:
sudo apt-get install python-pip python-dev build-essential
It will definitely solve your issue.
Jut run this command :
sudo apt-get update
than install python tools :
sudo apt-get install python-pip
sudo apt-get install python-dev
sudo apt-get install build-essential
All the packages will get installed or some of them may say its already latest version, Thats fine
I cannot install g++ on newly installed ubuntu 14.04.4 LTS.
When I use command sudo apt-get install g++, the terminal tell me:
cluster#cluster0-vm:~$ sudo apt-get install g++
[sudo] password for cluster:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
g++ : Depends: g++-4.8 (>= 4.8.2-5~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
I changed the source, and tried again, failed too.
cluster#cluster0-vm:~$ sudo apt-get install g++
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
g++:i386 : Depends: cpp:i386 (>= 4:4.7.3-1ubuntu10) but it is not going to be installed
Depends: gcc:i386 (>= 4:4.7.3-1ubuntu10) but it is not going to be installed
Depends: g++-4.7:i386 (>= 4.7.3-1~) but it is not going to be installed
Depends: gcc-4.7:i386 (>= 4.7.3-1~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
I used the ubuntu software center to install g++, failed again......
Figure: Use ubuntu software center to install g++
This problem has been solved by changing another source.
I have tried 4 sources, and all of them have problems......OMG!
I think this will help:
sudo apt-get update
sudo apt-get -f install
sudo dpkg --configure -a
sudo apt-get clean
sudo apt-get install g++
Also this could help:
sudo dpkg --purge g++# Try this first
sudo dpkg --purge --force-depends g++# Try this ONLY if the previous line fails
sudo apt-get clean g++# Remove g++ from the cache
sudo apt-get install g++# Download and install the appropriate version of g++
If I had to guess, I would say there are other libc6, libc-dev, etc..files that need updating before you can update the C's and G's.
It seems that if you install build essentials then it will correct the problem.
If you look up the files on the ubuntu packages site and look at the dependencies, then compare them to what is on your machine, I bet you find you have an update conflict due to incompatible dependency version somewhere.
You could manually download them individually at the bottom of the repository page (a small table) then double click the deb files and they will start to install if all of the dependencies and versions are met and compatible.
Think of it as "A depends on B which depends on C which depends on D......" being installed. to some infinity no avail. Its a nightmare when doing it that way. But does force you to respect Synaptic and the apt-get thorough and detailed process and compatibility check.
Best to start with build essentials though.
I've been attempting to install the package r-base on Ubuntu Trusty Tahr and there's a package dependency that became broken in the last week.
My commands are as follows:
apt-get update -y
apt-get dist-upgrade -y
apt-get install -y r-base-dev
...
Err http://archive.ubuntu.com/ubuntu/ trusty-security/main libpng12-dev amd64 1.2.50-1ubuntu2.14.04.1
404 Not Found [IP: 91.189.91.23 80]
Fetched 92.8 MB in 28s (3262 kB/s)
E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/libp/libpng/libpng12-dev_1.2.50-1ubuntu2.14.04.1_amd64.deb 404 Not Found [IP: 91.189.91.23 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
The command '/bin/sh -c sudo apt-get install -y r-base-dev' returned a non-zero code: 100
I have attempted to pass --fix-missing and --ignore-missing but it still fails.
It appears that the package was removed on Jan 8, 2016 due to a security patch: https://launchpad.net/ubuntu/+archive/primary/+sourcepub/5711916/+listing-archive-extra
Looking at http://archive.ubuntu.com/ubuntu/pool/main/libp/libpng/ confirms that the ubuntu2.14.04.1 file is not there but 1.2.50-1ubuntu2.14.04.2 is present.
How do I fix that?
My goal is to get r-base to install.
If I could somehow make it use the version "2" file instead of "1" it would presumably find the file and proceed happily, but I'm not sure how to make apt-get do that.
Alternatively, maybe it's possible to update the dependency list on my side? Or is it up to the r-base maintainers to do so?
Or third, is it possible to add a repository that still has the old package? I'm not running on an AMD processor, so I shouldn't need this particular package at runtime anyway.
Update:
The solution that worked for me was to explicitly remove the package with the broken dependency, download the updated version, and re-install it before running apt-get update.
$ apt-get remove -y libpng12-0
$ curl -O http://archive.ubuntu.com/ubuntu/pool/main/libp/libpng/libpng12-0_1.2.50-1ubuntu2.14.04.2_amd64.deb
$ dpkg -i libpng12-0_1.2.50-1ubuntu2.14.04.2_amd64.deb
$ apt-get update -y
The problem apparently doesn't have much to do with the r-base or r-base-dev packages, even though r-base-dev incidentally depends on libpng12.
In my opinion this problem will probably fix itself in a couple of days. However if you can't wait, here's what you can do.
First, find out which version of libpng the package you want to install depends on.
$ apt-cache depends r-base
r-base
Depends: r-base-core
Depends: r-recommended
Recommends: r-base-html
Recommends: r-doc-html
Suggests: ess
|Suggests: r-doc-info
Suggests: r-doc-pdf
r-base itself does not depend on libpng but r-base-core probably does.
$ apt-cache depends r-base-core | grep png
Depends: libpng12-0
Now we want to know which specific version of libpng
$ apt-cache show r-base-core
... libpng12-0 (>= 1.2.13-4) ...
If you locate this package in Ubuntu's repositories, you can
download it and try to install it manually.
$ wget <url>
$ sudo dpkg -i <filename>
and then install r-base with apt-get install r-base. However if dpkg
refuses to install libpng you should not force it, because it means the
package is not installable and it would break other dependencies.
How to install build-essential in Cygwin?
I've tried using: apt-cyg install build-essential
But does not work.
Installing build-essential
Package build-essential not found or ambiguous name, exiting
I'm also having problems like:
(gedit: 13864): Gtk-WARNING **: can not open display:
So I can not install crunch.
See It:
$ make all
Building binary...
/usr/bin/gcc -pthread -Wall -pedantic -std=c99 undefined crunch.c -lm -o crunch
gcc: error: undefined: No such file or directory
Makefile:48: recipe for target 'crunch' failed
make: *** [crunch] Error 1
What's the problem here, and how can I fix it?
There isn't a build-essential package in Cygwin.
Build-essential is a collection of packages. So you'll have to select the packages manually, which I believe are the following:
make
automake
gcc
gcc-c++
Assuming you're doing development, you'll want to select those packages from the Devel branch. This is done when you first install Cygwin and the installer asks you to select the packages, after choosing the download site from the list.
As for the Gtk-WARNING **: can not open display: error, this is because your system is not running Cygwin's X11 display server, which provides a surface for graphical applications to render to. Check out http://x.cygwin.com/.
If you want to run gedit in Windows, you should get the binary for windows here. That's built for Windows and doesn't need Cygwin.
EDIT: Running sudo apt-get install build-essential on Elementary OS Freya mentions the following dependencies will be installed as well, so you'll probably want that for a 'closer-to-Linux' build environment as well.
The following extra packages will be installed:
g++
g++-4.8
libstdc++-4.8-dev
Suggested packages:
g++-multilib
g++-4.8-multilib
gcc-4.8-doc
libstdc++6-4.8-dbg
libstdc++-4.8-doc
The following NEW packages will be installed:
build-essential
g++
g++-4.8
libstdc++-4.8-dev
The list of files installed can be found here
and the contents of the file list (current as of 4/24/2014) can be found in this PasteBin I made.
build-essential is an abstract package, short for its dependencies:
dpkg-dev
binutils
bzip2
libdpkg-perl
make
patch
perl
tar
xz-utils
g++
gcc
libc6-dev
make
So in Cygwin, it is the same to install their substitutes:
apt-cyg install make gcc-core gcc-g++ patch bzip2 perl tar xz
make and gcc-g++ (g++), which depends on gcc-core (gcc), are the most important.
If you really want to compile various projects in Cygwin, packages below may be also helpful. Be careful, libboost-devel is very large.
apt-cyg install git automake cmake python3-devel libboost-devel
I had recently installed ubuntu 13.04 and I'm a new linux user but I am unable to compile g++ code.
It says
The program 'g++' can be found in the following packages:
* g++
* pentium-builder
Try: sudo apt-get install <selected package>
When I tried to install g++ using following statements
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-4.8
It says:
The following packages have unmet dependencies:
g++-4.8 : Depends: gcc-4.8 (= 4.8.1-2ubuntu1~13.04) but it is not going to be installed
Depends: libcloog-isl4 (>= 0.17) but it is not installable
Depends: libisl10 (>= 0.10) but it is not installable
E: Unable to correct problems, you have held broken packages.
Will appreciate your help.
For Ubuntu, the easiest way to get all the build tools including g++ is to
sudo apt-get install build-essential
I suggest you check AskUbuntu for more info.
You just do try "sudo apt-get install g++" in the command line?
so package manager will try to install missing package. Do not request specific version and You will be fine! It fails just because of specific version requirement.