问题描述
刚刚开始用vscode,在build的过程中出现了
Undefined symbols for architecture x86_64: '_gsl_rng_types_setup', referenced from: _main in Playground-7475b2.old: symbol(s) not found for architecture x86_64clang: error: linker command failed with exit code 1 (use -v to see invocation)
这样的错误,我的代码是
#include <gsl/gsl_rng.h>#include <iostream>#include <stddef.h>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