Monday, July 25, 2022

[SOLVED] How to add options to gcc in qt creator?

Issue

Qt has been my choice of IDE for several years but this is crazy frustrating.

I'm trying to use openGL in my C project, but none of the functions have a defined reference. I google the issue and find this lovely page (second to last response). I try this out and it works flawlessly:

gcc main.c -lGL -lglut

But using the terminal instead of the built-in functionality of Qt creator is... undesirable. So I google how to add options to gcc with qt, I find this stackoverflow page, but it doesn't work, at all. And I tried all sorts of things like

QMAKE_CXXFLAGS += -lGL -lglut

and

QMAKE_CFLAGS += -lGL -lglut

and (desperately)

OPTIONS: -lGL -lglut

I don't know, I can't figure out how I'm supposed to add options to gcc in Qt so that my functions are no longer undefined.

Maybe I need a new IDE with a more straight forward compile function...

EDIT! Iskar Jarak was right, I had to add it to libs like so:

LIBS += -lGL -lglut

This is in the .pro file by the way.


Solution

Add LIBS += -lGL -lglut to your .pro file.

QMAKE_CXXFLAGS is for C++ compiler flags like -std=C++0x



Answered By - Iskar Jarak
Answer Checked By - Gilberto Lyons (WPSolving Admin)