cmake + Qt 5 编译出错,请帮忙看看怎么解决
1个回答
展开全部
Qt在编译时,需要首先使用uic.exe编译UI文件,通过moc.exe处理Q_OBJECT之类的宏,当然你可以去掉这些定义,否则就需要加上:
# COMPILE UIs
SET(UIS
mnwindow
)
FOREACH (ui_file ${UIS})
SET(TMP_IN "${PROJECT_SOURCE_DIR}/res/${ui_file}.ui")
SET(TMP_OUT "${PROJECT_BINARY_DIR}/ui_${ui_file}.h")
EXECUTE_PROCESS(COMMAND ${QT_FOLDER}/bin/uic.exe -o ${TMP_OUT} ${TMP_IN})
MESSAGE(STATUS "EXEC=${QT_FOLDER}/bin/uic.exe -o ${PROJECT_BINARY_DIR}/ui_${ui_file}.h ${PROJECT_SOURCE_DIR}/res/${ui_file}.ui")
ENDFOREACH(ui_file)
# CREATE MOC
SET(HEADERS
mainwindow
)
FOREACH (header_file ${HEADERS})
SET(TMP_IN "${PROJECT_SOURCE_DIR}/inc/${header_file}.h")
SET(TMP_OUT "${PROJECT_BINARY_DIR}/moc_${header_file}.cpp")
EXECUTE_PROCESS(COMMAND ${QT_FOLDER}/bin/moc.exe -o ${TMP_OUT} ${TMP_IN})
SET(MOCS ${MOCS} ${PROJECT_BINARY_DIR}/moc_${header_file}.cpp)
MESSAGE(STATUS "EXEC=${QT_FOLDER}/bin/moc.exe -o ${PROJECT_BINARY_DIR}/moc_${header_file}.cpp ${PROJECT_SOURCE_DIR}/inc/${header_file}.h")
ENDFOREACH(header_file)
free c#.net qr creator
这里要注意的是:EXECUTE_PROCESS在COMMAND后面不能加引号,命令直接写,否则执行的程序也不会出错,但也不会正常运行.
# COMPILE UIs
SET(UIS
mnwindow
)
FOREACH (ui_file ${UIS})
SET(TMP_IN "${PROJECT_SOURCE_DIR}/res/${ui_file}.ui")
SET(TMP_OUT "${PROJECT_BINARY_DIR}/ui_${ui_file}.h")
EXECUTE_PROCESS(COMMAND ${QT_FOLDER}/bin/uic.exe -o ${TMP_OUT} ${TMP_IN})
MESSAGE(STATUS "EXEC=${QT_FOLDER}/bin/uic.exe -o ${PROJECT_BINARY_DIR}/ui_${ui_file}.h ${PROJECT_SOURCE_DIR}/res/${ui_file}.ui")
ENDFOREACH(ui_file)
# CREATE MOC
SET(HEADERS
mainwindow
)
FOREACH (header_file ${HEADERS})
SET(TMP_IN "${PROJECT_SOURCE_DIR}/inc/${header_file}.h")
SET(TMP_OUT "${PROJECT_BINARY_DIR}/moc_${header_file}.cpp")
EXECUTE_PROCESS(COMMAND ${QT_FOLDER}/bin/moc.exe -o ${TMP_OUT} ${TMP_IN})
SET(MOCS ${MOCS} ${PROJECT_BINARY_DIR}/moc_${header_file}.cpp)
MESSAGE(STATUS "EXEC=${QT_FOLDER}/bin/moc.exe -o ${PROJECT_BINARY_DIR}/moc_${header_file}.cpp ${PROJECT_SOURCE_DIR}/inc/${header_file}.h")
ENDFOREACH(header_file)
free c#.net qr creator
这里要注意的是:EXECUTE_PROCESS在COMMAND后面不能加引号,命令直接写,否则执行的程序也不会出错,但也不会正常运行.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询