Search code examples
gccmakefileg++openmpicc

using openmp with a makefile and g++


I am building a large project with a makefile that was originally built with icpc, and now I need to get it running with g++.

When it compiles the file that uses openmp, it uses the -c flag, and doesn't use any libraries, so it ends up being serial instead of openmp. All of the examples I am seeing aren't using this -c flag.

Is there some way to compile without linking, but using openmp?

edit:

I've been using the -lgomp flag(and the library is on the library path):

g++ -lgomp -c -w -O4 mainS.cpp
g++: -lgomp: linker input file unused because linking not done

Edit: my boss made several mistakes in the code, the makefile, and the documentation. Sorry to have wasted your time, at least it was less than the 5 hours I spend on it =/


Solution

  • Are you passing the flag to enable OpenMP (IIRC it's something like -fopenmp? If you don't chances are the compiler will ignore the OpenMP-related primitives and just produce serial code.

    I don't think that -c (ie, compile only, don't like) has anything to do with your problem.