2

I am running into a problem I have not been able to avoid. Redhat 6 (or most linux packages) comes with a default QT package installed with headers/etc in the /usr/lib and /usr/include folders.

Now, I am wanting to link against a newer version of QT without removing the older version. Unfortunately, since the headers are in the /include/ folder, gcc automatically finds them, and then uses the wrong include files (instead of those which I have elsewhere).

I cannot seem to stop the compiler from automatically doing this. I have gotten around it previously by simply manually removing the old libraries/headers but this is a terrible solution long term.

I do not think this problem is specific to QT either, it just happens to be my current instance of it.

Any suggestions?

Many thanks :)

enderland
  • 13,825
  • 17
  • 98
  • 152
  • 2
    You just need to change the include flags to gcc - see http://stackoverflow.com/questions/558803/how-to-add-a-default-include-path-for-gcc-in-linux – Martin Beckett Nov 15 '11 at 22:12
  • I have done this, but when I compile the project I still get the /usr/include/QtCore etc paths and not the ones which are the CPLUS_LIBRARY_PATH ones. I'm not really sure what to do.. – enderland Nov 16 '11 at 22:23

2 Answers2

4

If you give the include directories of the newer Qt installation through -I option, it should be searched before the standard include directories (i.e. /usr/include, etc.) Removing the standard include directories from the search path completely is likely not a good idea because standard headers will also be found there (note that the Qt headers themselves most likely include standard headers and will not work if those are not found).

However if you really don't want the standard include directories to be searched, the option -nostdinc should do what you want.

celtschk
  • 19,311
  • 3
  • 39
  • 64
1

My issue turned out to be related to an incorrect version of qmake being used. It was finding a previous version of qmake, and even though it was from qt4, it was linking to the wrong includes.

Updating the qmake paths worked to fix this issue.

enderland
  • 13,825
  • 17
  • 98
  • 152
  • 1
    If this worked to solve your problem, go ahead and mark your answer as the accepted answer to let future viewers know what worked. – Nightfirecat Nov 17 '11 at 21:24
  • 2
    Yep, I was waiting to do so - it requires me to wait an hour or so after posting before being able to do this :) – enderland Nov 17 '11 at 22:47