Tag Info

Hot answers tagged

38

You can try this PPA for installing gcc 4.7. Do note that it has packages only for 12.04 and not for 11.10. Run the following commands in a terminal: sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-4.7 Or, if you prefer a graphical way of installing a PPA, take a look at What are PPAs and how do I use ...


28

First erased the current update-alternatives setup for gcc and g++: sudo update-alternatives --remove-all gcc sudo update-alternatives --remove-all g++ Install Packages It seems that both gcc-4.3 and gcc-4.4 are installed after install build-essential. However, we can explicitly install the following packages: sudo apt-get install gcc-4.3 gcc-4.4 ...


16

Ubuntu provides the standard Gnu Compiler Collection in the repositories. You can install the Gnu C Compiler gcc as well as the Gnu C++ compiler g++ with the following command: sudo apt-get install gcc g++ You'll probably also want to install libc6-dev (which includes the C standard library) and libstdc++6-4.5-dev (which includes the standard C++ ...


13

Is GCC-4.8 available for 12.04 Precise now? The short answer is: gcc-4.8 is currently available for 12.04(Precise) only by compiling the source(see below for details). Update: As of 4/13/2013, there is currently a dev release of gcc 4.8 for 12.04(precise) available at https://launchpad.net/~ubuntu-toolchain-r/+archive/test. One can install .deb files ...


12

A segmentation fault occurs when a program tries to access memory outside of the area that has been allocated for it. In this case, an experienced C programmer can see that the problem is happening in the line where sprintf is called. But if you can't tell where your segmentation fault is occurring, or if you don't want to bother reading through the code to ...


11

12.04 Add the toolchain ppa test repository, then do apt-get update, and apt-get dist-upgrade sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install g++-4.7 c++-4.7 This is only available in 12.04 - older ubuntu versions cannot be updated to this same version using this method. See here for further information about ...


10

Since you're running an executable in the current working directory, you should prefix it with ./. So for your program run it as ./a.out. Explanation The terminal searches for executables in $PATH. This is a Unix environment variable that lists directories containing system binaries (such as ls, echo, or gcc). If you call an executable that's not in a ...


10

I have created a PPA that contains a build of GCC 4.7 for Precise here: ppa:george-edison55/gcc4.7-precise (Click here for instructions on using PPAs.) To backport a package from one release to another is a relatively simple process assuming you have a Launchpad account and have registered your GPG key there. Make sure you have the ubuntu-dev-tools ...


9

Hello buffer overflow! char *s=""; sprintf(s,"%d",curr); length=strlen(s); You allocate one byte for a string on the stack and then proceed to write more than one byte to it. And to top it off, you read beyond the end of that array. Please read a C manual and especially the section on strings and allocating memory for them.


9

Even very new versions of GCC fail with that message. It's because the new Debian/Ubuntu releases (will) support multiarch (i.e. installing binaries for multiple machines in one file-system), so the libraries have been moved away from the standard places. There are GCC patches to fix it here (not yet approved final versions, but correct for Ubuntu), and ...


9

When you compile a binary, say, nginx from source code, it's built with information regarding what versions of the libraries are on the system that is compiling the binaries. The libraries to reference of course are determined by the arguments (for nginx, that's the definition of which modules you want activated or not). But that binary which you built ...


7

There's a metapackage called build-essential which should install the compiler and a bunch of related/needed packages: sudo apt-get install build-essential The suggestion to first do sudo apt-get update is sound, this will update package lists and all versions should match nicely. That is, however, if you didn't modify your /etc/apt/sources.list file ...


6

conio.h is a library that is windows specific. To my knowledge it comes with mingw32, a compiler that is a windows port of gcc. Try to set up your code so that it doesn't use it. Also, note that linux uses (99% of the time) the gnu standard library (gnulibc). You can find its content here For input/output you'd need the iostream (not iostream.h) header ...


6

If a package supports it you can use the -j flag to allow parallel jobs running, e.g.: make -j8 More details on this flag can be found in the Stackoverflow question Why does make -j perform better when it is passed a number larger than the number of cores available?. Distributed compilation If you have multiple machines, give distcc a go. On the ...


6

When you run commands on Linux it searches all the directories listed in the PATH environment variable, and if it doesn't find the command there then you get the message you've seen. Typically it looks like this: PATH=/usr/local/bin:/usr/bin:/bin That means it will look first in /usr/local/bin. If it doesn't find it there it'll look in /usr/bin, and so ...


5

