GCC installed on ubuntu 14.04, but no toolchain visible on eclipse? - c

So itś my first time using eclipse in ubuntu and I seem to have problems with setting up GCC as the toolchain. I expect the toolchains to work with a standard HelloWorld example, but they don't (after building the project of course).
I get the following error:
When adding the new project, I only have a choice between these toolchains:
When unmarking ¨Show project types and toolchains only if...¨, I do get the GCC toolchain in the list, but that doesn´t seem right (and is also not working).

Related

How to set up OpenMP?

I am using Codeblocks and have to run an OpenMP C program. So, I added the flag -fopenmp in Codeblocks (compiler settings) and am now getting the error of 'mingw32-g++.exe: error: libgomp.spec: No such file or directory'
So after a bit of searching on the internet about the error, I downloaded TDM-GCC ( installed in C:\TDM-GCC-64). But still the same error is being shown on Codeblocks.
What am I doing wrong?
Here is the build log:
mingw32-gcc.exe -c "D:\Language Files\MatrixMultiplication.c" -o "D:\Language Files\MatrixMultiplication.o"
mingw32-g++.exe -o "D:\Language Files\MatrixMultiplication.exe" "D:\Language Files\MatrixMultiplication.o" -fopenmp
mingw32-g++.exe: error: libgomp.spec: No such file or directory
There are multiple possible causes for this: Either you did not install OpenMP with the compiler or you made a mistake in the Code::Blocks configuration. Anyways go through the following steps and you should be able to fix it. You seem to be working on Windows but I also added remarks on how to do it on Linux.
1) You will need a compiler that comes with OpenMP. For Windows download TDM-GCC preferably the 64-bit executable (second file) and install it. Make sure you select OpenMP in the component tab: Components > gcc (TDM current: ....) > OpenMP (the last entry). Linux already comes with GCC so just open the command line and get yourself OpenMP by typing sudo apt-get install libomp-dev in the terminal.
2) You will have to configure the Compiler in Code::Blocks now: Go to Settings > Compiler under Selected Compiler select GNU GCC Compiler and click Copy and type in a convenient name for your new compiler such as TDM-GCC Compiler. Go to Toolchain executables and browse the directory for all the Program files (C compiler, C++ compiler, Linkers, Debugger, Resource compiler, Make) you should be able to find them in C:\TDM-GCC-64\ ...\bin on a Windows machine if you chose the default installation. I can't tell you the precise sub-directory as I working on a Linux machine but you should be able to find it pretty easily. Depending on your installation there might be two folders for 32- and 64-bit. For Linux this step is not necessary.
4) Then you need to set the Linker settings. This can be done for all projects (which I would not recommend) by doing the following steps in the aforementioned menu or for your current project by clicking Project > Build options. Go to Linker settings of the corresponding configuration (Debug or Release) and click Add under Link libraries. On a Windows machine you will need to browse a file called libgomp-1.dll (32-bit) or libgomp_64-1.dll (64-bit) which should be located in the same folder as the aforementioned Program files. Under Linux instead choose -lgomp under Other linker options.
3) Set the compiler flag -fopenmp (for all the projects or only the current one) by going to Compiler settings > Other compiler options and typing in there -fopenmp.
4) Test it with a program like the OpenMP "Hello World".

OpenMP support on OSX 10.11, gcc errors with "file omp.h not found"

