用Qt Creator构建斯坦福CS106B项目的问题

Problems building Stanford CS106B projects with Qt Creator

本文关键字:项目 问题 CS106B 斯坦福 Qt Creator 构建      更新时间:2023-10-16

我正在尝试使用他们的免费在线资源参加斯坦福大学CS106B课程(我不是斯坦福大学的学生)。由于他们现在需要登录ID才能访问当前季度主页上的许多页面,我使用的是2015年第一季度的存档页面,位于这里:

http://stanford.edu/class/archive/cs/cs106b/cs106b.1154/

我从其他人那里看到过一些类似的问题,他们在构建作业项目时遇到了麻烦,但他们都使用其他IDE和/或操作系统,并且他们都得到了不同的错误信息。

我首先尝试Qt Creator 5.5,但当我得到错误时,我卸载了它并安装了Qt Creator 5.4.1。这是存档的旧页面上推荐的版本,所以我认为同一页面上的作业应该与这个版本兼容。我在一台运行Windows 8.1的电脑和另一台运行Windows Vista的电脑上试用了它。无论我使用的是哪个版本的Qt Creator或Windows,每次我试图构建斯坦福大学的作业或示例项目之一时,我都会在Qt Creator的问题窗口中得到以下消息:

    cannot find -liberty
    error: Id returned 1 exit status
    collect2.exe

编译输出窗口显示以下错误:

    I:/Program Files/Qt Creator/Tools/mingw492_32/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -liberty
    collect2.exe: error: ld returned 1 exit status
    Makefile.Debug:247: recipe for target 'debugsimple-project.exe' failed
    mingw32-make[1]: *** [debugsimple-project.exe] Error 1
    mingw32-make[1]: Leaving directory 'I:/Moved from Drive 1/Documents/QT Creator projects/build-simple-project-Desktop_Qt_5_5_0_MinGW_32bit-Debug'
    makefile:34: recipe for target 'debug' failed
    mingw32-make: *** [debug] Error 2
    09:42:28: The process "I:Program FilesQt CreatorToolsmingw492_32binmingw32-make.exe" exited with code 2.
    Error while building/deploying project simple-project (kit: Desktop Qt 5.5.0 MinGW 32bit)
    When executing step "Make"

我还应该注意到,我下载了Qt Creator中提供的一个示例项目,并且我能够构建和运行这个项目。只有斯坦福的项目才会给我错误。

我是新的c++和Qt Creator,所以可能有一些简单的东西,我没能做到。

修改.pro文件,使其不再尝试链接"liberty"库。

在simple-project。Pro文件的第107行有一个对"liberty"库的引用。我将其注释掉,然后编译示例simple-project。

LIBS += -lDbghelp
LIBS += -lbfd
LIBS += -liberty <-place "#" in front of this line
LIBS += -limagehlp