c++ - vscode如何正确地link programs with library?

 sucbenson-lee_905 发布于 2022-10-31 13:08

刚刚开始用vscode,在build的过程中出现了

Undefined symbols for architecture x86_64:
  "_gsl_rng_types_setup", referenced from:
      _main in Playground-7475b2.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

这样的错误,
我的代码是

#include 
#include 
#include 


int main(){
    const gsl_rng_type **t, **t0;
    t0 = gsl_rng_types_setup (); 
    for (t = t0; *t != 0; t++) {
        std::cout<<(*t)->name; 
    }
}

按理我的library就在默认的位置(/usr/local/lib)不会出现这个问题吧。。
所以想求个解决方案,不胜感激!

1 个回答
  • 最后我用terminal解决了这个问题

    g++ -L/usr/local/lib -o "Playground" "Playground.cpp"
    

    这不是非常方便。。如果有更好的解决方法非常欢迎,比如修改task.json

    2022-10-31 22:46 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有