The Ultimate Qt Community site
Home News Forum Wiki Contest FAQ Links

Go Back   Qt Centre Forum > Qt > Qt Programming

Qt Programming General Qt programming issues.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 30th October 2007, 13:29
PowerKiKi PowerKiKi is offline
Beginner
 
Join Date: Apr 2007
Qt products used: Qt4
Qt platforms used: Windows
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default object files' names collision

Hi,
I came across a problem with qmake and Makefile.

I have this kind of directory structure :
Qt Code:
  1. src/NameSpace1/builder.cpp
  2. src/NameSpace2/builder.cpp
Some statements :
  • There is many namespaces
  • Each namespace has its own directory
  • Each namespace is owned by a developper who is responsible for it
  • Developpers don't know what's in others' namepsaces

As you can see in the sample, some name collisions will happen. There is no problem at the C++ level, but during the compilation stage some targets will have the same name.
For instance:
Qt Code:
  1. $> qmake -project "DESTDIR = debug" -o MyApp.pro && qmake
  2. $> make
It will output all object files in debug/. Considering the first example, it will be two same targets "debug/builder.o".


Is there any easy solution to create the same directory structure for object files as the source files ?

It should be something like that:
Qt Code:
  1. debug/NameSpace1/builder.o
  2. debug/NameSpace2/builder.o

Reply With Quote
  #2  
Old 30th October 2007, 13:42
high_flyer high_flyer is offline
Expert
 
Join Date: Jan 2006
Location: Munich, Germany
Qt products used: Qt3, Qt4
Qt platforms used: Unix/X11, Windows
Posts: 1,169
Thanks: 16
Thanked 85 Times in 85 Posts
Default Re: object files' names collision

you can use the OBJECTS_DIR and MOC_DIR tags in the pro file of each subproject (we are talking about sub projects here right?)
__________________
Archimedes
Reply With Quote
  #3  
Old 30th October 2007, 14:10
PowerKiKi PowerKiKi is offline
Beginner
 
Join Date: Apr 2007
Qt products used: Qt4
Qt platforms used: Windows
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default Re: object files' names collision

Unfotunately we're not talking about subprojects. We have a single .pro files as we build a single programm (no DLL).

OBJECTS_DIR seems to be working only if we had a .pro file per namespace. Is it somehow possible ? Having many .pro files sounds a bit ackward in this case, doesn't it ?

What I'm looking for basically is a way to tell what object file path I want for every single src file.

Reply With Quote
  #4  
Old 30th October 2007, 14:50
high_flyer high_flyer is offline
Expert
 
Join Date: Jan 2006
Location: Munich, Germany
Qt products used: Qt3, Qt4
Qt platforms used: Unix/X11, Windows
Posts: 1,169
Thanks: 16
Thanked 85 Times in 85 Posts
Default Re: object files' names collision

Quote:
What I'm looking for basically is a way to tell what object file path I want for every single src file.
I don't *know*, but I *think* this is not possible with qmake (*.pro) file.
If you are not willing or can't use a diferent project structre, then you will have to give up on atuomation, and use a custom hand made makefile.
There you can define each o file.

But to me, your project structure makes little sense.
Either use deferent development branches to the same project, or/and use sub projects - that would be my advice..
__________________
Archimedes
Reply With Quote
  #5  
Old 30th October 2007, 15:25
wysota wysota is offline
Guru
 
Join Date: Jan 2006
Location: Warsaw, Poland
Qt products used: Qt3, Qt4
Qt platforms used: Unix/X11, Windows
Posts: 11,590
Thanks: 3
Thanked 1,629 Times in 1,581 Posts
Default Re: object files' names collision

The problem is not with qmake but with make. I suggest you either rename one of the files or separate your build into subprojects consisting of static libraries which you can then link together to form the final binary code.

Reply With Quote
The following user says thank you to wysota for this useful post:
PowerKiKi (30th October 2007)
  #6  
Old 30th October 2007, 17:02
PowerKiKi PowerKiKi is offline
Beginner
 
Join Date: Apr 2007
Qt products used: Qt4
Qt platforms used: Windows
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
Default Re: object files' names collision

I guess I'll go for static library option. Thank you for that suggestion.

But still I don't get why my approach isn't supported. I'd say it's rather an easy obvious way to separate developpers' code without the need of "complicated" library linking.

Reply With Quote
  #7  
Old 30th October 2007, 19:20
elcuco elcuco is offline
Advanced user
 
Join Date: Jan 2006
Qt products used: Qt4
Qt platforms used: Unix/X11, Windows
Posts: 304
Thanks: 12
Thanked 13 Times in 13 Posts
Default Re: object files' names collision

To any of the CMake gurus:

Is this possible under CMake? I will give it a try tomorrow.

Reply With Quote
  #8  
Old 30th October 2007, 22:32
wysota wysota is offline
Guru
 
Join Date: Jan 2006
Location: Warsaw, Poland
Qt products used: Qt3, Qt4
Qt platforms used: Unix/X11, Windows
Posts: 11,590
Thanks: 3
Thanked 1,629 Times in 1,581 Posts
Default Re: object files' names collision

Quote:
Originally Posted by PowerKiKi View Post
But still I don't get why my approach isn't supported. I'd say it's rather an easy obvious way to separate developpers' code without the need of "complicated" library linking.
I'd say an obvious way is to use branches in your code repository.

Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 19:18.

Powered by vBulletin Version 3.7.1 Copyright ©2000 - 2008, Jelsoft Enterprises Ltd., vRewrite 1.5 SEOed URLs completed by Tech Help Forum and Chalo Na.
© 2006–2008 Qt Centre - The Ultimate Qt Community site
Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.