Mailing List Archive

How to recompile with -fPIC?
Hi.

I'm trying to install the latest version of clamav (0.102.3) on Ubuntu 20.04. I'm configuring clamav following the steps explained in http://www.clamav.net/documents/installation-on-debian-and-ubuntu-linux-distributions. It's the first time that I download the source code and I configure and compile a programme. I'm blocked because I don't know how to recompile with fPIC.

The two last steps:

./configure --enable-check --disable-clamav --with-libjson-static=/usr/lib/x86_64-linux-gnu/libjson-c.a

configure: Summary of detected features follows
OS : linux-gnu
pthreads : yes (-lpthread)
configure: Summary of miscellaneous features
check : -lcheck_pic -pthread -lrt -lm -lsubunit
fanotify : yes
fdpassing : 1
IPv6 : yes
openssl : /usr
libcurl : /usr
configure: Summary of optional tools
clamdtop : yes (-lncurses)
milter : no (missing libmilter) (disabled)
clamsubmit : yes (libjson-c-dev found at /usr, linking=static)
clamonacc : yes (auto)
configure: Summary of engine performance features
release mode: yes
llvm : no (disabled)
mempool : yes
configure: Summary of engine detection features
iconv : yes
bzip2 : ok
zlib : yes (from system)
unrar : yes
preclass : yes (libjson-c-dev found at /usr, linking=static)
pcre : /usr
libmspack : yes (Internal)
libxml2 : yes, from /usr
yara : yes
fts : yes (libc)

I think it's all right. Then, I try to compile:

make -j2

