PDA

View Full Version : makefile troubles



Walsi
11th April 2007, 14:57
Hello, ...

I want to create a SIP Client Application using Qt4 for the User Interface. My developing is really at the beginning and I got a problem with the makefile. My SIP Client GUI is based on a OpenSource SIP Stack (pjsip.org). On this Homepage is a Manual which explains how to create a own SIP Client GUI. They say, that I have to write my own makefile which involves following lines.


#Modify this to point to the PJSIP location.
PJBASE=/home/myself/pjproject-0.5.10.2

include $(PJBASE)/build.mak

CC = $(APP_CC)
LDFLAGS = $(APP_LDFLAGS)
LDLIBS = $(APP_LDLIBS)
CFLAGS = $(APP_CFLAGS)
CPPFLAGS= ${CFLAGS}

# If your application is in a file named myapp.cpp or myapp.c
# this is the line you will need to build the binary.
all: myapp

myapp: myapp.cpp
$(CC) -o $@ $< $(CPPFLAGS) $(LDFLAGS) $(LDLIBS)

clean:
rm -f myapp.o myapp

But also the command
qmake generates his own makefiles which involve the path for the Qt4 include files.

So when I use the the makefile generated by qmake, the compiler doesn't find the includes from the pjsip.

So my Question: How can or must I combine or build the makefile that i can make a successful build of my program.


Best Regards,...

Walsi
12th April 2007, 07:58
Okay, I try it another way:

This is my makefile generated by qmake:


-################################################## ###########################
# Makefile for building: usc-es_0-1
# Generated by qmake (2.01a) (Qt 4.2.3) on: Thu Apr 12 08:32:45 2007
# Project: usc-es_0-1.pro
# Template: app
# Command: /usr/local/Trolltech/Qt-4.2.3/bin/qmake -unix -o Makefile usc-es_0-1.pro
################################################## ###########################

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

CC = gcc
CXX = g++
LEX = flex
YACC = yacc
DEFINES = -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
CFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
CXXFLAGS = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
LEXFLAGS =
YACCFLAGS = -d
INCPATH = -I/usr/local/Trolltech/Qt-4.2.3/mkspecs/linux-g++ -I. \
-I/usr/local/Trolltech/Qt-4.2.3/include/QtCore -I/usr/local/Trolltech/Qt-4.2.3/include/QtCore \
-I/usr/local/Trolltech/Qt-4.2.3/include/QtGui -I/usr/local/Trolltech/Qt-4.2.3/include/QtGui
-I/usr/local/Trolltech/Qt-4.2.3/include -I. -Isrc -I. -I.
LINK = g++
LFLAGS = -Wl,-rpath,/usr/local/Trolltech/Qt-4.2.3/lib
LIBS = $(SUBLIBS) -L/usr/local/Trolltech/Qt-4.2.3/lib -lQtGui
-L/home/nb100146/qt-x11-opensource-src-4.2.3/lib -L/usr/X11R6/lib \
-lpng -lSM -lICE -pthread -pthread -lXi -lXrender -lXrandr -lXfixes -lXcursor \
-lXinerama -lfreetype -lfontconfig -lXext -lX11 -lQtCore -lz -lm -pthread \
-lgthread-2.0 -lglib-2.0 -ldl -lpthread
AR = ar cqs
RANLIB =
QMAKE = /usr/local/Trolltech/Qt-4.2.3/bin/qmake
TAR = tar -cf
COMPRESS = gzip -9f
COPY = cp -f
COPY_FILE = $(COPY)
COPY_DIR = $(COPY) -r
INSTALL_FILE = install -m 644 -p
INSTALL_DIR = $(COPY_DIR)
INSTALL_PROGRAM = install -m 755 -p
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 = src/uscgui.cpp \
src/uscinterface.cpp moc_uscgui.cpp
OBJECTS = uscgui.o \
uscinterface.o \
moc_uscgui.o
DIST = /usr/local/Trolltech/Qt-4.2.3/mkspecs/common/unix.conf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/common/g++.conf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/common/linux.conf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/qconfig.pri \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/qt_functions.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/qt_config.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/exclusive_builds.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/default_pre.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/release.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/default_post.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/warn_on.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/qt.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/unix/thread.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/moc.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/resources.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/uic.prf \
usc-es_0-1.pro
QMAKE_TARGET = usc-es_0-1
DESTDIR =
TARGET = usc-es_0-1

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: usc-es_0-1.pro /usr/local/Trolltech/Qt-4.2.3/mkspecs/linux-g++/qmake.conf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/common/unix.conf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/common/g++.conf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/common/linux.conf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/qconfig.pri \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/qt_functions.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/qt_config.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/exclusive_builds.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/default_pre.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/release.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/default_post.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/warn_on.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/qt.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/unix/thread.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/moc.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/resources.prf \
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/uic.prf \
/usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.prl \
/usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.prl
$(QMAKE) -unix -o Makefile usc-es_0-1.pro
/usr/local/Trolltech/Qt-4.2.3/mkspecs/common/unix.conf:
/usr/local/Trolltech/Qt-4.2.3/mkspecs/common/g++.conf:
/usr/local/Trolltech/Qt-4.2.3/mkspecs/common/linux.conf:
/usr/local/Trolltech/Qt-4.2.3/mkspecs/qconfig.pri:
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/qt_functions.prf:
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/qt_config.prf:
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/exclusive_builds.prf:
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/default_pre.prf:
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/release.prf:
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/default_post.prf:
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/warn_on.prf:
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/qt.prf:
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/unix/thread.prf:
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/moc.prf:
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/resources.prf:
/usr/local/Trolltech/Qt-4.2.3/mkspecs/features/uic.prf:
/usr/local/Trolltech/Qt-4.2.3/lib/libQtGui.prl:
/usr/local/Trolltech/Qt-4.2.3/lib/libQtCore.prl:
qmake: FORCE
@$(QMAKE) -unix -o Makefile usc-es_0-1.pro

