0

我刚刚在 Windows 7 上全新安装了以下工具:

  • MinGW / GCC 4.8.1
  • Qt 4.8.5
  • Qt 创作者 2.8.1

在 PATH 中有:C:\Qt\4.8.5\bin;C:\Qt\4.8.5\include;C:\Qt\4.8.5\lib;C:\MinGW\bin;

1) 我读到了关于 Qt 4.8 需要 GCC 4.6 的警告。我忽略了它,使用 GCC 4.8.1。所以这可能是一个问题。

2) 我成功安装了 Qt Creator。我成功构建了默认的 Qt GUI 应用程序。启动时出现错误:“程序意外完成。” 调试 在进入 main() 之前,我在qatomic_i386.h文件中的 QBasicAtomicInt::deref() 成员函数中遇到了分段错误。
如果我构建一个基于 cmake 的控制台应用程序,一切都很好。

3)如果我构建了以前的基于 Qt cmake 的项目(从命令行或从 Qt Creator),这就是我得到的(从树构建中):

我第一次运行 cmake:

MyPrj-build>cmake -G "MinGW Makefiles"  ..\MyPrj
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeMinGWFindMake.cmake:20 (message):
  sh.exe was found in your PATH, here:

  C:/Program Files (x86)/Git/bin/sh.exe

  For MinGW make to work correctly sh.exe must NOT be in your path.

  Run cmake from a shell that does not have sh.exe in your PATH.

  If you want to use a UNIX shell, then use MSYS Makefiles.

Call Stack (most recent call first):
  CMakeLists.txt:6 (PROJECT)

CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_C_COMPILER
CMake Error: Could not find cmake module file:S:/MyPrj/MyPrj-build/CMakeFiles/2.8.11.2/CMakeCCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_CXX_COMPILER
CMake Error: Could not find cmake module file:S:/MyPrj/MyPrj-build/CMakeFiles/2.8.11.2/CMakeCXXCompiler.cmake
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

第二次:

S:\MyPrj\MyPrj-build>cmake -G "MinGW Makefiles"  ..\MyPrj
-- The C compiler identification is GNU 4.8.1
-- The CXX compiler identification is GNU 4.8.1
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindQt4.cmake:1382 (message):
  Found unsuitable Qt version "" from NOTFOUND, this code requires Qt 4.x
Call Stack (most recent call first):
  CMakeLists.txt:12 (FIND_PACKAGE)

-- Configuring incomplete, errors occurred!  

在第一次和第二次 cmake 运行中出现这些不同的行为是否正常?

为什么系统找不到Qt4?

这三个问题是否相互依赖?

4

1 回答 1

1

你是如何“安装”你的 Qt 的?在您的情况下“安装”它的唯一方法是从源代码构建它。通常,您需要使用与编译使用 Qt 的项目相同的编译器来编译 Qt。一些 C++ 编译器版本不匹配可能会起作用,但您刚刚证明您的组合不起作用。

于 2013-09-12T19:49:44.813 回答