如何在没有 sudo 的情况下构建库?

How to build library without sudo?

我通常建立我的图书馆./configure && make && sudo make install。但是 Travis 文档不鼓励使用 sudo http://docs.travis-ci.com/user/workers/container-based-infrastructure/

所以我将构建命令更改为./configure --prefix=$HOME && make && make install。这行得通,但是在下一步(构建 Python 扩展)我得到了一个错误

/usr/bin/ld: cannot find -lprimesieve

有什么想法吗?我是否需要将 $HOME/lib 添加到某些环境变量中,因为我更改了前缀?

  1. 我的travis配置https://github.com/hickford/primesieve-python/blob/travis-ci/.travis.yml
  2. 生成错误日志 https://travis-ci.org/hickford/primesieve-python/jobs/69536543#L382

尝试设置集 LD_LIBRARY_PATH,这类似于图书馆的 PATH。例如:

LD_LIBRARY_PATH= $HOME/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH 

有关库路径变量的更多详细信息是 here

具体影响 configure 脚本如何将参数传递给编译的环境变量是 LIBSLD_FLAGSbash ./configure --help 提到了这些。

正如您在评论中提到的,LIBRARY_PATH 也需要设置。有关差异的解释,请参阅 LD_LIBRARY_PATH vs LIBRARY_PATH