我在qtcreator中创建了一个项目。该项目本身对这个问题不是很重要。我想添加一个名为PowerWatershed的项目,源代码可在此处获得: PowerWatershed
不幸的是,将所有文件添加到.pro文件时,在编译时会出现错误,当使用PowerWatershed项目的Makefile进行“make”命令时可以正常工作。
项目的makefile是:
# Camille Couprie
# october 2009
OBJDIR = objects
PINKDIR = PINK
CSDIR = CSparse
ARGV = argv
PWSRC = src
VPATH = ${PINKDIR}:${CSDIR}:${ARGV}
CSINCLUDE = -I${CSDIR}/Include
PINKINCLUDE = -I${PINKDIR}
ARGVINCLUDE = -I${ARGV}
PWINCLUDE = -Iinclude
INCL = ${CSINCLUDE} ${PINKINCLUDE} ${ARGVINCLUDE} ${PWINCLUDE}
OBJ= objects/larith.o \
objects/ccsort.o \
objects/cccodimage.o \
objects/gageodesic.o \
objects/mccodimage.o \
objects/mcimage.o \
objects/mcindic.o \
objects/mclifo.o \
objects/random_walker.o \
objects/lMSF.o \
objects/MSF_RW.o \
objects/mcrbt.o \
objects/union_find.o \
objects/image_toolbox.o \
objects/cs_lu.o \
objects/cs_lusol.o \
objects/cs_malloc.o \
objects/cs_util.o \
objects/cs_multiply.o \
objects/cs_compress.o \
objects/cs_lsolve.o \
objects/cs_scatter.o \
objects/cs_cumsum.o \
objects/cs_sqr.o \
objects/cs_ipvec.o \
objects/cs_amd.o \
objects/cs_permute.o \
objects/cs_transpose.o \
objects/cs_counts.o \
objects/cs_add.o \
objects/cs_etree.o \
objects/cs_leaf.o \
objects/cs_fkeep.o \
objects/cs_tdfs.o \
objects/cs_usolve.o \
objects/cs_spsolve.o \
objects/cs_post.o \
objects/cs_reach.o \
objects/cs_dfs.o \
objects/argv.o
# objects/cs_print.o \
# objects/cs_norm.o \
#
FLAGS = -g -Wall # -pg
CXX = g++
CC = gcc
OPTIMISE=-O4
WARNINGS=-Wall #-Werror
DEBUG=-g
CXXFLAGS= ${DEBUG} ${WARNINGS} ${OPTIMISE} -Wno-deprecated ${FLAGS}
CFLAGS = ${DEBUG} ${WARNINGS} ${OPTIMISE} ${FLAGS}
all: ${CS} ${OBJ}
${MAKE} powerwatsegm.exe
# make with the Intel compiler, a very good complement to gcc/g++
# much more efficient and with better diagnoses
intel:
${MAKE} CC=icc CXX=icpc all
debug:
${MAKE} OPTIMISE='' all
# remove the asserts and the debug information
production:
${MAKE} DEBUG='' FLAGS="-DNDEBUG" all
clean:
rm -f *.exe; rm -f *~; rm -f $(OBJ); #rm -f overlay*; rm -f mask*;
powerwatsegm.exe: ${PWSRC}/powerwatsegm.c $(OBJ)
$(CXX) $(CXXFLAGS) $(INCL) ${PWSRC}/powerwatsegm.c $(OBJ) -o powerwatsegm.exe
$(OBJDIR)/%.o: ${PWSRC}/%.c
$(CXX) $(CXXFLAGS) ${INCL} -c $< -o $@
$(OBJDIR)/%.o: ${CSDIR}/Source/%.c ${CSDIR}/Include/cs.h
$(CC) $(CFLAGS) ${CSINCLUDE} -c $< -o $@
$(OBJDIR)/%.o: ${PINKDIR}/%.c
$(CXX) $(CXXFLAGS) ${PINKINCLUDE} -c $< -o $@
$(OBJDIR)/argv.o: ${ARGV}/argv.c ${ARGV}/argv.h ${ARGV}/argv_loc.h
$(CC) $(CCFLAGS) ${ARGVINCLUDE} -c $< -o $@
$(OBJDIR)/lMSF.o: ${PWSRC}/lMSF.c ${PINKDIR}/mcimage.h ${PINKDIR}/mccodimage.h
$(CXX) $(CFLAGS) ${PINKINCLUDE} ${PWINCLUDE} -c ${PWSRC}/lMSF.c -o $@
我想在我的.pro文件中添加propoer选项以使编译工作。目前,我的专业文件看起来像
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Power
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
PW_1.0.1/argv/argv.c \
PW_1.0.1/CSparse/Source/cs_add.c \
PW_1.0.1/CSparse/Source/cs_amd.c \
PW_1.0.1/CSparse/Source/cs_chol.c \
PW_1.0.1/CSparse/Source/cs_cholsol.c \
PW_1.0.1/CSparse/Source/cs_compress.c \
PW_1.0.1/CSparse/Source/cs_counts.c \
PW_1.0.1/CSparse/Source/cs_cumsum.c \
PW_1.0.1/CSparse/Source/cs_dfs.c \
PW_1.0.1/CSparse/Source/cs_etree.c \
PW_1.0.1/CSparse/Source/cs_fkeep.c \
PW_1.0.1/CSparse/Source/cs_ipvec.c \
PW_1.0.1/CSparse/Source/cs_leaf.c \
PW_1.0.1/CSparse/Source/cs_lsolve.c \
PW_1.0.1/CSparse/Source/cs_lu.c \
PW_1.0.1/CSparse/Source/cs_lusol.c \
PW_1.0.1/CSparse/Source/cs_malloc.c \
PW_1.0.1/CSparse/Source/cs_multiply.c \
PW_1.0.1/CSparse/Source/cs_norm.c \
PW_1.0.1/CSparse/Source/cs_permute.c \
PW_1.0.1/CSparse/Source/cs_post.c \
PW_1.0.1/CSparse/Source/cs_print.c \
PW_1.0.1/CSparse/Source/cs_reach.c \
PW_1.0.1/CSparse/Source/cs_scatter.c \
PW_1.0.1/CSparse/Source/cs_spsolve.c \
PW_1.0.1/CSparse/Source/cs_sqr.c \
PW_1.0.1/CSparse/Source/cs_tdfs.c \
PW_1.0.1/CSparse/Source/cs_transpose.c \
PW_1.0.1/CSparse/Source/cs_usolve.c \
PW_1.0.1/CSparse/Source/cs_util.c \
PW_1.0.1/PINK/gageodesic.c \
PW_1.0.1/PINK/larith.c \
PW_1.0.1/PINK/lMSF.c \
PW_1.0.1/PINK/mccodimage.c \
PW_1.0.1/PINK/mcimage.c \
PW_1.0.1/PINK/mcindic.c \
PW_1.0.1/PINK/mclifo.c \
PW_1.0.1/PINK/mcrbt.c \
PW_1.0.1/src/cccodimage.c \
PW_1.0.1/src/ccsort.c \
PW_1.0.1/src/gageodesic.c \
PW_1.0.1/src/image_toolbox.c \
PW_1.0.1/src/lMSF.c \
PW_1.0.1/src/MSF_RW.c \
PW_1.0.1/src/powerwatsegm.c \
PW_1.0.1/src/random_walker.c \
PW_1.0.1/src/union_find.c
HEADERS += mainwindow.h \
PW_1.0.1/argv/argv.h \
PW_1.0.1/argv/argv_loc.h \
PW_1.0.1/argv/compat.h \
PW_1.0.1/argv/conf.h \
PW_1.0.1/CSparse/Include/cs.h \
PW_1.0.1/include/cccodimage.h \
PW_1.0.1/include/ccsort.h \
PW_1.0.1/include/gageodesic.h \
PW_1.0.1/include/image_toolbox.h \
PW_1.0.1/include/lMSF.h \
PW_1.0.1/include/MSF_RW.h \
PW_1.0.1/include/powerwatsegm.h \
PW_1.0.1/include/random_walker.h \
PW_1.0.1/include/union_find.h \
PW_1.0.1/PINK/larith.h \
PW_1.0.1/PINK/mccodimage.h \
PW_1.0.1/PINK/mcimage.h \
PW_1.0.1/PINK/mcindic.h \
PW_1.0.1/PINK/mclifo.h \
PW_1.0.1/PINK/mcrbt.h \
PW_1.0.1/PINK/mcutil.h
FORMS += mainwindow.ui
我有错误:
/home/iznogood/Documents/Power/PW_1.0.1/src/gageodesic.c:44: erreur : mccodimage.h: No such file or directory
#include <mccodimage.h>
^
我认为这是一个路径问题,在Makefile中提到:
OBJDIR = objects
PINKDIR = PINK
CSDIR = CSparse
ARGV = argv
PWSRC = src
VPATH = ${PINKDIR}:${CSDIR}:${ARGV}
但我无法将它们添加到.pro文件中。
答案 0 :(得分:0)
相关的qmake变量为INCLUDEPATH
。
因此,对于原始makefile中的以下内容:
CSINCLUDE = -I${CSDIR}/Include
PINKINCLUDE = -I${PINKDIR}
ARGVINCLUDE = -I${ARGV}
PWINCLUDE = -Iinclude
INCL = ${CSINCLUDE} ${PINKINCLUDE} ${ARGVINCLUDE} ${PWINCLUDE}
会是这样的:
INCLUDEPATH += ${CSDIR}/Include \
${PINKDIR} \
${ARGV} \
include
QMake manual中的reference pages记录了这一点。