【问题标题】:Weird compiler errors in Travis CI that don't happen on local machineTravis CI 中奇怪的编译器错误不会发生在本地机器上
【发布时间】:2017-12-05 10:17:28
【问题描述】:

我创建了一个 GitHub test repo 来玩 Travis CI,它运行良好,直到我尝试使用外部依赖项。在.travis.yml我有

install:
  - sudo apt-get install libsfml-dev

并且该命令在 Travis 机器上成功执行,但在编译时,我收到类似

的错误
main.cpp: In function ‘int main()’:
main.cpp:6:5: error: ‘CircleShape’ is not a member of ‘sf’
main.cpp:6:21: error: expected ‘;’ before ‘shape’
main.cpp:7:5: error: ‘shape’ was not declared in this scope

g++

main.cpp:6:9: error: no member named 'CircleShape' in namespace 'sf'
    sf::CircleShape shape(100.f);
    ~~~~^
main.cpp:7:5: error: use of undeclared identifier 'shape'
    shape.setFillColor(sf::Color::Green);
    ^

clang++.

无论是在我的 Windows 机器上还是在我的 Linux VM 上,我都没有收到这些错误,代码是 SFML 教程中的示例代码。

install 命令似乎没有任何问题,因为编译器不会说明错误的标头。

是什么导致了这些错误?我该如何修复它们? install 命令是不是我做错了什么?

【问题讨论】:

  • 据我回忆,Travis 使用的是非常老的 Ubuntu 12.04。也许它安装的 SFML 版本有问题?
  • 啊,有趣的提示;我会调查的
  • @GoodDeeds 太棒了,它有效!没想到这么简单
  • 好。顺便说一句,标题如何与问题的其余部分相关联?也许可以对其进行编辑以使其更容易找到?
  • @GoodDeeds 问题是我不知道原因是什么,我真的不知道更合适的标题。如果有人知道,请编辑它

标签: c++ linux dependencies travis-ci


【解决方案1】:

正如@GoodDeeds 在 cmets 中发布的那样,Ubuntu 发行版已经过时了。

dist: trusty(由@joepd 指出)添加到您的.travis.yml 文件中以使用最新的分发版。

【讨论】:

  • 你可能想要dist: trusty
  • 是吗?好吧,我只是快速浏览了一下 Ubuntu 的下载页面,看到的是 kylin。
  • 查看 Travis 文档。
猜你喜欢
  • 2016-01-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多