Why am I getting the error message undefinded reference to 'omp_get_wtime'
when I try to build my cpp file?
The full error message looks like this:
C:\Program Files\JetBrains\CLion 2022.2.4\bin\mingw\bin/ld.exe:
C:\Users\Hannah\AppData\Local\Temp\ccp3nN8r.o:daxpy.cpp:(.text+0x629): undefined reference to 'omp_get_wtime'
collect2.exe: error: ld returned 1 exit status
I looked into various posts already and most of them say to link -fopenmp
in the makefile, but I already did that (it was done for us students).
My Makefile looks like this:
CC=gcc
CXX=g++
CFLAGS=-O3 -fopenmp -std=c99
CXXFLAGS=-O3 -fopenmp
EXECS=daxpy
all: $(EXECS)
matmul_serial-sol: daxpy.cpp
$(CXX) -o $@ $< $(CXXFLAGS)
clean:
rm -f $(EXECS) *.o
and after suggestions from the comments:
CC=gcc
CXX=g++
CFLAGS=-O3 -fopenmp -std=c99
CXXFLAGS=-O3 -fopenmp
LDFLAGS= -fopenmp
EXECS=daxpy
all: $(EXECS)
daxpy: daxpy.cpp
$(CXX) -o $@ $< $(CXXFLAGS)
clean:
rm -f $(EXECS) *.o
and I did include omp.h
in my file.