Search code examples
c++qtboostcpputest

Weird behaviour when compiling CppUTest tests for application using Qt and Boost


I've following problem. When I try to compile .so library everything works fine.

Scanning dependencies of target logger
[ 11%] Building CXX object CMakeFiles/logger.dir/src/defaultconfig.cpp.o
[ 22%] Building CXX object CMakeFiles/logger.dir/src/loggerstate.cpp.o
[ 33%] Building CXX object CMakeFiles/logger.dir/src/configmanager.cpp.o
[ 44%] Building CXX object CMakeFiles/logger.dir/src/configuration.cpp.o
[ 55%] Building CXX object CMakeFiles/logger.dir/src/formatter.cpp.o
[ 66%] Building CXX object CMakeFiles/logger.dir/src/levelmap.cpp.o
[ 77%] Building CXX object CMakeFiles/logger.dir/src/logger.cpp.o
[ 88%] Building CXX object CMakeFiles/logger.dir/src/logworker.cpp.o
[100%] Linking CXX shared library liblogger.so
[100%] Built target logger

By when I try to create executable which use for example logger.cpp eg. test file I get wall of errors. Full log is here. However the most funny thing that it compiles on ones developer computer. We check compiler version, cmake version and everything is the same. The cpputest version wasn't the same.

Maybe anyone of you have face such problem and know what we doing wrong.


Solution

  • In file included from /opt/Qt5.3.2/5.3/gcc_64/include/QtCore/qobject.h:51:0,
                     from /opt/Qt5.3.2/5.3/gcc_64/include/QtCore/qabstractanimation.h:45,
                     from /opt/Qt5.3.2/5.3/gcc_64/include/QtCore/QtCore:4,
                     from /opt/Qt5.3.2/5.3/gcc_64/include/QtConcurrent/QtConcurrentDepends:2,
                     from /opt/Qt5.3.2/5.3/gcc_64/include/QtConcurrent/QtConcurrent:3,
                     from /tmp/Quantum/src/logger/include/logworker.h:5,
                     from /tmp/Quantum/src/logger/include/logger.h:5,
                     from /tmp/Quantum/src/logger/tests/logger_test.cpp:5:
    /opt/Qt5.3.2/5.3/gcc_64/include/QtCore/qlist.h: In member function ‘void QList<T>::node_construct(QList<T>::Node*, const T&)’:
    /opt/Qt5.3.2/5.3/gcc_64/include/QtCore/qlist.h:374:44: error: ‘n’ does not name a type
         else if (QTypeInfo<T>::isComplex) new (n) T(t);
                                                ^
    

    The error looks like the <new> header hasn't been included. Check that there isn't another file called "new" somewhere in the include paths, and check that no other headers define a macro like _NEW or _LIBCPP_NEW which would prevent <new> from being included correctly.

    You might need to compile one of the failing files with a flag such as -save-temps so you can examine the preprocessed output, to see which files are being included, and if their content is being included.

    You should also tell CMake to be verbose, so it prints the full compiler commands. It's useless to hide the details of the compilation if the compilation is failing - you need to know what's happening!