Results 1 to 4 of 4

Thread: Qt +CMake+ gmock build issue“gmock.h no such file or diretory” while building in Qt

  1. #1
    Join Date
    Oct 2014
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Qt +CMake+ gmock build issue“gmock.h no such file or diretory” while building in Qt

    I have incorporated GTest in my already existing CMake project by following this google doc( https://github.com/google/googletest...-cmake-project)

    If I build my project through the command line there is no error, I am able to run UnitTest Exe. But as I need to debug the unit test, when I run the test in Qt Creator it builds it first but the build failed, throwing the error "gmock/h: no such file or directory". I am not able to understand why this error on Qt Creator only. As few stackoverflow post suggests only gmock.h should get included, that is already there.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,851
    Thanks
    270
    Thanked 787 Times in 777 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Qt +CMake+ gmock build issue“gmock.h no such file or diretory” while building in

    Did you tell Qt Creator where to find your missing header file? Your CMakelists.txt file probably has a target_include_directories() entry that tells CMake where to find it. You need to do the equivalent thing in your Qt project .pro file.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,692
    Thanks
    13
    Thanked 1,599 Times in 1,527 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt +CMake+ gmock build issue“gmock.h no such file or diretory” while building in

    Quote Originally Posted by piyush bisen View Post
    If I build my project through the command line there is no error, I am able to run UnitTest Exe. But as I need to debug the unit test, when I run the test in Qt Creator it builds it first but the build failed, throwing the error "gmock/h: no such file or directory". I am not able to understand why this error on Qt Creator only. As few stackoverflow post suggests only gmock.h should get included, that is already there.
    It seems to me that the error message is self-explanatory "gmock/h" is not "gmock.h" and is very unlikely to be a file. Find where your code references "gmock/h" and fix the typo.

    Whether this message occurs in any given build/build environment will depend on whether the offending statement is ever parsed, it may be conditionally compiled (inside #ifdef for example.)
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,851
    Thanks
    270
    Thanked 787 Times in 777 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Qt +CMake+ gmock build issue“gmock.h no such file or diretory” while building in

    It seems to me that the error message is self-explanatory "gmock/h" is not "gmock.h" and is very unlikely to be a file. Find where your code references "gmock/h" and fix the typo.
    I assumed that the "gmock/h" was a typo in the post, not a typo in the code, since the OP said the code builds under the CMake toolchain. If it was a code typo, it wouldn't build in either place.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 0
    Last Post: 15th July 2015, 08:56
  2. How build Qt with CMake & MinGW in windows?
    By jennal in forum Qt Programming
    Replies: 4
    Last Post: 15th December 2014, 02:19
  3. Problem while building Qt5 with cmake
    By alizadeh91 in forum Installation and Deployment
    Replies: 1
    Last Post: 20th September 2012, 13:23
  4. file and diretory view
    By hbill in forum Qt Programming
    Replies: 15
    Last Post: 18th November 2008, 18:18
  5. build project with cmake does not work
    By codebehind in forum Qt Programming
    Replies: 4
    Last Post: 18th August 2008, 13:29

Tags for this Thread

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.