From clamav-devel-bounces@lists.clamav.net  Wed Mar 25 20:09:29 2009
Return-Path: <clamav-devel-bounces@lists.clamav.net>
X-Original-To: list@tad.clamav.net
Delivered-To: list@tad.clamav.net
X-Virus-Scanned: Debian amavisd-new at tad.clamav.net
Received: from tad.clamav.net ([127.0.0.1])
	by localhost (tad.clamav.net [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id NzJ5-GbF+YjY; Wed, 25 Mar 2009 20:09:28 +0100 (CET)
Received: from tad.clamav.net (localhost.localdomain [127.0.0.1])
	by tad.clamav.net (Postfix) with ESMTP id 9804116C2C8;
	Wed, 25 Mar 2009 20:09:26 +0100 (CET)
X-Original-To: clamav-devel@tad.clamav.net
Delivered-To: clamav-devel@tad.clamav.net
X-Virus-Scanned: Debian amavisd-new at tad.clamav.net
Received: from tad.clamav.net ([127.0.0.1])
	by localhost (tad.clamav.net [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id rQdv7r5DRcCQ for <clamav-devel@tad.clamav.net>;
	Wed, 25 Mar 2009 20:09:22 +0100 (CET)
Received: from kelly.lavabit.com (kelly.lavabit.com [72.249.41.32])
	by tad.clamav.net (Postfix) with ESMTP id A41B916C29C
	for <clamav-devel@lists.clamav.net>;
	Wed, 25 Mar 2009 20:09:22 +0100 (CET)
Received: from b.earth.lavabit.com (b.earth.lavabit.com [192.168.111.11])
	by kelly.lavabit.com (Postfix) with ESMTP id DFF8F7C19A
	for <clamav-devel@lists.clamav.net>;
	Wed, 25 Mar 2009 14:09:21 -0500 (CDT)
Received: from 10.8.0.6 (10.8.0.6) by lavabit.com with ESMTP id VB5L7JCEF9MU
	for <clamav-devel@lists.clamav.net>; Wed, 25 Mar 2009 14:09:21 -0500
Message-ID: <49CA8161.5030309@lavabit.com>
Date: Wed, 25 Mar 2009 14:09:21 -0500
From: Ladar Levison <ladar@lavabit.com>
User-Agent: Thunderbird 1.5.0.12 (X11/20090114)
MIME-Version: 1.0
To: ClamAV Development <clamav-devel@lists.clamav.net>
References: <a55c54ec0903250635x46b447a9t261e4c516567a1ce@mail.gmail.com>
In-Reply-To: <a55c54ec0903250635x46b447a9t261e4c516567a1ce@mail.gmail.com>
Subject: Re: [Clamav-devel] [Clamav] Cannot dlopen: file not found - unrar
 support unavailable
X-BeenThere: clamav-devel@lists.clamav.net
X-Mailman-Version: 2.1.9
Precedence: list
Reply-To: ClamAV Development <clamav-devel@lists.clamav.net>
List-Id: ClamAV Development <clamav-devel.lists.clamav.net>
List-Unsubscribe: <http://lists.clamav.net/cgi-bin/mailman/listinfo/clamav-devel>,
	<mailto:clamav-devel-request@lists.clamav.net?subject=unsubscribe>
List-Post: <mailto:clamav-devel@lists.clamav.net>
List-Help: <mailto:clamav-devel-request@lists.clamav.net?subject=help>
List-Subscribe: <http://lists.clamav.net/cgi-bin/mailman/listinfo/clamav-devel>,
	<mailto:clamav-devel-request@lists.clamav.net?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: clamav-devel-bounces@lists.clamav.net
Errors-To: clamav-devel-bounces@lists.clamav.net

nicolas dumont wrote:
> Hello,
>
> I am using clamav-0.95 with my own daemon that use libclamav
>
> During the initialization I have the message :
> LibClamAV Warning: Cannot dlopen: file not found - unrar support unavailable
>
> I would like to link my daemon with the libclamunrar_iface.a and libclamunrar.a
> in order to have all libraries inside my binary.
>
> Is there a way in my Makefile or elsewhere to have the libclamunrar
> directly called
> inside my binary without modifying the call to
> lt_dlopenext("libclamunrar_iface") ?
>
> Best regards,
> Nicolas Dumont.
>   

Hi Nicholas,

I am also compiling ClamAV into a library and opening it with a dlopen() 
call. The technique I use is:

/configure
make

I then merge together the different ClamAV libs using this command:

ld -shared -o clamav.lib clamav-0.94.2/libclamav/.libs/libclamav.a 
clamav-0.94.2/libclamunrar_iface/.libs/libclamunrar_iface.a 
clamav-0.94.2/libclamunrar/.libs/libclamunrar.a -lbz2 -lgmp -lpthread -lz

Which creates a file called clamav.lib that can be passed to dlopen().

There are a couple of notes. Which libraries you dynamically link 
against when using ld will vary depending on your platform and how 
ClamAV configures itself. For example, on my system I don't actually 
link against pthread specifically because I know the program I'm using 
is already linked against the pthread library. On Cent OS 4/Red Hat 
Enterprise 4 specifically, I need to pass the --disable-zlib-vcheck 
parameter to configure and I need to manually edit the libclamav 
makefiles to pass -O1 instead of -O2 to gcc or all of the free() calls 
will be optimized away inside the cl_free() function. See this bug for 
details:

https://bugzilla.redhat.com/show_bug.cgi?id=490253

If anyone knows of a better way to do this, or finds any problems with 
using ClamAV this way, please let me know...

Ladar


_______________________________________________
http://lurker.clamav.net/list/clamav-devel.html
Please submit your patches to our Bugzilla: http://bugs.clamav.net

