I have created a small library (around 600 lines) in C++ in Codeblocks and I'm using OMP and O3 optimization to build it. When I try to build the same code through the terminal with a Makefile with exactly the same options (-fopenmp -O3) it runs around 3 times slower. I need to build it in various machines so I need to do the process through a terminal and not through Codeblocks. Why is this happening? This is my Makefile if you're interested:
CC=g++
CFLAGS=
LDFLAGS= -fopenmp -O3 -std=c++11
SOURCES=main.cpp CNNFunctions.cpp
OBJECTS=$(SOURCES:.cpp=.o) EXECUTABLE=cnn
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@
.cpp.o:
$(CC) $(CFLAGS) $< -o $@