(...)
*** Warning: Linking the shared library libclamav.la against the
*** static library /usr/lib/x86_64-linux-gnu/libjson-c.a is not portable!
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libjson-c.a(json_object.o): relocation R_X86_64_TPOFF32 against `tls_serialization_float_format' can not be used when making a shared object; recompile with -fPIC
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:1547: libclamav.la] Error 1
make[4]: Leaving directory '/home/alberto/Deskargak/clamav-0.102.3/libclamav'
make[3]: *** [Makefile:4320: all-recursive] Error 1
make[3]: Leaving directory '/home/alberto/Deskargak/clamav-0.102.3/libclamav'
make[2]: *** [Makefile:1463: all] Error 2
make[2]: Leaving directory '/home/alberto/Deskargak/clamav-0.102.3/libclamav'
make[1]: *** [Makefile:853: all-recursive] Error 1
make[1]: Leaving directory '/home/alberto/Deskargak/clamav-0.102.3'
make: *** [Makefile:649: all] Error 2

Those are the last messages. I have to recompile with -fPIC, but I don't know how. I've spent some hours trying to find the way to do it, but... Can you help me? Thank you very much.

Alberto

Sent with [ProtonMail](https://protonmail.com) Secure Email.
Re: How to recompile with -fPIC? [ In reply to ]
Hi there,

On Fri, 19 Jun 2020, Alberto Matxain wrote:

> I'm trying to install the latest version of clamav (0.102.3) on
> Ubuntu 20.04. I'm configuring clamav following the steps explained
> in
> http://www.clamav.net/documents/installation-on-debian-and-ubuntu-linux-distributions.

To be fair to you, that document isn't exactly beginner-friendly.

> It's the first time that I download the source code and I configure
> and compile a programme. I'm blocked because I don't know how to
> recompile with fPIC.
> ...
> ./configure --enable-check --disable-clamav --with-libjson-static=/usr/lib/x86_64-linux-gnu/libjson-c.a
> ...
> make -j2
> ...
> /usr/bin/ld: ... recompile with -fPIC

There are much easier ways to do what you want to do. Version 0.102.3
of ClamaV is available in an Ubuntu package, so unless you're using an
architecture for which the package is not available (and I don't
believe that you are) then you could probably just install that:

https://packages.ubuntu.com/search?keywords=clamav&searchon=names&suite=focal&section=all

Even if you do want to compile it yourself, unless you want to have
more than one version of ClamAV running on your system (which I don't
recommend for a beginner), on an ordinary Ubuntu system I wouldn't
expect you to need any fancy options to 'configure'. In that case I
would suggest, assuming that you've already installed dependencies:

1. Delete your existing clamav-0.102.3 source tree.
2. Extract the tarball once again into a new source tree(*).
3. Change your working directory to the top level of that tree.
4. Run the following comands verbatim - no options at all (**):
./configure
make
sudo make install

(*) Do this logged in as your usual user, in your home directory,
or somewhere that doesn't neeed administrator permissions to work.
(**) Run these commands as your usual user, not 'root'. The last
command could be replaced by 'su root ; make install' which is how
I normally do it - but that's just because I have a sudo aversion.

Please let us know how you get on. FWIW these are more or less the
steps to build anything supplied as a source tarball - at least if the
source is written largely in C (as is ClamAV). Broadly speaking they
(1) set up the source tree to suit your system; (2) compile the source
thus set up to produce binaries and stuff in the source tree (but at
this stage it's _still_ all in your source tree); and (3) copy the
binaries, configuration files etc. (etc.) from the source tree into
the appropriate system areas - which is why that last step will need
administrator permissions. Sometimes you can run the binaries while
they're still in the source tree, and if you do an optional but very
common 'make test' step before 'make install' that's what will happen.
I rarely bother doing that for ClamAV so I've left that part out for
simplicity, as the output might just give you more palpitations.

After you've done all this you should have ClamAV installed, and you
can get back to us to tell us what you want to do with it because it
will probably need some work to configure it to your liking. ClamAV
is more along the lines of a toolkit than the point'n'shoot things you
see for Windows. To be used effectively it needs some thought.

Please note that my list email address only accepts mail from the list.

--

73,
Ged.

_______________________________________________

clamav-users mailing list
clamav-users@lists.clamav.net
https://lists.clamav.net/mailman/listinfo/clamav-users


Help us build a comprehensive ClamAV guide:
https://github.com/vrtadmin/clamav-faq

http://www.clamav.net/contact.html#ml
Re: How to recompile with -fPIC? [ In reply to ]
Hi Alberto,

The error you’re seeing is because the libjson-c.a static library wasn’t compiled with -fPIC, not because ClamAV wasn’t compiled with -fPIC. The -fPIC option makes it possible for another library (like libclamav.so) to link in libjson-c.a. The default build settings for json-c currently don’t have -fPIC enabled so many distribution’s json-c packages may not work with the --with-libjson-static option. I recently got a pull-request merged into the json-c project to fix this in json-c’s CMake build tools (see: https://github.com/json-c/json-c/pull/634) so future versions of libjson-c.a will not have the issue you just encountered but the change is not yet in a release.

For now, your options are to:

1. Build libjson-c.a manually, adding the -fPIC option to your CFLAGS for the build.
2. Skip the --with-libjson-static option. Unless you’re providing libclamav as a package for other application developers to use, it is perfectly safe to skip the --with-libjson-static option.

Best,
Micah

From: clamav-users <clamav-users-bounces@lists.clamav.net> on behalf of Alberto Matxain via clamav-users <clamav-users@lists.clamav.net>
Reply-To: "albertomatxain@protonmail.com" <albertomatxain@protonmail.com>, ClamAV users ML <clamav-users@lists.clamav.net>
Date: Friday, June 19, 2020 at 4:53 AM
To: "clamav-users@lists.clamav.net" <clamav-users@lists.clamav.net>
Cc: "albertomatxain@protonmail.com" <albertomatxain@protonmail.com>
Subject: [clamav-users] How to recompile with -fPIC?

Hi.

I'm trying to install the latest version of clamav (0.102.3) on Ubuntu 20.04. I'm configuring clamav following the steps explained in http://www.clamav.net/documents/installation-on-debian-and-ubuntu-linux-distributions. It's the first time that I download the source code and I configure and compile a programme. I'm blocked because I don't know how to recompile with fPIC.

The two last steps:

./configure --enable-check --disable-clamav --with-libjson-static=/usr/lib/x86_64-linux-gnu/libjson-c.a

configure: Summary of detected features follows
OS : linux-gnu
pthreads : yes (-lpthread)
configure: Summary of miscellaneous features
check : -lcheck_pic -pthread -lrt -lm -lsubunit
fanotify : yes
fdpassing : 1
IPv6 : yes
openssl : /usr
libcurl : /usr
configure: Summary of optional tools
clamdtop : yes (-lncurses)
milter : no (missing libmilter) (disabled)
clamsubmit : yes (libjson-c-dev found at /usr, linking=static)
clamonacc : yes (auto)
configure: Summary of engine performance features
release mode: yes
llvm : no (disabled)
mempool : yes
configure: Summary of engine detection features
iconv : yes
bzip2 : ok
zlib : yes (from system)
unrar : yes
preclass : yes (libjson-c-dev found at /usr, linking=static)
pcre : /usr
libmspack : yes (Internal)
libxml2 : yes, from /usr
yara : yes
fts : yes (libc)

I think it's all right. Then, I try to compile:

make -j2

(...)
*** Warning: Linking the shared library libclamav.la against the
*** static library /usr/lib/x86_64-linux-gnu/libjson-c.a is not portable!
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libjson-c.a(json_object.o): relocation R_X86_64_TPOFF32 against `tls_serialization_float_format' can not be used when making a shared object; recompile with -fPIC
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:1547: libclamav.la] Error 1
make[4]: Leaving directory '/home/alberto/Deskargak/clamav-0.102.3/libclamav'
make[3]: *** [Makefile:4320: all-recursive] Error 1
make[3]: Leaving directory '/home/alberto/Deskargak/clamav-0.102.3/libclamav'
make[2]: *** [Makefile:1463: all] Error 2
make[2]: Leaving directory '/home/alberto/Deskargak/clamav-0.102.3/libclamav'
make[1]: *** [Makefile:853: all-recursive] Error 1
make[1]: Leaving directory '/home/alberto/Deskargak/clamav-0.102.3'
make: *** [Makefile:649: all] Error 2

