V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
MrVito
V2EX  ›  问与答

Linux 编译、链接的问题

  •  
  •   MrVito · 2018-07-16 10:28:17 +08:00 · 1237 次点击
    这是一个创建于 2083 天前的主题,其中的信息可能已经有所发展或是发生改变。

    环境: ubuntu18.04, g++7.3.0, cmake3.10.2


    问题描述: 一个项目中想使用 glog 日志库,于是我从 github 上 clone 了 glog,并且成功编译,安装,之后将安装好 glog 头文件、libglog.a 复制到我的工程里面。我的工程目录结果如下:
    ├── libs
    │   ├── google
    │   │   ├── glog
    │   │   └── gtest
    │   ├── libglog.a
    │   ├── libgtest.a
    │   └── libgtest_main.a
    ├── test
    │   ├── CMakeLists.txt
    │   └── vlist_test.cpp
    └── utils
    ├── vlist.h
    └── vqueue.h
    然后我在 cmakelists.txt 中写入了这样的内容

    include_directories(../libs/)
    link_directories(../libs/)
    link_libraries(glog)
    target_link_libraries(${EXECUTABLE_TARGET} glog)
    

    但是在编译过程中提示我
    glog/logging.h:1246:26: error: ‘ noreturn ’ has not been declared
    static void __declspec(noreturn) Fail();
    这个报错我找遍了 google 也没见有人遇到,所以我认为应该是我的 cmakelist.txt 写的有问题,故又去网上找了别人使用 glog、cmake 的例子,发现应该是没问题的。最后我尝试使用 g++直接编译,使用了这样的命令:

    g++ --std=c++11 -c -I../utils/ -I../libs/ -I../libs/google/ -L../libs/ -lglog vlist_test.cpp
    

    可是还是有同样的报错


    按理说这个 libglog.a 是用我自己的机器,用 glog 的源文件、头文件编译出来的,就说明这些文件是可以在我的机器上正常编译的,可是为什么我这里就始终编译不过呢?

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2865 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 11:36 · PVG 19:36 · LAX 04:36 · JFK 07:36
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.