autoconf和共享库 [英] autoconf and shared library

查看:118
本文介绍了autoconf和共享库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我发布到正确的新闻组。我尝试将此提交到
au******@gnu.org 邮件列表,但我看不到任何活动。如果这是错误的

新闻组,我会推荐一个不同来源的引用。


我的问题是:


我的一个源文件使用该库:


#include< openssl / md5.h>


这迫使我当我链接

对象以生成可执行文件时,将/usr/lib/libcrypto.so添加到gcc命令。我的gcc命令看起来像

如下:


gcc --pedantic -Wall -std = c99 -O2 -g -O2 / usr / lib / libcrypto .so -o main Main.o

my_md5.o


我今天正在学习autoconf并且想知道如何断言用户

编译确实有libcrypto.so共享对象。


例如./configure会检查以确保libcrypto.so可用...至少

它的功能 - 例如定义了MD5_Init函数。


这可能吗?


第二个问题:


随着程序的复杂性增加并需要许多这些共享对象,什么是

确保便携性的最佳方法?如果他们没有libcrypto.so,我是否包含libcrypto.c的代码以供用户编译?b $ b?或者我是否向用户提供了

,其中包含来自编译器的不友好错误消息。


此外,我的libcrypto.so对象的位置可能与其他人不同。我怎么处理这个问题?


谢谢,

马特

I hope I am posting this to the right newsgroup. I tried submitting this to the
au******@gnu.org mailing list, but I see no activity. If this is the wrong
newsgroup, I would appriciate a reference to a different source.

My question was:

One of my source files uses the library:

#include <openssl/md5.h>

This forces me to add /usr/lib/libcrypto.so to the gcc command when I link the
object to produce an executable for instance. My gcc command looks something
like below:

gcc --pedantic -Wall -std=c99 -O2 -g -O2 /usr/lib/libcrypto.so -o main Main.o
my_md5.o

I was studying autoconf today and was wondering how I can assert that the user
compiling does in fact have the libcrypto.so shared object.

e.g. ./configure would check to make sure libcrypto.so is available... at least
it''s functionality--the function MD5_Init is defined for example.

Is this possible?

Second Question:

As programs grow in complexity and require many of these shared objects, what is
the best way to assure portability? Do I include the code for libcrypto.c for
the user to compile if they don''t have libcrypto.so? Or do I provide the user
with an unfriendly error message from the compiler.

Also, the location of my libcrypto.so object may differ from other peoples. How
do I deal with that?

Thanks,
Matt

推荐答案



Matt Kowalczyk写道:

Matt Kowalczyk wrote:
我希望我把它发布到正确的新闻组。我尝试将此提交到
au******@gnu.org 邮件列表,但我看不到任何活动。如果这是错误的
新闻组,我会批评对不同来源的引用。


这确实是错误的新闻组,但看起来你最初发布了这个没有回复的正确版本,这是一个很好的借口

对我来说。

我的问题是:

我的一个源文件使用该库:

#include< openssl / md5.h>

当我链接
对象以生成可执行文件时,这迫使我将/usr/lib/libcrypto.so添加到gcc命令。我的gcc命令看起来像下面的东西:

gcc --pedantic -Wall -std = c99 -O2 -g -O2 /usr/lib/libcrypto.so -o main Main.o
my_md5.o

今天我正在学习autoconf,并想知道如何断言用户编译确实有libcrypto.so共享对象。

例如./configure会检查以确保libcrypto.so可用...至少它的功能 - 例如定义了MD5_Init函数。

这可能吗?<第二个问题:

随着程序的复杂性增加并需要许多这些共享对象,什么是确保可移植性的最佳方法?如果他们没有libcrypto.so,我是否包含libcrypto.c的代码以供用户编译?或者我是否向用户提供了编译器不友好的错误消息。

此外,我的libcrypto.so对象的位置可能与其他人不同。我该如何处理?


参见例如:

http://roo.no-ip.org/howtos/autoconf.php#head


你可以拯救使用

时缺少所需的功能:


#在指定的库中搜索指定的函数

AC_SEARCH_LIBS([BK_set_key] ,

[加密],

[],

[AC_MSG_ERROR([无法找到libcrypto库,需要构建

这个包。])])


你还需要从你的

Makefile.in中删除对libcrypto的直接引用,而是使用@LDFLAGS @上面的工作。


即使libcrypto丢失但是

功能仍然存在于libc中,上述工作仍然有效。它也有效,如果图书馆住在例如

