如何添加 LDFLAGS 路径
我正在尝试建立一个名为 PBC (基于配对的密码学)的库。这个库需要另一个名为 GMP 的库 -(GNU 多精度库)。
我的问题是正确安装 GMP 后,PBC 给出错误:
找不到 gmp 库将其路径添加到 LDFLAGS
我不知道 LDFLAGS
是什么以及如何将其添加到路径中。
PS:我使用的是MinGW。
I'm trying to set up a library called PBC (Pairing-based cryptography). And this library requires another library called GMP -(GNU Multiple-Precision Library).
My problem is after installing GMP correctly, PBC gives an error of:
gmp library not found add its path to LDFLAGS
I have no idea what LDFLAGS
is and how to add it to the path.
PS: I'm using MinGW.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这个问题的描述性不够好,任何人都无法很好地回答,但是……
在基于 Unix 的系统上,您可能会做这样的事情:
使用 GNU make 工具的 Windows 环境,需要进行一些细微的调整。
The question is not really descriptive enough for anyone to answer well, but....
On a Unix-based system you would likely do something like this:
Windows environments with GNU make tools, will need minor tweaks.
如果您查看gcc man:
添加目录 dir 到要搜索的目录列表
对于-l。因此,-Ldir只是将路径传递给链接器来查找源代码使用的.a或.so库
-Rdir 并不总是受所有平台支持,
更好的选择是 rpath 与 -Wl :
If you look into gcc man:
adds directory dir to the list of directories to be searched
for -l. So, -Ldir just passes a path to the linker to look for a .a or .so library used by the source code
-Rdir is not always supported by all platform,
a better option is rpath together with -Wl:
只是为了确保我们不能让这变得更容易:您是否试图编译一些额外的东西,以至于您不能(或不想);如果您喜欢从源代码编译所有内容或什么,我没有问题不是,但想确保您只是没有看到它)使用某人已经使用 MinGW 构建的预编译二进制文件? (位于此处,当我写这篇文章时.)
LDFLAGS
是 C 编译器对于应传递给加载器部分的标志的约定。在你的情况下,你很可能想要添加类似-L/usr/local/lib
的东西(或者无论 GMP 放在哪里......我希望你可以通过以下方式弄清楚)搜索libgmp.a
...如有必要,在您的 msys shell 中,cd
到/
并运行find -name "libgmp .a"
)。如果您在文本编辑器中打开Makefile
,您应该会找到一个LDFLAGS
行,可能是空的(在我的 Linux 机器上,它只是LDFLAGS=
对于该行)。Just to make sure we can't make this easier: are you trying to compile something extra such that you can't (or don't want to; I have no problems if you prefer to compile everything from source or what not but want to make sure you just didn't see it) use the precompiled binaries someone already built using MinGW? (Located here as of when I wrote this.)
LDFLAGS
are a convention with a C compiler for flags that should be passed to the loader part. In your case, you're most likely going to want to add something like-L/usr/local/lib
(or wheverer GMP got put... I would expect you can probably figure it out by searching forlibgmp.a
... if necessary, in your msys shell,cd
to/
and runfind -name "libgmp.a"
). If you open theMakefile
in a text editor, you should find aLDFLAGS
line, possibly empty (on my Linux box, it's justLDFLAGS=
for that line).