PDA

View Full Version : Building the entire project



vermarajeev
23rd February 2007, 08:20
Hi all,
I have two project files 1) Project1.pro 2) Project2.pro and a makefile basically GNUMakefile...

Project2.pro contains some *.h and *.cpp files..
makefile has all the information for compiling and linking a different application.

What I want is, when I say

qmake Project1.pro
make clean
make
First makefile(GNUMakefile) should be compiled and linked then files in Project2.pro should be compiled and linked to create an executable file. This basically means Proejct2.pro is dependent on GNUMakefile

Please let me what contents should be there in Project1.pro to make that happen.

Thanks

camel
23rd February 2007, 08:58
First makefile(GNUMakefile) should be compiled and linked then files in Project2.pro should be compiled and linked to create an executable file. This basically means Proejct2.pro is dependent on GNUMakefile


You can build that using extra targets, i.e. you should be able to embedd it directly into the project2.pro...could look something like this:


makeproject.target = WHATEVER_THAT_MAKEFILE_PRODUCES
makeproject.commands = make NAME_OF_MAKEFILE
makeproject.depends = WHICH_FILES_THE_TARGET_DEPENDS_ON

QMAKE_EXTRA_TARGETS += makeproject
PRE_TARGETDEPS += makeproject


Make clean would probably not work directly this way...you might have to play around a bit to achieve that....