/ usr / local。

谢谢,
马特
I hope I am posting this to the right newsgroup. I tried submitting this to the
au******@gnu.org mailing list, but I see no activity. If this is the wrong
newsgroup, I would appriciate a reference to a different source.
This is indeed the wrong newsgroup, but it seems you originally posted
this in the correct one with no reply, which is a good enough excuse
for me.

My question was:

One of my source files uses the library:

#include <openssl/md5.h>

This forces me to add /usr/lib/libcrypto.so to the gcc command when I link the
object to produce an executable for instance. My gcc command looks something
like below:

gcc --pedantic -Wall -std=c99 -O2 -g -O2 /usr/lib/libcrypto.so -o main Main.o
my_md5.o

I was studying autoconf today and was wondering how I can assert that the user
compiling does in fact have the libcrypto.so shared object.

e.g. ./configure would check to make sure libcrypto.so is available... at least
it''s functionality--the function MD5_Init is defined for example.

Is this possible?

Second Question:

As programs grow in complexity and require many of these shared objects, what is
the best way to assure portability? Do I include the code for libcrypto.c for
the user to compile if they don''t have libcrypto.so? Or do I provide the user
with an unfriendly error message from the compiler.

Also, the location of my libcrypto.so object may differ from other peoples. How
do I deal with that?
See for example:

http://roo.no-ip.org/howtos/autoconf.php#head

You could bail out if the required functionality is missing using
something like:

# Search for specified function in specified libraries
AC_SEARCH_LIBS( [BK_set_key],
[crypto],
[],
[AC_MSG_ERROR( [Cannot find the libcrypto library, needed to build
this package.] )] )

You also need to remove the direct reference to libcrypto from your
Makefile.in and instead use @LDFLAGS@ for the above to work.

The above would work even if the libcrypto was missing but the
functionality lives in libc. It also works if the library lives in e.g.
/usr/local.

Thanks,
Matt




希望这会有所帮助。


-

Axel



Hope this helps.

--
Axel


< a href =mailto:li ********** @ gmail.com> li ********** @ gmail.com 写道:
Matt Kowalczyk写道:
Matt Kowalczyk wrote:
我希望我把它发布到正确的新闻组。我尝试将此提交到
au******@gnu.org 邮件列表,但我看不到任何活动。如果这是错误的
新闻组,我会推荐一个不同来源的引用。
I hope I am posting this to the right newsgroup. I tried submitting this to the
au******@gnu.org mailing list, but I see no activity. If this is the wrong
newsgroup, I would appriciate a reference to a different source.



这确实是错误的新闻组,但似乎你最初发布了
这是正确的,没有回复,这对我来说是一个很好的借口。



This is indeed the wrong newsgroup, but it seems you originally posted
this in the correct one with no reply, which is a good enough excuse
for me.




如果是这样,为什么你不呢?将您的回复发布在正确的

论坛中,主题是什么?


Robert Gamble



If this is the case, why wouldn''t you post your response in the correct
forum where it would be on topic?

Robert Gamble


2006-03-26,Robert Gamble< rg ******* @ gmail.com>写道:
On 2006-03-26, Robert Gamble <rg*******@gmail.com> wrote:
li ********** @ gmail.com 写道:
Matt Kowalczyk写道:
Matt Kowalczyk wrote:
>我希望我把它发布到正确的新闻组。我尝试将此内容提交给
> au******@gnu.org 邮件列表,但我看不到任何活动。如果这是错的
>新闻组,我会提到一个不同来源的引用。
> I hope I am posting this to the right newsgroup. I tried submitting this to the
> au******@gnu.org mailing list, but I see no activity. If this is the wrong
> newsgroup, I would appriciate a reference to a different source.



这确实是错误的新闻组,但似乎你最初发布的是正确的,没有回复,对我来说这是一个很好的借口。



This is indeed the wrong newsgroup, but it seems you originally posted
this in the correct one with no reply, which is a good enough excuse
for me.



如果是这样的话,为什么你不在正确的论坛里发表你的回复呢?会有什么话题?

Robert Gamble



If this is the case, why wouldn''t you post your response in the correct
forum where it would be on topic?

Robert Gamble




出于好奇,C程序员的正确新闻组在哪里?
讨论(多平台)工具和库?



Out of curiosity where is the correct newsgroup for C programmers to
discuss (multi-platform) tools and libraries?


这篇关于autoconf和共享库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