我只是在我的 slax 盒子上安装了 qt,我尝试使用 qmake 编写和编译。
但问题是 qmake 没有写它的“Makefile”来包含 -Lqt-mt 或 -Lqt。我必须手动提供,否则会有未解决的链接。我能为此做些什么?有什么解决方法吗?
这是 qmake 的“Makefile”输出。
#############################################################################
# Makefile for building: hello
# Generated by qmake (2.01a) (Qt 4.5.3) on: Tue Feb 2 04:04:03 2010
# Project: hello_world.pro
# Template: app
# Command: /usr/bin/qmake -unix -o Makefile hello_world.pro
#############################################################################
####### Compiler, tools and options
CC = gcc
CXX = g++
DEFINES =
CFLAGS = -pipe $(DEFINES)
CXXFLAGS = -pipe $(DEFINES)
INCPATH = -I/usr/lib/qt-3.3.8b/mkspecs/linux-g++ -I.
LINK = g++
LFLAGS =
LIBS = $(SUBLIBS)
AR = ar cqs
RANLIB =
QMAKE = /usr/bin/qmake
TAR = tar -cf
COMPRESS = gzip -9f
COPY = cp -f
SED = sed
COPY_FILE = $(COPY)
COPY_DIR = $(COPY) -r
INSTALL_FILE = $(COPY_FILE)
INSTALL_DIR = $(COPY_DIR)
INSTALL_PROGRAM = $(COPY_FILE)
DEL_FILE = rm -f
SYMLINK = ln -sf
DEL_DIR = rmdir
MOVE = mv -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p
####### Output directory
OBJECTS_DIR = ./
####### Files
SOURCES = hello_world.cpp
OBJECTS = hello_world.o
DIST = hello_world.pro
QMAKE_TARGET = hello
DESTDIR =
TARGET = hello
first: all
####### Implicit rules
.SUFFIXES: .o .c .cpp .cc .cxx .C
.cpp.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
.cc.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
.cxx.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
.C.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
.c.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
####### Build rules
all: Makefile $(TARGET)
$(TARGET): $(OBJECTS)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
Makefile: hello_world.pro /usr/lib/qt-3.3.8b/mkspecs/linux-g++/qmake.conf
$(QMAKE) -unix -o Makefile hello_world.pro
qmake: FORCE
@$(QMAKE) -unix -o Makefile hello_world.pro
dist:
@$(CHK_DIR_EXISTS) .tmp/hello1.0.0 || $(MKDIR) .tmp/hello1.0.0
$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/hello1.0.0/ && (cd `dirname .tmp/hello1.0.0` && $(TAR) hello1.0.0.tar hello1.0.0 && $(COMPRESS) hello1.0.0.tar) && $(MOVE) `dirname .tmp/hello1.0.0`/hello1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/hello1.0.0
clean:compiler_clean
-$(DEL_FILE) $(OBJECTS)
-$(DEL_FILE) *~ core *.core
####### Sub-libraries
distclean: clean
-$(DEL_FILE) $(TARGET)
-$(DEL_FILE) Makefile
compiler_clean:
####### Compile
hello_world.o: hello_world.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o hello_world.o hello_world.cpp
####### Install
install: FORCE
uninstall: FORCE
FORCE:
这是我使用的 .pro 文件。
TEMPLATE=app
CONFIG+= qt warn_on release
HEADERS=
SOURCES=hello_world.cpp
TARGET=hello
我已经设置了 $QTDIR 并且我认为一切都已就绪。我错过了哪里?为什么我必须手动给它?为什么qmake首先不起作用?
编辑:在makefile中有
LIBS = $(SUBLIBS)
我所做的就是将其更改为,
LIBS = $(SUBLIBS) -lqt-mt
更改后一切正常!问题又来了,为什么我必须手动做这样的事情?
对于@Frank Osterfeld,我认为我使用的是正确的'qmake',因为当我点击 qmake --version 时,我确实明白了。
QMake version 2.01a
Using Qt version 4.5.3 in /usr/lib/qt/lib
- 提前致谢 -