Error while compiling QtProject under openSUSE

268 Views Asked by At

I've tried to compile my project under openSUSE using a CMAKE to generate the makefile.

Now, I got this error. Can somebody help me out here?

[ 18%] Building CXX object VSProjects/PROJECT/CMakeFiles/PROJECT.dir/src/Activity/ActivityFactory.cpp.o
In file included from /home/martin/Qt/5.8/gcc_64/include/QtCore/qglobal.h:97:0,
                 from /home/martin/Qt/5.8/gcc_64/include/QtCore/qchar.h:43,
                 from /home/martin/Qt/5.8/gcc_64/include/QtCore/qstring.h:48,
                 from /home/martin/Qt/5.8/gcc_64/include/QtCore/QString:1,
                 from /home/martin/VSProjects/PROJECT/src/Activity/ActivityFactory.cpp:51:
/home/martin/Qt/5.8/gcc_64/include/QtCore/qglobal.h:357:1: error: expected constructor, destructor, or type conversion before ‘(’ token
 Q_CORE_EXPORT const char *qVersion() Q_DECL_NOTHROW;
 ^
/home/martin/Qt/5.8/gcc_64/include/QtCore/qglobal.h:649:12: error: expected constructor, destructor, or type conversion before ‘(’ token
 Q_NORETURN Q_CORE_EXPORT void qTerminate() Q_DECL_NOTHROW;
            ^
/home/martin/Qt/5.8/gcc_64/include/QtCore/qglobal.h:657:1: error: expected constructor, destructor, or type conversion before ‘(’ token
 Q_CORE_EXPORT bool qSharedBuild() Q_DECL_NOTHROW;
 ^
/home/martin/Qt/5.8/gcc_64/include/QtCore/qglobal.h:697:1: error: expected constructor, destructor, or type conversion before ‘(’ token
 Q_CORE_EXPORT QString qt_error_string(int errorCode = -1);
 ^
/home/martin/Qt/5.8/gcc_64/include/QtCore/qglobal.h:702:1: error: expected constructor, destructor, or type conversion before ‘(’ token
 Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line) Q_DECL_NOTHROW;
 ^
/home/martin/Qt/5.8/gcc_64/include/QtCore/qglobal.h:719:1: error: expected constructor, destructor, or type conversion before ‘(’ token
 Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *file, int line) Q_DECL_NOTHROW;
 ^
/home/martin/Qt/5.8/gcc_64/include/QtCore/qglobal.h:750:1: error: expected constructor, destructor, or type conversion before ‘(’ token
 Q_CORE_EXPORT void qt_check_pointer(const char *, int);
 ^
/home/martin/Qt/5.8/gcc_64/include/QtCore/qglobal.h:751:1: error: expected constructor, destructor, or type conversion before ‘(’ token
 Q_CORE_EXPORT void qBadAlloc();
2

There are 2 best solutions below

1
On

I digged into the CMakeLists.txt and figured out, that one colluege has added -DWIN64 to the Compiler Flag.

Qt is know thinking that it is compiling under Windows and addes the "Q_OS_WIN" define

now the Q_CORE_EXPORT is looking for the __declspec macro...

0
On

You are calling these functions: *qVersion(); qTerminate(); qt_error_string(); etc..

It seems you are not calling them in the right place (expected constructor, destructor, or type conversion before ‘(’ ), must be declare inside of a function:

bool someclass() 
{ 
 qSharedBuild(); --bool type
 return false;
}