I have been using gcc version 5.3.0. It says that it comes with openmp support. But every time when I compile a program using either gcc [by terminal] or via xCode 7, I get same error, "file omp.h not found". I have searched too much on this issue and tried almost everything I found.
First I tried to locate omp.h on my mac. I found some files; then in header file, I used that specific location of omp.h but no help [it gave me linker error].
I installed gcc version 6.0 (pre-release) but no help. I tried changing C_INCLUDE_PATH [which is now, and previously set to none] but that didn't helped me as well.
I reinstalled clang-omp but no help.
I am using llvm compiler version 7.0. Although i have installed clang-omp, there is no omp.h in my /usr/include/*
I changed the compiler and now I am able to run it. [It was issue of clang, which I couldn't solve].
I am a student and Intel is giving Intel Parallel Studio 1 year licence for free to students.
So I downloaded, and installed it.
In xCode, under build settings, I set my compiler to 'Intel C/C++ compiler' and in parallalization, I turned it to 'yes'. That was it. Then it compiled successfully. But, note that you won't be using header file 'omp.h' anymore.
By the way, I am still looking for answers, just to know what I was doing wrong.
You can install 'clang-omp' or 'gcc' (corresponds to GCC 5.3 right now) packages via Homebrew, both of which support OpenMP.
The built in GCC is based upon GCC 4.2.1 abs uses LLVM back end via Dragonegg, which is why it doesn't support OpenMP.
As noted already, Intel compilers support OpenMP on Mac.
I don't use Xcode editor so I don't know how to use any of these from there, but all will work from terminal just as they do on Linux.
the compiler on the mac is clang (based on llvm 3.5) which does not support openmp.
you can try install llvm/clang/openmp from source or using prebuild binaries, but I must admit it does not work as advertised for me…
edit unless you use the -fopenmp=libomp flag.

C libraries installation on Mac OSX

I have recently switched from Windows to Mac . I was told that Xcode has the C/C++ libraries(GCC) included. Apparently, the new Xcode 5 doesn't have them. As IDE, I have CodeBlocks downloaded. How do I install the libraries for CodeBlocks in Mac?
Apple deprecated gcc in XCode5 (after giving warning for quite a few releases). The main reason for this was that clang is now the system compiler, along with libc++, its accompanying standard library. One of the motivations for the move to clang is that the IDE makes heavy use of the compiler's modular architecture for code syntax highlighting, indexing and refactoring.
I can't imagine many reasons why you actually would specifically need GCC if building software on MacOSX and iOS. Clang has had the edge of GCC in both compilation speed and standards compliance for some time.
What you may need to do, if you haven't already, is install the optional XCode5 command-line tools package (the UI for this changed a few versions ago - google for the solution to your version of XCode5). This installs clang and other command-line tools (or more likely symlinks to them) in /usr, which where external tools and build and configuration tools such as cmake and autoconf expect them to be. clang is also aliased to cc.

ARM cross compiling introduction?

I'm trying to compile a program to run on a Linux powered board, which has an ARM926EJ-S processor. So I've installed Debian embedded cross-development toolchain, and tried compiling an Hello World with in gcc with -march=armv5te . When I tried running the binary on the board it crashed with file not found errors (due to library versions), after that I've tried compiling with -static flag and I got a seg fault (0x0000827c in __libc_start_main (), said mr gdb trough gdbserver).
Any idea on what to do here to get something running?
Apparently the solution is to try as many toolchains as you can find. Eventually you'll find the one that works, after spending a few too many hours compiling toolchains. uClibc buildroot in this case.
You can find toolchains which support ARM926EJ-S on Linaro Page. Use the most recent arm-linux-gnueabi from Linaro project. I am currently using a version with gcc 4.9.4 which you can find here
It is recommended to use -mcpu=arm926ej-s instead of -march and -mtune. See gcc documentation because it combines -march and -mtune for your specified processor. It was deprecated for x86, but not for arm.
Other possibility could be building your own toolchain via crosstools-ng. But the Linaro toolchains are working out of the box if you don't need some specific setting (for example only using static libraries).

Can I cross compile with gcc for an old version of a Linux distro on my Ubuntu 9.10?

I have some old hardware with an old version of say SuSE linux running on it. Now I have this fancy development machine running Ubuntu 9.10. Some of the tools I use to compile my C app (written in Python 2.6.x) are not available on the old SuSe box. So... is it possible to compile for that old machine on my dev box?
I have the following steps in mind, but would like to cross-check before venturing off into this quest:
1. Find out which static/shared libs my app needs and find/build target version of them
2. Also find the corresponding header files
3. Feed the correct flags to gcc to use the target headers and libraries
4. Feed the correct flags to gcc to use the correct architecture (i386/i686), or do I need a cross-compilation toolchain.
5. Compile, upload and enjoy ;-)
I regularly use avr-gcc and cc65, both are cross compiling. I know that you set up a coss compiler for developing something like a gumstix, so it should be possible to do the same for old/other Linux distros, not?
C
The way I would approach this is grab your oldmachine:/usr/lib and oldmachine:/usr/include so you have e.g. newmachine:/oldmachinecompiler/usr/{lib|include} then build a cross compiler setting --sysroot to newmachine:/oldmachinecompiler/
This is really the only way to ensure that any library requirements (including libc) in your program are compatible with oldmachine.

Resources