PDA

View Full Version : Problem when compiling project with visual studio



Thaorius
18th April 2007, 02:56
Hi everyone, this is my first post here.
I'm having problems with visual studio and Qt4, y made a simple project, following a tutorial from the net. It thows QMetaObject related errors. That's fine, I have to use qmake and not the vs ide directly because of moc.
So, I do this on the project directory:


qmake -project
qmake

Everything ok so far, but... if I then run nmake, the compiler says it can't find g++, of course... I'm not using MinGW!.

This is the makefile generated:

################################################## ###########################
# Makefile for building: QTest
# Generated by qmake (2.01a) (Qt 4.2.3) on: mar 17. abr 12:22:23 2007
# Project: QTest.pro
# Template: app
################################################## ###########################

####### Compiler, tools and options

CC = gcc
CXX = g++
LEX = flex
YACC = byacc
DEFINES = -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN
CFLAGS = -O2 -O2 -Wall $(DEFINES)
CXXFLAGS = -O2 -O2 -frtti -fexceptions -Wall $(DEFINES)
LEXFLAGS =
YACCFLAGS = -d
INCPATH = -I"G:/Qt/4.2.3/include/QtCore" -I"G:/Qt/4.2.3/include/QtCore" -I"G:/Qt/4.2.3/include/QtGui" -I"G:/Qt/4.2.3/include/QtGui" -I"G:/Qt/4.2.3/include" -I"." -I"G:/Qt/4.2.3/include/ActiveQt" -I"release" -I"." -I"..\..\..\Qt\4.2.3\mkspecs\default"
LINK = g++
LFLAGS = -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-s -Wl,-s -Wl,-subsystem,windows
LIBS = -L"g:\Qt\4.2.3\lib" -lmingw32 -lqtmain -lQtGui4 -lQtCore4
QMAKE = qmake
IDC = g:\Qt\4.2.3\bin\idc.exe
IDL = midl
ZIP = zip -r -9
DEF_FILE =
RES_FILE =
COPY = copy /y
COPY_FILE = $(COPY)
COPY_DIR = xcopy /s /q /y /i
DEL_FILE = del
DEL_DIR = rmdir
MOVE = move
CHK_DIR_EXISTS= if not exist
MKDIR = mkdir
INSTALL_FILE = $(COPY_FILE)
INSTALL_PROGRAM = $(COPY_FILE)
INSTALL_DIR = $(COPY_DIR)

####### Output directory

OBJECTS_DIR = release

####### Files

SOURCES = findDialog.cpp \
QTest.cpp \
stdafx.cpp release\moc_findDialog.cpp
OBJECTS = release\findDialog.o \
release\QTest.o \
release\stdafx.o \
release\moc_findDialog.o
DIST =
QMAKE_TARGET = QTest
DESTDIR = release\ #avoid trailing-slash linebreak
TARGET = QTest.exe
DESTDIR_TARGET = release\QTest.exe

####### Implicit rules

.SUFFIXES: .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:
$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<

####### Build rules

first: all
all: Makefile.Release $(DESTDIR_TARGET)

$(DESTDIR_TARGET): $(OBJECTS)
$(LINK) $(LFLAGS) -o "$(DESTDIR_TARGET)" $(OBJECTS) $(LIBS)


qmake: FORCE
@$(QMAKE) -win32 -o Makefile.Release QTest.pro

dist:
$(ZIP) QTest.zip $(SOURCES) $(DIST) QTest.pro G:/Qt/4.2.3/mkspecs/qconfig.pri ..\..\..\Qt\4.2.3\mkspecs\features\qt_functions.pr f ..\..\..\Qt\4.2.3\mkspecs\features\qt_config.prf ..\..\..\Qt\4.2.3\mkspecs\features\exclusive_build s.prf ..\..\..\Qt\4.2.3\mkspecs\features\default_pre.prf ..\..\..\Qt\4.2.3\mkspecs\features\win32\default_p re.prf ..\..\..\Qt\4.2.3\mkspecs\features\release.prf ..\..\..\Qt\4.2.3\mkspecs\features\debug_and_relea se.prf ..\..\..\Qt\4.2.3\mkspecs\features\default_post.pr f ..\..\..\Qt\4.2.3\mkspecs\features\build_pass.prf ..\..\..\Qt\4.2.3\mkspecs\features\Release.prf ..\..\..\Qt\4.2.3\mkspecs\features\win32\rtti.prf ..\..\..\Qt\4.2.3\mkspecs\features\win32\exception s.prf ..\..\..\Qt\4.2.3\mkspecs\features\win32\stl.prf ..\..\..\Qt\4.2.3\mkspecs\features\shared.prf ..\..\..\Qt\4.2.3\mkspecs\features\warn_on.prf ..\..\..\Qt\4.2.3\mkspecs\features\qt.prf ..\..\..\Qt\4.2.3\mkspecs\features\win32\thread.pr f ..\..\..\Qt\4.2.3\mkspecs\features\moc.prf ..\..\..\Qt\4.2.3\mkspecs\features\win32\windows.p rf ..\..\..\Qt\4.2.3\mkspecs\features\resources.prf ..\..\..\Qt\4.2.3\mkspecs\features\uic.prf g:\Qt\4.2.3\lib\qtmain.prl HEADERS RESOURCES IMAGES SOURCES FORMS

clean: compiler_clean
-$(DEL_FILE) release\findDialog.o release\QTest.o release\stdafx.o release\moc_findDialog.o

distclean: clean
-$(DEL_FILE) "$(DESTDIR_TARGET)"
-$(DEL_FILE) Makefile.Release

mocclean: compiler_moc_header_clean compiler_moc_source_clean

mocables: compiler_moc_header_make_all compiler_moc_source_make_all

compiler_moc_header_make_all: release\moc_findDialog.cpp
compiler_moc_header_clean:
-$(DEL_FILE) release\moc_findDialog.cpp
release\moc_findDialog.cpp: stdafx.h \
findDialog.h
g:\Qt\4.2.3\bin\moc.exe $(DEFINES) $(INCPATH) -D__GNUC__ -DWIN32 findDialog.h -o release\moc_findDialog.cpp

compiler_rcc_make_all:
compiler_rcc_clean:
compiler_image_collection_make_all: qmake_image_collection.cpp
compiler_image_collection_clean:
-$(DEL_FILE) qmake_image_collection.cpp
compiler_moc_source_make_all:
compiler_moc_source_clean:
compiler_uic_make_all:
compiler_uic_clean:
compiler_clean: compiler_moc_header_clean compiler_rcc_clean compiler_image_collection_clean compiler_moc_source_clean compiler_uic_clean



####### Compile

release\findDialog.o: findDialog.cpp stdafx.h \
findDialog.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\findDialog.o findDialog.cpp

release\QTest.o: QTest.cpp stdafx.h \
QTest.h \
resource.h \
findDialog.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\QTest.o QTest.cpp

release\stdafx.o: stdafx.cpp stdafx.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\stdafx.o stdafx.cpp

release\moc_findDialog.o: release\moc_findDialog.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o release\moc_findDialog.o release\moc_findDialog.cpp

####### Install

install: FORCE

uninstall: FORCE

FORCE:


Has you can see in the first lines... is not for vc++. So, my question is, how do I compile the project using vc++?

Thanks

vermarajeev
18th April 2007, 04:19
Can you please provide some more information?

marcel
18th April 2007, 05:05
use this:
qmake -o Makefile -spec win32-msvc.net
instead of just qmake.

Regards

Thaorius
18th April 2007, 15:31
Thanks, is working now