0

I am using Ubuntu 11.04. I have installed the compiler gcc 4.5 by using the command sudo apt-get install gcc 4.5 in terminal. Now I need the command to enable OpenMP. Is it gcc -fopenmp foo.c ?


@pl1nk I started from the beginning:

1st step=> sudo apt-get install build-essential

2nd step=> sudo apt-get install gcc 4.5

And now the output of gcc -v is:

**ubuntu@ubuntu:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/i386-linux-gnu/gcc/i686-linux-gnu/4.5.2/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.5.2-8ubuntu4' --with-bugurl=file:///usr/share/doc/gcc-4.5/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.5 --enable-shared --enable-multiarch --with-multiarch-defaults=i386-linux-gnu --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib/i386-linux-gnu --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.5 --libdir=/usr/lib/i386-linux-gnu --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-gold --enable-ld=default --with-plugin-ld=ld.gold --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)** 

In few words the same results....
What should I do now?

2 Answers 2

0

Run update-alternatives --config gcc to be asked to choose the GCC version you want to use among those installed.

Then you could run gcc with the chosen version.

9
  • It looks like there is only one version
    – Anita 7
    May 31, 2012 at 22:42
  • ubuntu@ubuntu:~$ update-alternatives --config gcc update-alternatives: error: no alternatives for gcc.
    – Anita 7
    May 31, 2012 at 22:42
  • @Anita7 How did you install gcc 4.5? What´s the output of ggc -v
    – pl1nk
    May 31, 2012 at 22:47
  • I have installed the compiler gcc 4.5 by using the command sudo apt-get install gcc 4.5
    – Anita 7
    Jun 1, 2012 at 12:28
  • @Anita7 It seems that you have only gcc 4.5 installed. You can proceed with gcc -fopenmp foo.c as you mentioned.
    – pl1nk
    Jun 1, 2012 at 12:45
0

GCC 4.4/5 implements OpenMP version 3.0.

GCC 4.7/8 supports the OpenMP 3.1 specification.

GCC 4.9 supports OpenMP 4.0. Ubuntu 13.10, however, uses GCC 4.8 by default.

For more information, see OpenMP in the GCC wiki.

According to the gcc man page, gcc -fopenmp foo.c is indeed the correct syntax.

The man page also states:

-fopenmp

Enable handling of OpenMP directives "#pragma omp" in C/C ++ and "!$omp" in Fortran. When -fopenmp is specified, the compiler generates parallel code according to the OpenMP Application Program Interface v3.0 http://www.openmp.org/. This option implies -pthread, and thus is only supported on targets that have support for -pthread.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .