【问题标题】:Local install of GNU MP, how to access it from ld?本地安装 GNU MP,如何从 ld 访问它?
【发布时间】:2018-06-11 17:19:34
【问题描述】:

我有一个已编译的 GMP 本地安装:

/path/to/gmp
    .../lib/gmp.h
    .../include/[gmp_binaries.etc]

现在,我导出路径,只是为了测试安装;一旦我开始工作,我会在某个中心位置添加符号链接:

export LD_LIBRARY_PATH=/path/to/gmp:$LD_LIBRARY_PATH

g++ -lgmp

// error: /usr/bin/ld: cannot find -lgmp

export LD_LIBRARY_PATH=/path/to/gmp/include:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/path/to/gmp/lib:$LD_LIBRARY_PATH

g++ -lgmp

// error: /usr/bin/ld: cannot find -lgmp

基本上,我的问题是:如何将我的本地库连接到 ld

(重点是在没有 sudo 的情况下安装内容,所以我不能“只是____”在大多数情况下)

【问题讨论】:

  • -l 需要-L 位置才能在g++ 中搜索。你想做什么?你想制作gmp吗?该路径中应该有一个makefile;你应该可以打电话给make
  • @jeremysprofile 我正在尝试安装一个依赖于 gmp 的库。该库的配置脚本在发现我的本地安装时遇到问题。我正试图弄清楚为什么它不起作用。

标签: bash compilation g++ ld


【解决方案1】:

-l 需要-L 位置才能在g++ 中搜索。 Make 不关注您的LD_LIBRARY_PATH。 Make需要一个特定的位置来搜索/usr/lib中未包含的特定库

# define library paths in addition to /usr/lib
# if I wanted to include libraries not in /usr/lib I'd specify
# their path using -Lpath, something like:
LFLAGS = -L/home/newhall/lib -L../lib

From this site

找到你的libgmp文件,链接如下:

g++ -L/path/to/libgmp/ -lgmp

【讨论】:

    猜你喜欢
    • 2010-12-09
    • 1970-01-01
    • 2021-06-02
    • 2019-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    相关资源
    最近更新 更多