ia32-libs just contains some compatibility libraries haven't been migrated yet to Multi Arch. For compiling 32-bit libraries, you need to install the 32-bit libraries and development files for C: sudo apt-get install libc6-dev:i386 See also: Does the multiarch feature in 11.10 mean the death of force--architecture installs?


5

on ubuntu: install ncurses library (packages for developers has "-dev" postfix) sudo apt-get install libncurses5-dev for each package, in /usr/share/doc/{package name}/ you can find documentation. Open this URL file:///usr/share/doc/libncurses5-dev/html/index.html in your browser. Have fun.


5

You can use debian snapshots. Add the following lines to /etc/apt/sources.list deb http://snapshot.debian.org/archive/debian/20070730T000000Z/ lenny main deb-src http://snapshot.debian.org/archive/debian/20070730T000000Z/ lenny main deb http://snapshot.debian.org/archive/debian-security/20070730T000000Z/ lenny/updates main deb-src ...


5

execute in terminal : gcc -v g++ -v Okay, so that part is fairly simple. The tricky part is that when you issue the command GCC it is actually a sybolic link to which ever version of GCC you are using. What this means is we can create a symbolic link from GCC to whichever version of GCC we want. You can see the symbolic link : ls -la /usr/bin | grep ...


5

You might have trouble compiling new kernels with very old versions of GCC. Besides that, no, GCC versions are not tied to the Linux kernel's version: You can run an ancient GCC version on a system with a new kernel. You can run a new GCC version on a system with a very old kernel. The only thing that would stop you from doing this would be if your new ...


4

I looked at your video and saw the problem in your program source. The reason you are getting this error is because you are using: #include <stdio> #include <stdlib> You should be using: #include <stdio.h> #include <stdlib.h> ..use these corrections in your program and it should now compile.


4

If you do not have SVN install it with sudo apt-get install svn Then run the following command and it will download the source for gcc 4.1.2 into a subdirectory of the current working directory. svn co svn://gcc.gnu.org/svn/gcc/tags/gcc_4_1_2_release gcc Then follow the official gcc build guide


4

You are getting the warning because you are using the wrong format specifier in printf(). p is an integer-pointer. &p is the address of a pointer. &x and &y are addresses of integers. These are all addresses in memory, not values of a variable. The specifier %u is for values of unsigned integers. So you are printing apples where the compiler ...


4

I'm by no means an expert on the subject, but hopefully I can point you in the right direction. As far as IDEs go, there is a GNU ARM plugin for the Eclipse IDE. It is a Manged Build Extension that supports a number of GNU ARM Toolchains like CodeSourcery G++ Lite, GNUARM, WinARM, Yagarto, devkitPro. Outside of an IDE, you could consider running a QEMU ARM ...


4

A simple #define seems to be all that is needed.. (the program writes past 2 GB now.) Perhaps the reason it didn't compile apppropriately, is that I compiled a single program from a much larger suite ('xxd' is part of 'vim')... Had I compiled 'vim' in toto, it would most likely have worked fine... So for anyone who comes to this page, the following ...


4

Or alternatively to the Debian snapshots Elazar posted in his answer, you can use the Ubuntu package repositories for the older Ubuntu releases: http://packages.ubuntu.com Add them to the /etc/apt/sources.list as Elazar already described: deb http://archive.ubuntu.com/ubuntu/ hardy universe deb-src http://archive.ubuntu.com/ubuntu/ hardy universe The ...


4

sudo apt-get install gcc-snapshot Then, invoke it with: /usr/lib/gcc-snapshot/bin/gcc For the second part of the question, the answer is "yes, sort of". If you really want to do that (i.e. installing the gcc-snapshot package isn't enough) then you'll need to install the dependencies: sudo apt-get build-dep gcc-snapshot Then, find the correct ...


4

LDFLAGS should include -m32 as well. Following should work: export LDFLAGS='-m32 -L/usr/lib32' In fact, you can drop -L/usr/lib32 part, since this is a default directory for 32bit libs, and your system is aware about that. Basically, the simplest way to build 32bit application on 64bit machine is: export CFLAGS='-m32' export CXXFLAGS='-m32' export ...


4

Ok, solved. Apparently, for some mysterious reason, the order of the gcc options now matters. So when I do: gcc -I /usr/include/SDL -o test test.cpp -lSDL (moved the -lSDL option to the end) everthing works just fine. I'd love to know why it suddenly matters, when before if did not, but for now I'm happy that stuff works again.



Only top voted, non community-wiki answers of a minimum length are eligible