dist:
@$(CHK_DIR_EXISTS) .tmp/usc-es_0-11.0.0 || $(MKDIR) .tmp/usc-es_0-11.0.0
$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/usc-es_0-11.0.0/ && \
$(COPY_FILE) --parents src/uscgui.h .tmp/usc-es_0-11.0.0/ && \
$(COPY_FILE) --parents src/uscgui.cpp src/uscinterface.cpp .tmp/usc-es_0-11.0.0/ && \
(cd `dirname .tmp/usc-es_0-11.0.0` && $(TAR) usc-es_0-11.0.0.tar usc-es_0-11.0.0 && \
$(COMPRESS) usc-es_0-11.0.0.tar) && $(MOVE) `dirname .tmp/usc-es_0-11.0.0`/usc-es_0-11.0.0.tar.gz . && \
$(DEL_FILE) -r .tmp/usc-es_0-11.0.0


yaccclean:
lexclean:
clean:compiler_clean
-$(DEL_FILE) $(OBJECTS)
-$(DEL_FILE) *~ core *.core


####### Sub-libraries

distclean: clean
-$(DEL_FILE) $(TARGET)
-$(DEL_FILE) Makefile


/usr/local/Trolltech/Qt-4.2.3/bin/moc:
(cd $(QTDIR)/src/tools/moc && $(MAKE))

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: moc_uscgui.cpp
compiler_moc_header_clean:
-$(DEL_FILE) moc_uscgui.cpp
moc_uscgui.cpp: src/uscgui.h \
/usr/local/Trolltech/Qt-4.2.3/bin/moc
/usr/local/Trolltech/Qt-4.2.3/bin/moc $(DEFINES) $(INCPATH) src/uscgui.h -o moc_uscgui.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

uscgui.o: src/uscgui.cpp src/uscgui.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o uscgui.o src/uscgui.cpp

uscinterface.o: src/uscinterface.cpp src/uscgui.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o uscinterface.o src/uscinterface.cpp

moc_uscgui.o: moc_uscgui.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_uscgui.o moc_uscgui.cpp

####### Install

install: FORCE

uninstall: FORCE

FORCE:

I have to include in this makefile some other lines, because I want to build a application which is based on the sources of the pjproject sources. In a manual of pjproject is written that my makefile have to look like this:


#Modify this to point to the PJSIP location.
PJBASE=/home/myself/pjproject-0.5.10.2

include $(PJBASE)/build.mak

