Results 1 to 15 of 15

Thread: Building the entire project

  1. #1
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Building the entire project

    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
    Qt Code:
    1. qmake Project1.pro
    2. make clean
    3. make
    To copy to clipboard, switch view to plain text mode 
    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

  2. #2
    Join Date
    Jan 2006
    Posts
    128
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Building the entire project

    Quote Originally Posted by vermarajeev View Post
    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:
    Qt Code:
    1. makeproject.target = WHATEVER_THAT_MAKEFILE_PRODUCES
    2. makeproject.commands = make NAME_OF_MAKEFILE
    3. makeproject.depends = WHICH_FILES_THE_TARGET_DEPENDS_ON
    4.  
    5. QMAKE_EXTRA_TARGETS += makeproject
    6. PRE_TARGETDEPS += makeproject
    To copy to clipboard, switch view to plain text mode 

    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 in the wiki.

  3. #3
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Building the entire project

    [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:
    Qt Code:
    1. makeproject.target = WHATEVER_THAT_MAKEFILE_PRODUCES
    2. makeproject.commands = make NAME_OF_MAKEFILE
    3. makeproject.depends = WHICH_FILES_THE_TARGET_DEPENDS_ON
    4.  
    5. QMAKE_EXTRA_TARGETS += makeproject
    6. PRE_TARGETDEPS += makeproject
    To copy to clipboard, switch view to plain text mode 

    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
    Qt Code:
    1. TEMPLATE = subdirs
    2. SUBDIRS = \
    3. cryp \
    4. source
    5.  
    6. # install
    7. sources.path = source/
    8. INSTALLS += sources
    To copy to clipboard, switch view to plain text mode 

    Inside source directory there is a source.pro which contains
    Qt Code:
    1. TEMPLATE = app
    2. LANGUAGE = C++
    3.  
    4. CONFIG += qt warn_on debug
    5.  
    6. unix:LIBS += -lXext -lm
    7.  
    8. unix:LIBS += ../cryp/libcryp.a
    9.  
    10. DEFINES += SYNSUP_GUI
    11.  
    12. INCLUDEPATH += . ./common
    13. INCLUDEPATH += ../cryp
    14.  
    15. HEADERS += atomgroup.h \
    16.  
    17. SOURCES += atomgroup.cpp \
    18.  
    19. FORMS = dlg/SynsupOptionsDlgData.ui \
    20.  
    21. win32:TMAKE_CFLAGS = -TP
    22. win32:TMAKE_CXXFLAGS = -GX
    23. win32:RC_FILE = chemedit.rc
    24. CONFIG += non_threaded
    25. TARGET = cmbedit
    26.  
    27. # install
    28. target.path = ../source
    29. sources.files = $$SOURCES $$HEADERS source.pro
    30. sources.path = ../source
    31. INSTALLS += target sources
    To copy to clipboard, switch view to plain text mode 

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

    Qt Code:
    1. makeproject.target = libcryp.a
    2. makeproject.commands = make GNUmakefile
    3. makeproject.depends = ../source/cmbedit
    4. QMAKE_EXTRA_TARGETS += makeproject
    5. PRE_TARGETDEPS += makeproject
    To copy to clipboard, switch view to plain text mode 

    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]#

  4. #4
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Building the entire project

    Hi camel,
    Where r u lost??? Can you please help me with this...

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Building the entire project

    AFAIR those fields might need to be fed with a variable name holding the list of dependencies/inputs/etc. Something like:

    Qt Code:
    1. PROJDEPS = ../source/cmbedit
    2. makeproject.depends = PROJDEPS
    To copy to clipboard, switch view to plain text mode 

    I personally use something like this:
    Qt Code:
    1. COMMS = $$find(HEADERS, ws.*)
    2. COMM = webservice.cpp
    3.  
    4. cmh_c.output = hashes.h
    5. cmh_c.input = COMM
    6. cmh_c.commands = $${CMDHASHER} $${COMMS} hashes.h
    7. cmh_c.depends = $${CMDHASHER} $${COMMS}
    8. cmh_c.CONFIG = no_link
    9. cmh_c.variable_out = HEADERS
    10.  
    11. QMAKE_EXTRA_COMPILERS += cmh_c
    To copy to clipboard, switch view to plain text mode 

    Don't forget about the input field.

  6. #6
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Building the entire project

    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????

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Building the entire project

    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

  8. #8
    Join Date
    Jan 2006
    Posts
    128
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Building the entire project

    Quote Originally Posted by vermarajeev View Post
    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?

  9. #9
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Building the entire project

    Quote Originally Posted by wysota View Post
    This works for me:
    Not on my system

    I tried putting

    Qt Code:
    1. PRE_TARGETDEPS += dummy
    2. MKFL = ../cryp/GNUmakefile //cryp is a directory where the GNUmakefile is present
    3. tst.input = MKFL
    4. tst.commands = cd ../cryp && make
    5. tst.CONFIG = no_link
    6. tst.output = dummy
    7.  
    8. QMAKE_EXTRA_COMPILERS += tst
    To copy to clipboard, switch view to plain text mode 
    in ce.pro (project file)

    I get this error
    Qt Code:
    1. [raj@fedora4 cmbedit]# qmake ce.pro
    2. [raj@fedora4 cmbedit]# make clean
    3. rm -f *~ core *.core
    4. [raj@fedora4 cmbedit]# make
    5. make: *** No rule to make target `dummy', needed by `ce'. Stop.
    6. [raj@fedora4 cmbedit]#
    To copy to clipboard, switch view to plain text mode 

    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.

  10. #10
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Building the entire project

    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???

  11. #11
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Building the entire project

    Quote Originally Posted by vermarajeev View Post
    Not on my system

    I tried putting

    Qt Code:
    1. PRE_TARGETDEPS += dummy
    2. MKFL = ../cryp/GNUmakefile //cryp is a directory where the GNUmakefile is present
    3. tst.input = MKFL
    4. tst.commands = cd ../cryp && make
    5. tst.CONFIG = no_link
    6. tst.output = dummy
    7.  
    8. QMAKE_EXTRA_COMPILERS += tst
    To copy to clipboard, switch view to plain text mode 
    in ce.pro (project file)

    I get this error
    Qt Code:
    1. [raj@fedora4 cmbedit]# qmake ce.pro
    2. [raj@fedora4 cmbedit]# make clean
    3. rm -f *~ core *.core
    4. [raj@fedora4 cmbedit]# make
    5. make: *** No rule to make target `dummy', needed by `ce'. Stop.
    6. [raj@fedora4 cmbedit]#
    To copy to clipboard, switch view to plain text mode 

    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
    Qt Code:
    1. PRE_TARGETDEPS
    2. 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.
    3. This list will go before all builtin dependencies.
    To copy to clipboard, switch view to plain text mode 

    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....

  12. #12
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Building the entire project

    I used this and it runs the makefile
    Qt Code:
    1. PRE_TARGETDEPS += libcryp.a
    2. MKFL = cryptoPP/GNUmakefile
    3. tst.input = MKFL
    4. tst.commands = cd cryptoPP/ && make
    5. tst.CONFIG = no_link
    6. tst.output = libcryp.a
    7. QMAKE_EXTRA_UNIX_COMPILERS += tst
    To copy to clipboard, switch view to plain text mode 

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

    Qt Code:
    1. [raj@fedora4 cmbedit]# qmake ce.pro
    2. [raj@fedora4 cmbedit]# make clean
    3. rm -f *~ core *.core
    4. [raj@fedora4 cmbedit]# make
    5. cd cryptoPP/ && make
    6. make[1]: Entering directory `/raj/rajTest/cmbedit/cryptoPP'
    7. make[1]: Nothing to be done for `all'.
    8. make[1]: Leaving directory `/raj/rajTest/cmbedit/cryptoPP'
    9. g++ -o ce -L/usr/lib/qt-3.3/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm
    10. /usr/lib/gcc/i386-redhat-linux/4.0.0/../../../crt1.o(.text+0x18): In function
    11. `_start':
    12. : undefined reference to `main'
    13. collect2: ld returned 1 exit status
    14. make: *** [ce] Error 1
    To copy to clipboard, switch view to plain text mode 
    What is wrong here now???

  13. #13
    Join Date
    Jan 2006
    Posts
    128
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Building the entire project

    Quote Originally Posted by vermarajeev View Post
    Qt Code:
    1. make[1]: Leaving directory `/raj/rajTest/cmbedit/cryptoPP'
    2. g++ -o ce -L/usr/lib/qt-3.3/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm
    3. /usr/lib/gcc/i386-redhat-linux/4.0.0/../../../crt1.o(.text+0x18): In function
    4. `_start':
    5. : undefined reference to `main'
    6. collect2: ld returned 1 exit status
    7. make: *** [ce] Error 1
    To copy to clipboard, switch view to plain text mode 
    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...

  14. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Building the entire project

    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.

  15. #15
    Join Date
    Sep 2006
    Posts
    339
    Thanks
    15
    Thanked 21 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Building the entire project

    Quote Originally Posted by wysota View Post
    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.
    Qt Code:
    1. PRE_TARGETDEPS += libcryp.a
    2. MKFL = cryptoPP/GNUmakefile
    3. tst.input = MKFL
    4. tst.commands = cd cryptoPP/ && make
    5. tst.CONFIG = no_link
    6. tst.output = libcryp.a
    7. QMAKE_EXTRA_UNIX_COMPILERS += tst
    To copy to clipboard, switch view to plain text mode 

    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
    Qt Code:
    1. Not linking with the output of QMAKE_EXTRA_UNIX_COMPILERS
    2. 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.
    3.  
    4. 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.
    5.  
    6. mycompiler.output = ${QMAKE_FILE_BASE}.out
    7. mycompiler.input = MYCOMPILER_INPUT_FILES
    8. mycompiler.commands = foo ${QMAKE_FILE_NAME}
    9. mycompiler.CONFIG = no_link
    10. QMAKE_EXTRA_UNIX_COMPILERS += my_compiler
    11.  
    12. Examples when you might want to do this are for things like generating documentation.
    To copy to clipboard, switch view to plain text mode 

    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???

Similar Threads

  1. making new project qt4
    By !Ci in forum Qt Programming
    Replies: 1
    Last Post: 18th June 2009, 13:32
  2. how do i use a same project in multiple systems ?
    By nhatkhang in forum KDE Forum
    Replies: 6
    Last Post: 21st December 2006, 16:32
  3. Project generation on linux from QT Project
    By darpan in forum Qt Programming
    Replies: 6
    Last Post: 11th December 2006, 09:43
  4. Clean project deletes makefile
    By Djony in forum Qt Programming
    Replies: 2
    Last Post: 7th December 2006, 10:15
  5. Replies: 2
    Last Post: 11th July 2006, 14:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.