tags:

views:

370

answers:

1

I have 3 files in my program: App_interface.h, App_interface.cpp, main.cpp. Im trying to compile my program which requires the Qt library. I just installed the Qt library in the default location. This is my makefile:

if your wondering why i don't use moc in this makefile is because 1) i dont know how to do that. 2) i just want to stop getting the compiler error "cannot find ... file".

thanks

# Project: App_interface
# 10-19-09
# 

# general variables
CPP := g++
OBJS := main.o App_interface.o

# Qt directorys
QTLIB := /usr/local/Trolltech/Qt-4.5.3/lib

QTINC := /usr/local/Trolltech/Qt-4.5.3/include
QTMOC := /usr/local/Trolltech/Qt-4.5.3/bin

App_interfaceV1: $(OBJS)
    $(CPP) $(OBJS) -o App_interfaceV1 $(QTLIB) 

main.o: main.cpp App_interface.h 
    $(CPP) -B $(QTINC) -c main.cpp -o main.o 

App_interface.o: App_interface.h
    $(CPP) -B $(QTINC) -c App_interface.cpp -o App_interface.o
+1  A: 

There are several problems: You should use -I $(QTINC) to compile files, -L $(QTLIB) and at least -lQtCore -lQtGui to link the application. To get more help you should provide exact error messages.

Sorry to be blunt, but if you don't know how to write Makefiles, I'd suggest to use qmake.

Lukáš Lalinský
Regarding qmake, what was wrong with http://stackoverflow.com/questions/1557714/how-to-automate-qt-moc/1565249#1565249 ?
Lukáš Lalinský
the only way to learn how to write Makefiles is to write Makefiles.
TheFuzz
Well, while that's true, you said you just want to stop getting errors. Using a tool that will generate the Makefile for you is the best advice I can give you. After you are comfortable with the build process and you understand the tools it uses, you can write them manually (which you won't, because at the point you realize it's not worth the effort).
Lukáš Lalinský
your right, i did some research on qmake. sorry about the semi smart ass comment
TheFuzz