Re: [tcpdump-workers] Cannot find -lpcap when statically compiling a C project

2015-11-20 Thread Jamie Bainbridge
On 20 November 2015 at 17:39, Guy Harris  wrote:
>
> On Nov 19, 2015, at 4:35 PM, liu wen  wrote:
>
>> On Fri, Nov 20, 2015 at 12:52 AM, Guy Harris  wrote:
>>
>>> On Nov 19, 2015, at 3:29 PM, liu wen  wrote:
>>>
 I want to statically compile a C project in a laptop(fedora), using command
 line like:

 gcc -o myprogram -static main.c ... -levent -lpcap

 but I get error:

 /usr/bin/ld: cannot find -lpcap
 /usr/bin/ld: cannot find -lc

 I tried to locate libpcap.a and find no such a file
>>>
>>> See if there are libpcap RPMs that you haven't installed, perhaps one with 
>>> a name like "libpcap-dev" or something with "-dev" in the name, although 
>>> usually "-dev" packages include both static libraries and header files, so 
>>> without the "-dev" package you won't be able to compile anything.  Perhaps 
>>> Fedora has separate packages for the libpcap runtime (shared libraries), 
>>> libpcap development (headers), and libpcap static libraries.
>>
>> # locate libpcap-dev
>> /var/lib/yum/yumdb/l/75ed44a0adeee36906852424e93dafd3a950ae77-libpcap-devel-1.3.0-2.fc18-x86_64
>> /var/lib/yum/yumdb/l/75ed44a0adeee36906852424e93dafd3a950ae77-libpcap-devel-1.3.0-2.fc18-x86_64/changed_by
>> /var/lib/yum/yumdb/l/75ed44a0adeee36906852424e93dafd3a950ae77-libpcap-devel-1.3.0-2.fc18-x86_64/checksum_data
>> /var/lib/yum/yumdb/l/75ed44a0adeee36906852424e93dafd3a950ae77-libpcap-devel-1.3.0-2.fc18-x86_64/checksum_type
>> /var/lib/yum/yumdb/l/75ed44a0adeee36906852424e93dafd3a950ae77-libpcap-devel-1.3.0-2.fc18-x86_64/command_line
>> /var/lib/yum/yumdb/l/75ed44a0adeee36906852424e93dafd3a950ae77-libpcap-devel-1.3.0-2.fc18-x86_64/from_repo
>> /var/lib/yum/yumdb/l/75ed44a0adeee36906852424e93dafd3a950ae77-libpcap-devel-1.3.0-2.fc18-x86_64/from_repo_revision
>> /var/lib/yum/yumdb/l/75ed44a0adeee36906852424e93dafd3a950ae77-libpcap-devel-1.3.0-2.fc18-x86_64/from_repo_timestamp
>> /var/lib/yum/yumdb/l/75ed44a0adeee36906852424e93dafd3a950ae77-libpcap-devel-1.3.0-2.fc18-x86_64/installed_by
>> /var/lib/yum/yumdb/l/75ed44a0adeee36906852424e93dafd3a950ae77-libpcap-devel-1.3.0-2.fc18-x86_64/reason
>> /var/lib/yum/yumdb/l/75ed44a0adeee36906852424e93dafd3a950ae77-libpcap-devel-1.3.0-2.fc18-x86_64/releasever
>>
>> what commands/steps should I follow so as to get the libpcap.a?
>
> You might have to build it from source, because the Fedora people don't like 
> static libraries:
>
> 
> https://fedoraproject.org/wiki/Packaging:Guidelines#Packaging_Static_Libraries
>
> https://bugzilla.redhat.com/show_bug.cgi?id=248813
>
>>> However, "cannot find -lc" means it also doesn't have a static version of 
>>> libc, so you'll also have to find a Fedora package with a static version of 
>>> libc.
>>
>> how can I find a static version of libc?
>
> You might have to build it from source, because the Fedora people don't like 
> static libraries.
>
> However, they might have decided to allow a static version of libc:
>
> http://www.xinotes.net/notes/note/1025/
>
> If that works, try looking for a libpcap-static package, but there might not 
> be one.

Fedora has glibc-static, but no libpcap-static.
___
tcpdump-workers mailing list
tcpdump-workers@lists.tcpdump.org
https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers


Re: [tcpdump-workers] Cannot find -lpcap when statically compiling a C project

2015-11-20 Thread Jamie Bainbridge
On 21 November 2015 at 08:15, liu wen  wrote:
> thank you very much!
> then how to compile the source codes to make a libpcap.a from the libpcap
> source codes?

$ tar xf libpcap-1.7.4.tar.gz
$ cd libpcap-1.7.4/
$ ./configure
$ make
$ find . -name libpcap.a
./libpcap.a

You may have to install some additional stuff like flex and bison.
It's been a while since I used Fedora but yum groupinstall
"Development tools" brings in a lot of useful things.

> On Fri, Nov 20, 2015 at 6:58 PM, Guy Harris  wrote:
>>
>>
>> On Nov 20, 2015, at 12:32 AM, Jamie Bainbridge
>>  wrote:
>>
>> > Fedora has glibc-static, but no libpcap-static.
>>
>> Then he'll have to build libpcap from source.
>>
>> I would suggest building with the *latest* version of libpcap from
>> tcpdump.org, currently 1.7.4:
>>
>> http://www.tcpdump.org/#latest-release
>>
>> to see whether it's better than either the 1.3.0 on the machines where it
>> wasn't having problems of the 1.5.3 on the machines where it was.
>>
>
___
tcpdump-workers mailing list
tcpdump-workers@lists.tcpdump.org
https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers