使用root用户安装
# yum install libnl3
Loaded plugins: langpacks, presto, refresh-packagekit
Repository updates is listed more than once in the configuration
Repository updates-debuginfo is listed more than once in the configuration
Repository updates-source is listed more than once in the configuration
Repository fedora is listed more than once in the configuration
Repository fedora-debuginfo is listed more than once in the configuration
Repository fedora-source is listed more than once in the configuration
Resolving Dependencies
--> Running transaction check
---> Package libnl3.i686 0:3.2.7-1.fc17 will be updated
---> Package libnl3.i686 0:3.2.21-1.fc17 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================
Updating:
libnl3 i686 3.2.21-1.fc17 updates 186 k
Transaction Summary
=============================================================================================================================================
Upgrade 1 Package
Total download size: 186 k
Is this ok [y/N]: y
Downloading Packages:
Setting up and reading Presto delta metadata
libnl3-3.2.21-1.fc17.i686.rpm | 186 kB 00:00
Running Transaction Check
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : libnl3-3.2.21-1.fc17.i686 1/2
Cleanup : libnl3-3.2.7-1.fc17.i686 2/2
Verifying : libnl3-3.2.21-1.fc17.i686 1/2
Verifying : libnl3-3.2.7-1.fc17.i686 2/2
Updated:
libnl3.i686 0:3.2.21-1.fc17
Complete!
# yum install libnl3-devel
Loaded plugins: langpacks, presto, refresh-packagekit
Repository updates is listed more than once in the configuration
Repository updates-debuginfo is listed more than once in the configuration
Repository updates-source is listed more than once in the configuration
Repository fedora is listed more than once in the configuration
Repository fedora-debuginfo is listed more than once in the configuration
Repository fedora-source is listed more than once in the configuration
Resolving Dependencies
--> Running transaction check
---> Package libnl3-devel.i686 0:3.2.21-1.fc17 will be installed
--> Processing Dependency: libnl3-cli = 3.2.21-1.fc17 for package: libnl3-devel-3.2.21-1.fc17.i686
--> Processing Dependency: libnl-cli-3.so.200 for package: libnl3-devel-3.2.21-1.fc17.i686
--> Running transaction check
---> Package libnl3-cli.i686 0:3.2.21-1.fc17 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================
Installing:
libnl3-devel i686 3.2.21-1.fc17 updates 54 k
Installing for dependencies:
libnl3-cli i686 3.2.21-1.fc17 updates 58 k
Transaction Summary
=============================================================================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 112 k
Installed size: 430 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): libnl3-cli-3.2.21-1.fc17.i686.rpm | 58 kB 00:00
(2/2): libnl3-devel-3.2.21-1.fc17.i686.rpm | 54 kB 00:00
---------------------------------------------------------------------------------------------------------------------------------------------
Total 12 kB/s | 112 kB 00:09
Running Transaction Check
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : libnl3-cli-3.2.21-1.fc17.i686 1/2
Installing : libnl3-devel-3.2.21-1.fc17.i686 2/2
Verifying : libnl3-devel-3.2.21-1.fc17.i686 1/2
Verifying : libnl3-cli-3.2.21-1.fc17.i686 2/2
Installed:
libnl3-devel.i686 0:3.2.21-1.fc17
Dependency Installed:
libnl3-cli.i686 0:3.2.21-1.fc17
Complete!
安装完成后出现以下文件
$ ls /usr/lib/libnl*
/usr/lib/libnl-3.so /usr/lib/libnl-cli-3.so.200.16.1 /usr/lib/libnl-nf-3.so.200 /usr/lib/libnl.so
/usr/lib/libnl-3.so.200 /usr/lib/libnl-genl-3.so /usr/lib/libnl-nf-3.so.200.16.1 /usr/lib/libnl.so.1
/usr/lib/libnl-3.so.200.16.1 /usr/lib/libnl-genl-3.so.200 /usr/lib/libnl-route-3.so /usr/lib/libnl.so.1.1
/usr/lib/libnl-cli-3.so /usr/lib/libnl-genl-3.so.200.16.1 /usr/lib/libnl-route-3.so.200
/usr/lib/libnl-cli-3.so.200 /usr/lib/libnl-nf-3.so /usr/lib/libnl-route-3.so.200.16.1
/usr/lib/libnl:
cli
$ ls /usr/include/libnl3/netlink/
addr.h cache.h errno.h handlers.h list.h netlink-compat.h object-api.h socket.h version.h
attr.h cli fib_lookup hash.h msg.h netlink.h object.h types.h
cache-api.h data.h genl hashtable.h netfilter netlink-kernel.h route utils.h
$ ls /usr/lib/pkgconfig/libnl-*
/usr/lib/pkgconfig/libnl-1.pc /usr/lib/pkgconfig/libnl-cli-3.0.pc /usr/lib/pkgconfig/libnl-nf-3.0.pc
/usr/lib/pkgconfig/libnl-3.0.pc /usr/lib/pkgconfig/libnl-genl-3.0.pc /usr/lib/pkgconfig/libnl-route-3.0.pc
*.pc文件由pkg-config程序使用
$ pkg-config --cflags --libs libnl-3.0
-I/usr/include/libnl3 -lnl-3
编译程序的使用pkg-config为gcc传递参数
指定头文件搜索路径和链接库名称
$ gcc myprogram.c -o myprogram $(pkg-config --cflags --libs libnl-3.0)