How to Exclude /usr/include Path from Linux Application?

点点圈 提交于 2020-01-04 06:06:10

问题


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 :)


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/8143829/how-to-exclude-usr-include-path-from-linux-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!