Hot answers tagged

25

At a command prompt, type cat /proc/cpuinfo to view CPU information. The ARM11 chips use version 6 of the ARM instruction set, ARMv6. More recent chips from the ARM Cortex range like the Cortex A7, A8 etc all use the ARMv7 instruction set. All Pi boards are shipped with an ARM11. The options on the second line look like a better fit for building ...


20

Checking at configure/compile time for the features your code depends upon is the way to go. Checking for specific devices is problematic because avoiding false-positives is virtually impossible (someone could lie to you deliberately even with little effort) and the aim of such checks is to answer the question: "can I build here? If yes what code path should ...


19

I am eager to get compiling and I would like to use the latest and the best tools. In fact, the latest and best tools do not need to be built by yourself. On the Raspberry Pi Tool GitHub Repository you will find the X86_64 and x686 toolchains for cross-compiling software. I recommend using the x86-linux64-cross-arm-linux-hardfp toolchain, as that will ...


13

Do NOT use nano (or another text editor to put your code into) with root/sudo permissions (ie. do not edit with sudo nano, only use nano) if all you are doing is personal stuff that does not need superuser permissions. Answer To compile from the command line (assuming yourcode.c is the name of your C file, and program the name of the resulting program ...


9

That may depend on your distro, but if you are using raspbian, the stock gcc includes g++, here's the version info: me@RPi» gcc -v Using built-in specs. [...] --enable-languages=c,c++,fortran,objc,obj-c++ So apt-get install gcc should work if it isn't already there. Most distros will build gcc with C++ support, so this should be true for them too. The ...


8

In 2015-02-16-raspbian-wheezy is gcc-4.8 already as package (4.8.2), but not default. You can install it apt-get install gcc-4.8 g++-4.8 and then change the links in /usr/bin/


6

The documentation for GCC is actually contained in its own package1, gcc-doc. Just run: sudo apt-get install gcc-doc and then man gcc will work as expected. Note that your attempt, sudo apt-get --reinstall install man gcc asks apt-get to try and install two packages, man and gcc. man doesn't exist as a package in the repositories, and gcc will just be ...


5

To install development tools on raspbian : sudo apt-get install build-essential


4

Note that when building the toolchain using ct-ng on centos 6.3 on a 64 bit system I was forced to deselect the option to statically link libstdc++ because static linking was not supported on the platform (apparently). Also, while it would be great to use the prebuilt toolchain from the git repository, that chain does not seem to work on Centos 6.3 - ...


4

As long as your Raspberry Pi is up to date, then you can just download and patch GCC 4.8 to run on you Raspberry Pi. Download GCC sources $ wget ftp://ftp.fu-berlin.de/unix/languages/gcc/snapshots/LATEST-4.8/*.bz2 Extract sources $ tar xf gcc-4.8-20120826.tar.bz2 Patch sources We need to get and apply two debian specific patches for GCC: $ wget http://...


4

The problem is in Putty not the Pi. To fix the problem: Load the stored profile for the Pi (I assume you have saved you connection details). Open Putty Configuration. From the left side menu click Translation from the Window section. In the Remote character set dropdown select UTF-8. Make sure that Use Unicode line drawing code points is selected. Save the ...


3

The gcc documentation explains this in detail. Basically, you can tell the compiler to forcibly use armv6: gcc -march=armv6 -c foo.c -o foo.o You can also let gcc try to autodetect the current architecture: gcc -march=native -c foo.c -o foo.o


3

There's a gotcha here created by the lack of specificity with ARM cross-compilers. ARM actually refers to a family or series of instruction sets which are not necessarily compatible with one another. Currently, by far the most common ARM architecture is ARMv7. This is widely used in mobile devices such as smartphones (including Apple's) and low-power ...


3

Compiling C programs on the raspberry pi is rather simple. First, create your program in a text editor and save it as <insert name>.c It should be saved on the Desktop. Next, open terminal. In it type: cd Desktop This changes the directory that the terminal is looking at to Desktop. This is also where our program is stored. gcc -Wall <myName>....


3

Like @okertanov said, your code has syntax errors. In C, comments must be enclosed /* like this */, strings for printf "have to be in quotes", and newlines are printed with \n inside the quotes. Try something like this: #include <stdio.h> #include <stdlib.h> #include <signal.h> #include <wiringPi.h> #include <softPwm.h&#...


3

This guide may be helpful. It helped me get mine going. I added some comments about tuning as well.


3

In case you are going to cross-compile from the OS X : here is the great article (and the only one working on the web I found). The greatest thing is author provides a complete precompiled toolchain, so you only need to download, unzip and mount dmg image. And thats it, you are ready to cross-compile.


3

If you want to benefit from a fast host for compiling things for your RPI I suggest to work in cross environment via chroot and QEMU. This by the way supersedes a cross compiler with no hassle. Simply setup a Debian cross-environment using deboostrap/multistrap (see chapter QEMU/debootstrap approach) and you are done.


3

You made a mistake in your command. It should be: sudo apt-get install gcc-4.9 g++-4.9


3

The default version of the GCC are as follows: Raspbian Stretch: GCC 6.3.0 Raspbian Jessie: GCC 4.9.2 (GCC 4.8.4 available) Raspbian Wheezy: GCC 4.6.3 (GCC 4.4.7 and 4.7.2 available) g++ always gets the same version number as GCC, since it is part of the same software project.


3

The -o option to gcc specifies the name to be given to the executable. You are saying name the executable as the input source code. That is almost certainly an error.


2

If you installed Ubuntu 64 bits edition and the tools from Raspberry Pi SVN and you are getting the error: -bash: /home/I/toolchain/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-c++: No such file or directory just run: sudo apt-get install ia32-libs


2

It's in the Raspbian repository, so you can install it with sudo apt-get install liblinux-inotify2-perl Bringing in modules from CPAN can affect the stability of a Debian distribution (they have conflicting policies on file modifications), so I don't recommend it unless you absolutely have to.


2

gcc-4.6 is the default compiler in Debian 6.0; Raspian is a port of Debian 6.0. It is not the only version available, though. You can install different versions, including 4.7 with apt-get install gcc-4.7. Now, you said that CPAN modules are compiled with the same version perl was compiled with. It is very possible that perl on Raspbian was compiled with ...


2

to make linking work you'll need to run ldconfig $ sudo ldconfig (oh well already in comments above. didn't see that until post)


2

This question is a Unix question, not a Raspberry Pi specific question. The answer you are looking for is here: https://unix.stackexchange.com/questions/13192/what-is-the-difference-between-a-and-so-file. You could have found this easily if you would have googled (3rd hit on the search "what are .so files in linux")


2

My interpretation of the Cortex-A7 MPCore ™ is that there is an FPU per core. In particular section 1.5 of the Technical Reference Manual says the FPU can be configured per core but goes on to say that if the core has NEON the core has an FPU. I believe all the cores have NEON so all have an FPU. http://infocenter.arm.com/help/topic/com.arm.doc.ddi0464f/...


2

If you suspect a hardware problem, try running cpu and RAM tests to confirm it: sudo apt-get install memtester memtester I would probably run fsck as well, even though filesystem errors resulting in segfaults are unlikely. Finally, I would assume that the bug is specific to the compiler and try to install a different version of gcc.


2

So I figured it out. I just grabbed the crossbuild version of gcc (I think that is what it is) sudo apt-get install crossbuild-essential-armhf And then my new path is: export CCPREFIX=/usr/bin/arm-linux-gnueabihf- And the build works perfectly!


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