简体   繁体   English

将源代码构建的库链接到由autotools管理的程序

[英]Linking a library built from source code to a program managed by autotools

I have ac program which needs a library named libnuma to be installed. 我有一个ac程序,需要安装一个名为libnuma的库。 But I dont have root access in the parallel machine in which I need to run this program. 但我在并行机器中没有root访问权限,我需要运行该程序。 So I downloaded the source code of libnuma and compiled it. 所以我下载了libnuma的源代​​码并编译了它。 I have a libnuma.a file which i assume is the library. 我有一个libnuma.a文件,我假设是库。 I need to link this library with the c program that I have. 我需要将这个库与我拥有的c程序链接起来。 This program uses autotools for generating the configuration files and the makefile. 该程序使用autotools生成配置文件和makefile。 I am new to autotools. 我是autotools的新手。 Please tell me what I have to do to link this library without being root. 请告诉我如何在不成为root的情况下链接此库。

Ajay. 阿贾伊。

It should be sufficient to set CPPFLAGS and LDFLAGS. 设置CPPFLAGS和LDFLAGS应该足够了。 First, try: 第一次尝试:

$ ./configure LDFLAGS=-L/path/to/lib CPPFLAGS=-I/path/to/include

(where libnuma.a is /path/to/lib/libnuma.a and numa.h is /path/to/include/numa.h. That is, specify the directories.) If that does not work, check config.log to see what went wrong. (其中libnuma.a是/path/to/lib/libnuma.a,numa.h是/path/to/include/numa.h。也就是说,指定目录。)如果这不起作用,请检查config.log看看出了什么问题。 If the configure script for the program you are using was built with an old version of autoconf, you may need to do: 如果您使用的程序的configure脚本是使用旧版autoconf构建的,则可能需要执行以下操作:

$ LDFLAGS=-L/path/to/lib CPPFLAGS=-I/path/to/include ./configure

instead. 代替。 (The second invocation will only work in Bourne shells. With csh/tcsh, you will need to set the environment variables some other way, for example with env.) You also have the option of making those settings in the environment of your shell (eg, in a .bashrc) or in a config.site file. (第二次调用仅适用于Bourne shell。使用csh / tcsh,您需要以其他方式设置环境变量,例如使用env。)您还可以选择在shell的环境中进行这些设置(例如,在.bashrc中)或在config.site文件中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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