Also, check out the "Undocumented qmake" page (http://wiki.qtcentre.org/index.php?title=Undocumented_qmake) in the wiki.

vermarajeev
23rd February 2007, 14:04
[QUOTE=camel;30002]You can build that using extra targets, i.e. you should be able to embedd it directly into the project2.pro...could look something like this:


makeproject.target = WHATEVER_THAT_MAKEFILE_PRODUCES
makeproject.commands = make NAME_OF_MAKEFILE
makeproject.depends = WHICH_FILES_THE_TARGET_DEPENDS_ON

QMAKE_EXTRA_TARGETS += makeproject
PRE_TARGETDEPS += makeproject


I tried something like this but there is some problem.

First the path where my project is present

raj
|
|
cmb
|
|-->source //This is a directory
|
|-->cryp //This is another directory
|
|-->cmb.pro //This is what I'll give to command prompt

so the path on my system is /raj/cmb/. Inside cmb directory there is source, cryp directory and a project file cmb.pro

Now I have put this information to cmb.pro

TEMPLATE = subdirs
SUBDIRS = \
cryp \
source

# install
sources.path = source/
INSTALLS += sources

Inside source directory there is a source.pro which contains

TEMPLATE = app
LANGUAGE = C++

CONFIG += qt warn_on debug

unix:LIBS += -lXext -lm

unix:LIBS += ../cryp/libcryp.a

DEFINES += SYNSUP_GUI

INCLUDEPATH += . ./common
INCLUDEPATH += ../cryp

HEADERS += atomgroup.h \

SOURCES += atomgroup.cpp \

FORMS = dlg/SynsupOptionsDlgData.ui \

win32:TMAKE_CFLAGS = -TP
win32:TMAKE_CXXFLAGS = -GX
win32:RC_FILE = chemedit.rc
CONFIG += non_threaded
TARGET = cmbedit

# install
target.path = ../source
sources.files = $$SOURCES $$HEADERS source.pro
sources.path = ../source
INSTALLS += target sources

Inside cryp directory there is a cryp.pro which contains.


makeproject.target = libcryp.a
makeproject.commands = make GNUmakefile
makeproject.depends = ../source/cmbedit
QMAKE_EXTRA_TARGETS += makeproject
PRE_TARGETDEPS += makeproject

Some explanation
libcryp.a is static library which is created from GNUMakefile.
GNUmakefile is the name of the makefile inside cryp directory.
../source/cmbedit--->here cmbedit is the name of the executable which is
produced after linking with libcryp.a.
source is a directory.

I get this error
[raj@fedora4 cmb]# qmake cmb.pro
[raj@fedora4 cmb]# make
cd cryp && make -f Makefile
make[1]: Entering directory
`raj/cmb/cryp'
make[1]: *** No rule to make target `makeproject', needed by `cryp'. Stop.
make[1]: Leaving directory
`raj/cmb/cryp'
make: *** [sub-cryp] Error 2
[raj@fedora4 cmb]#

vermarajeev
26th February 2007, 04:00
Hi camel,
Where r u lost??? Can you please help me with this...

wysota
26th February 2007, 11:09
AFAIR those fields might need to be fed with a variable name holding the list of dependencies/inputs/etc. Something like:


PROJDEPS = ../source/cmbedit
makeproject.depends = PROJDEPS

I personally use something like this:

COMMS = $$find(HEADERS, ws.*)
COMM = webservice.cpp

cmh_c.output = hashes.h
cmh_c.input = COMM
cmh_c.commands = $${CMDHASHER} $${COMMS} hashes.h
cmh_c.depends = $${CMDHASHER} $${COMMS}
cmh_c.CONFIG = no_link
cmh_c.variable_out = HEADERS

QMAKE_EXTRA_COMPILERS += cmh_c

Don't forget about the input field.

vermarajeev
26th February 2007, 13:48
Hi wysota,
I'm totally bugged

I have been trying all the way long but not able to get.
Lets make things simpler

Now suppose I have a GNUmakefile in one folder(folder1) and a project file (test.pro)
in another folder(folder2).

NOTE: GNUmakefile contains all the information for creating the target

What commands I should provide in test.pro to run GNUmakefile (present in folder2)that
creates the target in folder2????

wysota
26th February 2007, 14:54
This works for me:

PRE_TARGETDEPS += dummy
MKFL = ../test2/Makefile
tst.input = MKFL
tst.commands = cd ../test2 && make
tst.CONFIG = no_link
tst.output = dummy

QMAKE_EXTRA_COMPILERS += tst

camel
26th February 2007, 20:21
Hi camel,
Where r u lost???

I had a nice weekend without a computer (most of the time ;-)


Now I am back, but it seems I am not needed anymore...bummer... ;-)


Did wysota solution work?

vermarajeev
27th February 2007, 03:29
This works for me:
Not on my system :crying:

I tried putting


PRE_TARGETDEPS += dummy
MKFL = ../cryp/GNUmakefile //cryp is a directory where the GNUmakefile is present
tst.input = MKFL
tst.commands = cd ../cryp && make
tst.CONFIG = no_link
tst.output = dummy

QMAKE_EXTRA_COMPILERS += tst
in ce.pro (project file)

I get this error

[raj@fedora4 cmbedit]# qmake ce.pro
[raj@fedora4 cmbedit]# make clean
rm -f *~ core *.core
[raj@fedora4 cmbedit]# make
make: *** No rule to make target `dummy', needed by `ce'. Stop.
[raj@fedora4 cmbedit]#

By the way I think the problem is with version.
I have qt3.3.5 on my system. Will the above soultion work for it(Qt3.3.5)???

I have attached GNUmakefile. I dont think there is any problem with it.

vermarajeev
27th February 2007, 03:32
Oh!! where is the attachement lost????

Never mind I think there is no need, as GNUmakefile work properly for me where I say make to the path where GNUmakefile is present...

How can I solve the problem as specified in above post???

vermarajeev
27th February 2007, 04:03
Not on my system :crying:

I tried putting


PRE_TARGETDEPS += dummy
MKFL = ../cryp/GNUmakefile //cryp is a directory where the GNUmakefile is present
tst.input = MKFL
tst.commands = cd ../cryp && make
tst.CONFIG = no_link
tst.output = dummy

QMAKE_EXTRA_COMPILERS += tst
in ce.pro (project file)

I get this error

[raj@fedora4 cmbedit]# qmake ce.pro
[raj@fedora4 cmbedit]# make clean
rm -f *~ core *.core
[raj@fedora4 cmbedit]# make
make: *** No rule to make target `dummy', needed by `ce'. Stop.
[raj@fedora4 cmbedit]#

By the way I think the problem is with version.
I have qt3.3.5 on my system. Will the above soultion work for it(Qt3.3.5)???

I have attached GNUmakefile. I dont think there is any problem with it.

By the way what is that dummy????
I went through Qt Assistance and found this

PRE_TARGETDEPS
All libraries that the target depends on can be listed in this variable. Some backends do not support this, these include MSVC Dsp, and ProjectBuilder .pbproj files. Generally this is support internally by these build tools, this is usefull for explicitly listing dependant static libraries.
This list will go before all builtin dependencies.

I think the above commands will work with qt3.3.5. I got to know after I went through Qt assistance. I'm just trying out something. Let's see if it works....

vermarajeev
27th February 2007, 06:31
I used this and it runs the makefile

PRE_TARGETDEPS += libcryp.a
MKFL = cryptoPP/GNUmakefile
tst.input = MKFL
tst.commands = cd cryptoPP/ && make
tst.CONFIG = no_link
tst.output = libcryp.a
QMAKE_EXTRA_UNIX_COMPILERS += tst

It creates the static library libcryp.a. Evenrything goes on fine
but at last this error occurs


[raj@fedora4 cmbedit]# qmake ce.pro
[raj@fedora4 cmbedit]# make clean
rm -f *~ core *.core
[raj@fedora4 cmbedit]# make
cd cryptoPP/ && make
make[1]: Entering directory `/raj/rajTest/cmbedit/cryptoPP'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/raj/rajTest/cmbedit/cryptoPP'
g++ -o ce -L/usr/lib/qt-3.3/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../crt1.o(.text+0x18): In function
`_start':
: undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [ce] Error 1

What is wrong here now???

camel
27th February 2007, 09:18
make[1]: Leaving directory `/raj/rajTest/cmbedit/cryptoPP'
g++ -o ce -L/usr/lib/qt-3.3/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../crt1.o(.text+0x18): In function
`_start':
: undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [ce] Error 1

What is wrong here now???

I had these kind of problems, when I had an "empty" pro file. i.e. when I had no targets/sources in the file itself.

Qmake tries to compile "No Source File", and then tries to link it. Of course, when you do not have no source, you did not define a main function...which your linker complains about.

Add your real project infos to the pro file and the problem should vanish...

wysota
27th February 2007, 11:35
I missed that the problem regards Qt3... It won't work as qmake3 uses different variable names. You should consult the docs to see if you can convert the solution to Qt3.

vermarajeev
28th February 2007, 03:00
I missed that the problem regards Qt3... It won't work as qmake3 uses different variable names. You should consult the docs to see if you can convert the solution to Qt3.


PRE_TARGETDEPS += libcryp.a
MKFL = cryptoPP/GNUmakefile
tst.input = MKFL
tst.commands = cd cryptoPP/ && make
tst.CONFIG = no_link
tst.output = libcryp.a
QMAKE_EXTRA_UNIX_COMPILERS += tst

I think the problem is with this statement
tst.CONFIG = no_link

I tried looking for it in Qt3.3.5 but couldnt find. I googled to find this

Not linking with the output of QMAKE_EXTRA_UNIX_COMPILERS
qmake assumes that the output of the extra compilers is destined to be linked into the final library or application. If this isn't the case, then you need to do something to stop it.

If "mycompiler" is the name of your compiler compound variable, then if you have a member .CONFIG set to no_link, then the output won't get linked. Example.

mycompiler.output = ${QMAKE_FILE_BASE}.out
mycompiler.input = MYCOMPILER_INPUT_FILES
mycompiler.commands = foo ${QMAKE_FILE_NAME}
mycompiler.CONFIG = no_link
QMAKE_EXTRA_UNIX_COMPILERS += my_compiler

Examples when you might want to do this are for things like generating documentation.

This is related to Qt4.. What should I replace with no_link in Qt3.3.5 to resolve the above problem.

Hi camel I tried what you have suggested but I get the same error as shown in above post.
Is there any way out???