简体   繁体   中英

How to create a Qt Creator project (.pro) file equivalent to existing Makefile

There is a project which is build via make command, where the Makefile is provided. Following are the Makefile contents:

TARGETT=gnulinux
OROPATH=/usr/local
CXXFLAGS=-I${OROPATH}/include -DOROCOS_TARGET=${TARGETT} -Wall
LDFLAGS=-L${OROPATH}/lib -Wl,-rpath ${OROPATH}/lib -lorocos-taskbrowser-${TARGETT} -lorocos-rtt-${TARGETT}

all: main

main.o: main.cpp
    $(CXX) -c main.cpp $(CXXFLAGS)

AHRS.o: AHRS.cpp AHRS.h
    $(CXX) -c AHRS.cpp $(CXXFLAGS)

main: main.o AHRS.o 
    $(CXX) -g -o main main.o AHRS.o $(CXXFLAGS) $(LDFLAGS)

clean:
    rm -f main orocos.log .tb_history *.o 

But I'm used to use QtCreator . I know that QtCreator constructs its own makefile from the project (.pro) file during build process. So, I think, relevant information must be copied from the Makefile contents (above) into a Qt Creator project file to allow QtCreator to generate the compatible makefile. Right?

Given the Makefile above, how should the .pro file look like?

And in the end of this process I'll be able to work from QtCreator .

Given the Makefile above, how should the .pro file look like?

Like this:

TEMPLATE = app
TARGET = AHRS # the desired filename of the executable goes here
OROPATH = /usr/local
INCLUDEPATH += $${OROPATH}/include
O_TARGET = gnulinux
DEFINES += OROCOS_TARGET=$${O_TARGET}
QMAKE_RPATHDIR += -L$${OROPATH}/lib
LIBS += -L$${OROPATH}/lib 
LIBS += -lorocos-taskbrowser-$${O_TARGET} -lorocos-rtt-$${O_TARGET}

SOURCES += main.cpp AHRS.cpp
HEADERS += AHRS.h

Note that Qt Creator doesn't construct anything. qmake does. The project files are qmake projects, not Qt Creator projects. You don't need Qt Creator at all to build your project. You can do it from the command line using nothing but Qt and the compiler/binutils:

# assume that the source is in AHRS-source subfolder
mkdir AHRS
cd AHRS
/path/to/Qt/bin/qmake ../AHRS-source
make -j
# now we can run it
./AHRS

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM