简体   繁体   中英

Add library search path to clang

How can I add /usr/local/lib to my clang library search path?

This is what I see when I list my library search paths using clang -Xlinker -v :

在此处输入图像描述

Is it OK to add it as environment variable?

This should work:

export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/lib

Notice, it's LIBRARY_PATH , not LD_LIBRARY_PATH .

On the other hand, if that doesn't work for you, you should compile with the flag:

-L/usr/local/lib

And that should be sufficient, too.

EDIT: Btw, I don't know why you're using back-slashes instead of slashes... that needs explanation. Use slashes always . Even on Windows.

使用 -L 标志,您可以向库路径添加其他路径。

its, capital I (i), not capital L. Example:

clang -fsanitize=unsigned-integer-overflow,signed-integer-overflow,shift,pointer-overflow -Wall -Wno-format-extra-args -g utilities.cpp -I/Users/myName/Git/myProj/src/libs "$@" &&./a.out

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM