明明安装了gcc和g++,版本是4.9.2 系统debian8
qmake -v
qmake myproject.pro 无任何报错
make
编译没有问题,链接的时候报错:
/usr/local/Qt-5.10.0/bin/moc -DLINUX -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_NETWORK_LIB -DQT_CORE_LIB --include ./moc_predefs.h -I/usr/local/Qt-5.10.0/mkspecs/linux-g++ -I/root/hz3000v2.5/trunk/source/dts/debug_info_srv -I/root/hz3000v2.5/trunk/source/dts/common -I/root/hz3000v2.5/trunk/include/hnstd -I/root/hz3000v2.5/trunk/include/boost_include -I/root/hz3000v2.5/trunk/source/dts/debug_info_srv -I/usr/local/Qt-5.10.0/include -I/usr/local/Qt-5.10.0/include/QtNetwork -I/usr/local/Qt-5.10.0/include/QtCore -I/usr/include/c++/4.9 -I/usr/include/i386-linux-gnu/c++/4.9 -I/usr/include/c++/4.9/backward -I/usr/lib/gcc/i586-linux-gnu/4.9/include -I/usr/local/include -I/usr/lib/gcc/i586-linux-gnu/4.9/include-fixed -I/usr/include/i386-linux-gnu -I/usr/include tcp_server.h -o moc_tcp_server.cpp
usr/include/c++/4.9/bits/stl_relops.:67: Parse error at "std"
Makefile:579: recipe for target 'moc_tcp_server.cpp' failed
make: *** [moc_tcp_server.cpp] Error 1
看上面的提示的stl_relops.文件名很可疑,没有h结尾,感觉被截断。一通搜索后,有些人说要改mkspecs里面的QMAKE_DEFAULT_INCDIRS,添加gcc、g++相关的include目录,感觉这个也太麻烦了,32和64bit的目录又各不相同,感觉手工添加会是一个隐患。
于是,一通google之后发现,qmake会在工程目录下生成.qmake.stash,删掉这个文件,重新qmake myproject.pro,会重新生成这个文件
qmake myproject.pro
Info: creating stash file /root/myproject/.qmake.stash
重新生成后编译一切正常。怀疑之前安装Qt的不同目录(我之前将Qt安装在home目录下,现在通通安装到/usr/local去了),生成的这个隐藏文件有毛病。
是老外的这个文章给了启发,附上链接,尊重人家的版权
http://www.logikalsolutions.com/wordpress/information-technology/moc-parse-error-at-std/