Those are the last messages. I have to recompile with -fPIC, but I don't know how. I've spent some hours trying to find the way to do it, but... Can you help me? Thank you very much.

Alberto


Sent with ProtonMail<https://protonmail.com> Secure Email.
Re: How to recompile with -fPIC? [ In reply to ]
Hi, Ged and Micah.

Thank you for the answers. I've tried following the steps that Ged told me (1. Delete... 2. Extract... 3. Change... 4. Run the following commands...), and I've installed Clamav properly. I've configured clamd.conf and freshclam.conf; I've configured on-access scanning on clamd.conf; I've programmed automatic scans with crontab (clamdscan command); I did a little script to run when a virus event happens (to ask me if I want to delete the virus or move it to a folder), and I created log files for the programmed scans, the database updates, the on-access scanning and the virus events. For me, that's quite enough. :-)

I haven't found any virus on my laptop. Now, I would like to test the virus event on the programmed scans and on-access scanning, to be sure that they work. Can you help me?

Thank you very much.

Alberto


Sent with ProtonMail Secure Email.

??????? Original Message ???????
On Friday, 2020ko Juneren 19a 14:47, G.W. Haywood via clamav-users <clamav-users@lists.clamav.net> wrote:

> Hi there,
>
> On Fri, 19 Jun 2020, Alberto Matxain wrote:
>
> > I'm trying to install the latest version of clamav (0.102.3) on
> > Ubuntu 20.04. I'm configuring clamav following the steps explained
> > in
> > http://www.clamav.net/documents/installation-on-debian-and-ubuntu-linux-distributions.
>
> To be fair to you, that document isn't exactly beginner-friendly.
>
> > It's the first time that I download the source code and I configure
> > and compile a programme. I'm blocked because I don't know how to
> > recompile with fPIC.
> > ...
> > ./configure --enable-check --disable-clamav --with-libjson-static=/usr/lib/x86_64-linux-gnu/libjson-c.a
> > ...
> > make -j2
> > ...
> > /usr/bin/ld: ... recompile with -fPIC
>
> There are much easier ways to do what you want to do. Version 0.102.3
> of ClamaV is available in an Ubuntu package, so unless you're using an
> architecture for which the package is not available (and I don't
> believe that you are) then you could probably just install that:
>
> https://packages.ubuntu.com/search?keywords=clamav&searchon=names&suite=focal&section=all
>
> Even if you do want to compile it yourself, unless you want to have
> more than one version of ClamAV running on your system (which I don't
> recommend for a beginner), on an ordinary Ubuntu system I wouldn't
> expect you to need any fancy options to 'configure'. In that case I
> would suggest, assuming that you've already installed dependencies:
>
> 1. Delete your existing clamav-0.102.3 source tree.
> 2. Extract the tarball once again into a new source tree(*).
> 3. Change your working directory to the top level of that tree.
> 4. Run the following comands verbatim - no options at all ():
> ./configure
> make
> sudo make install
> (*) Do this logged in as your usual user, in your home directory,
> or somewhere that doesn't neeed administrator permissions to work.
> () Run these commands as your usual user, not 'root'. The lastcommand could be replaced by 'su root ; make install' which is how
> I normally do it - but that's just because I have a sudo aversion.
>
> Please let us know how you get on. FWIW these are more or less the
> steps to build anything supplied as a source tarball - at least if the
> source is written largely in C (as is ClamAV). Broadly speaking they
> (1) set up the source tree to suit your system; (2) compile the source
> thus set up to produce binaries and stuff in the source tree (but at
> this stage it's still all in your source tree); and (3) copy the
> binaries, configuration files etc. (etc.) from the source tree into
> the appropriate system areas - which is why that last step will need
> administrator permissions. Sometimes you can run the binaries while
> they're still in the source tree, and if you do an optional but very
> common 'make test' step before 'make install' that's what will happen.
> I rarely bother doing that for ClamAV so I've left that part out for
> simplicity, as the output might just give you more palpitations.
>
> After you've done all this you should have ClamAV installed, and you
> can get back to us to tell us what you want to do with it because it
> will probably need some work to configure it to your liking. ClamAV
> is more along the lines of a toolkit than the point'n'shoot things you
> see for Windows. To be used effectively it needs some thought.
>
> Please note that my list email address only accepts mail from the list.
>
> --
>
> 73,
> Ged.
>
>
> clamav-users mailing list
> clamav-users@lists.clamav.net
> https://lists.clamav.net/mailman/listinfo/clamav-users
>
> Help us build a comprehensive ClamAV guide:
> https://github.com/vrtadmin/clamav-faq
>
> http://www.clamav.net/contact.html#ml



_______________________________________________

clamav-users mailing list
clamav-users@lists.clamav.net
https://lists.clamav.net/mailman/listinfo/clamav-users


Help us build a comprehensive ClamAV guide:
https://github.com/vrtadmin/clamav-faq

http://www.clamav.net/contact.html#ml
Re: How to recompile with -fPIC? [ In reply to ]
Hi there,

On Sun, 28 Jun 2020, Alberto Matxain via clamav-users wrote:

> ... I've installed Clamav properly. I've configured clamd.conf and
> freshclam.conf; I've configured on-access scanning on clamd.conf;
> I've programmed automatic scans with crontab (clamdscan command); I
> did a little script to run when a virus event happens (to ask me if
> I want to delete the virus or move it to a folder), and I created
> log files for the programmed scans, the database updates, the
> on-access scanning and the virus events. ...

Sounds like you've done quite a lot of work!

> I haven't found any virus on my laptop.

I'd have been surprised if you had. :/

> Now, I would like to test the virus event on the programmed scans
> and on-access scanning, to be sure that they work. Can you help me?

Have you checked out the documentation on the ClamAV Website?

See for example

https://www.clamav.net/documents/on-access-scanning

which I think explains how to test it's working.

--

73,
Ged.

_______________________________________________

clamav-users mailing list
clamav-users@lists.clamav.net
https://lists.clamav.net/mailman/listinfo/clamav-users


Help us build a comprehensive ClamAV guide:
https://github.com/vrtadmin/clamav-faq

http://www.clamav.net/contact.html#ml