[Qt-interest] qmake: problem building source files which share the same name

Bo Thorsen bo at fioniasoftware.dk
Wed Sep 7 15:44:15 CEST 2011


Den 07-09-2011 15:13, Rui Maciel skrev:
> I have a C++ project that contains two files which happen to share the same
> name, although they are located in separate parts of the source code tree.
> Those source code files are used to define two separate classes, which also
> share the same name but are included in different namespaces.
>
> When I ran qmake there wasn't a single warning.  Yet, running make triggered
> a set of errors regarding how some methods weren't defined.  After a bit of
> prodding I've noticed that if I renamed one of those source files which
> shared their name (and tweaked all project accordingly) to a unique name
> then the build succeeded without a single hitch.
>
> This leads me to suspect that qmake isn't able to handle source files which
> share their file name.  Is this true?

Yes.

The reason is that qmake puts all the object files from the compiler in 
the same directory.

I agree completely qmake should at least warn about this problem, maybe 
even treat it as an error. But that's not the case, unfortunately. You 
could write a bug report about this, if it doesn't already exist.

> If it is, what strategies are there,
> besides renaming the file, that let the user side-step this sort of problem?

None. You rename the files.

Well, you can do this by creating a static library by one project and 
link to this project with the other project. In that case, there is of 
course no problem with the two having the same filename, if the build 
dir isn't also named the same.

But when you use .pri files, you just have to accept that you can't have 
two cpp files with the same name. Probably also goes for ui files, qrc 
files etc.

Bo Thorsen,
Fionia Software.

-- 

Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk



More information about the Qt-interest-old mailing list