Compiler Options [Solved]



  • Hi all.

    I am trying to pass options to the compiler in Qt Creator. I'm new to Qt. Please take pity and explain why when I pass options to the compiler in creator, my program won't compile. But if I use the compiler directly via the command line with options, everything goes fine.

    OS: OpenSUSE Linux 12.3 (64 bit)
    Compiler: g++
    QT: 4.8.4 (64 bit)
    Creator: 2.6.2

    I passed options to the compiler with the following entries in my .pro file.

    @QMAKE_CXXFLAGS += -O2
    QMAKE_CXXFLAGS += -llapack
    QMAKE_CXXFLAGS += -lblas@

    I tried running this directly on the command line.

    @g++ -O2 -llapack -lblas main.cpp@

    Works just fine.

    But in Qt Creator, doesn't work. I checked my compile output, and I can see that the options are included.

    @10:06:31: Running steps for project testArma1...
    10:06:31: Starting: "/usr/bin/qmake" /home/nicholas/Development/testArma1/testArma1.pro -r -spec linux-g++-64 CONFIG+=debug CONFIG+=declarative_debug
    10:06:31: The process "/usr/bin/qmake" exited normally.
    10:06:31: Starting: "/usr/bin/make" -w
    make: Entering directory /home/nicholas/Development/testArma1-build-Desktop-Debug' g++ -c -m64 -pipe -O2 -llapack -lblas -g -Wall -W -D_REENTRANT -DQT_WEBKIT -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++-64 -I../testArma1 -I/usr/include/QtCore -I/usr/include -I. -I../testArma1 -I. -o main.o ../testArma1/main.cpp ../testArma1/main.cpp:8:5: warning: unused parameter 'argc' [-Wunused-parameter] ../testArma1/main.cpp:8:5: warning: unused parameter 'argv' [-Wunused-parameter] g++ -m64 -o testArma1 main.o -L/usr/lib64 -lQtCore -L/usr/lib64 -lpthread main.o: In functiongemv<double>':
    /usr/include/armadillo_bits/blas_wrapper.hpp:39: undefined reference to dgemv_' main.o: In functiongemm<double>':
    /usr/include/armadillo_bits/blas_wrapper.hpp:74: undefined reference to dgemm_' main.o: In functiongemv<double>':
    /usr/include/armadillo_bits/blas_wrapper.hpp:39: undefined reference to dgemv_' main.o: In functiondot<double>':
    /usr/include/armadillo_bits/blas_wrapper.hpp:140: undefined reference to ddot_' collect2: error: ld returned 1 exit status make: Leaving directory/home/nicholas/Development/testArma1-build-Desktop-Debug'
    make: *** [testArma1] Error 1
    10:06:38: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project testArma1 (kit: Desktop)
    When executing step 'Make'@

    I even tried using the exact Qt command in the command line, minus the Qt variables.

    @g++ -c -m64 -pipe -O2 -llapack -lblas -g -Wall -W -I/usr/share/qt4/mkspecs/linux-g++-64 -I../testArma1 -I/usr/include/QtCore -I/usr/include -I. -I../testArma1 -I. -o main.o ../testArma1/main.cpp@

    And that worked fine. I assume something important is happening in the Qt variables. But I'm too new at this to know what. Any help please?


  • Lifetime Qt Champion

    Hi,

    Your options are passed but they are wrong (except for the O2).

    -llapack and -lblas are linker options and since these are "libraries" options what you need to do is:

    @LIBS += -llapack -lblas@

    in your pro file and you should be good



  • You were right. Worked perfect once I added those as libs. Thanks!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.