CC = $(APP_CC)
LDFLAGS = $(APP_LDFLAGS)
LDLIBS = $(APP_LDLIBS)
CFLAGS = $(APP_CFLAGS)
CPPFLAGS= ${CFLAGS}

# If your application is in a file named myapp.cpp or myapp.c
# this is the line you will need to build the binary.
all: myapp

myapp: myapp.cpp
$(CC) -o $@ $< $(CPPFLAGS) $(LDFLAGS) $(LDLIBS)

clean:
rm -f myapp.o myapp



My question: How can I include this few lines to the Qt specific makefile that the make also finds the pjproject sources????


Best Regards,...

wysota
12th April 2007, 10:00
I answered your question yesterday but Konqueror crashed during posting the message, so it didn't make it onto the board.

You should try to split the application into two components - one should contain all SIP related code, which you can then compile using a custom (non-Qt) makefile into a library and the other one should contain Qt code (which you can compile using qmake) and call functions/classes defined in the other part which needs to be linked with the main part during compilation.

jacek
12th April 2007, 11:55
Can't you just set LIBS and INCLUDEPATH accordingly in your .pro file? Does this library support pkgconfig?

Walsi
12th April 2007, 13:41
I answered your question yesterday but Konqueror crashed during posting the message, so it didn't make it onto the board.

You should try to split the application into two components - one should contain all SIP related code, which you can then compile using a custom (non-Qt) makefile into a library and the other one should contain Qt code (which you can compile using qmake) and call functions/classes defined in the other part which needs to be linked with the main part during compilation.

Okay that sounds like a very god idea! Because today i tried to include the relevant SIP-makefile lines into the Qt-makefile and it causes further troubles anywhere.

But your info isn't very helpful in this way. How can implement these call functions/classes and how can I manually link them during the compilation?

I please you to give me more and detailed information about that.

Best Regards!

wysota
12th April 2007, 14:19
You have to create a library of classes or functions and link your application against it just like you link against Qt libraries. There are lots and lots of materials on how to create libraries for various systems available in the Internet. In doubt consult your compiler manual.

Walsi
12th April 2007, 15:12
Hey Wysota,

Thanks for your information. But just yet I find out how to handle my problem. qmake also generates me a .pro file before it generates me the Makefile. The .pro file is much easier to understand and to configure by a "human being". ;) ;)

So today I find out how to fill up this .pro file correctly with the PSJIP specific Includes and Libraries.

My Profile looks like this at the moment:


################################################## ####################
# Automatically generated by qmake (2.01a) Thu Apr 12 15:03:47 2007
################################################## ####################


TEMPLATE = app
TARGET =
DEPENDPATH += . src
INCLUDEPATH += . src

LIBS += -L/home/user/pjproject-0.5.10.2/pjlib/lib
LIBS += -L/home/user/pjproject-0.5.10.2/pjlib-util/lib/
LIBS += -L/home/user/pjproject-0.5.10.2/pjmedia/lib
LIBS += -L/home/user/pjproject-0.5.10.2/pjsip/lib

LIBS += -lpjsua-i686-pc-linux-gnu
LIBS += -lpjsip-ua-i686-pc-linux-gnu
LIBS += -lpjsip-simple-i686-pc-linux-gnu
LIBS += -lpjsip-i686-pc-linux-gnu
LIBS += -lpjmedia-codec-i686-pc-linux-gnu
LIBS += -lpjmedia-i686-pc-linux-gnu
LIBS += -lpjmedia-codec-i686-pc-linux-gnu
LIBS += -lpjlib-util-i686-pc-linux-gnu
LIBS += -lpj-i686-pc-linux-gnu
LIBS += -lm -lnsl -lrt -lpthread

INCLUDEPATH += /home/user/pjproject-0.5.10.2/pjlib/include
INCLUDEPATH += /home/user/pjproject-0.5.10.2/pjlib-util/include
INCLUDEPATH += /home/user/pjproject-0.5.10.2/pjmedia/include
INCLUDEPATH += /home/user/pjproject-0.5.10.2/pjsip/include


# Input
HEADERS += src/uscgui.h
SOURCES += src/uscgui.cpp src/uscinterface.cpp

And it works with this configuration. :) :)

Thanks for your help!

Best Regards,...