安裝了/usr/ports/net/libnet/後找不到 … - BBS

Table of Contents

※ 引述《harddriver (HD)》之銘言:
: 在freebsd下用port安裝了libnet後…
: 在t.c裡面使用
: #include <libnet.h>
: 使用gcc t.c -o t -lnet出現
: t.c:2:20: error: libnet.h: No such file or directory
: ldconfig -r 也有看到 -lnet
: 這是為什麼呢?

屬於 FreeBSD OS 本體以外的東西會被裝在 /usr/local 下面,
所以你要加上 -I/usr/local/include 才行,
同樣的 link 的路徑也是要像 -L/usr/local/lib 這樣加。

我沒有裝這個 ports 所以不清楚 pkg-config 有沒有支援,
如果有的話可以這樣下:
gcc `pkg-config --cflags libnet` t.c -o t `pkg-config --libs libnet`
有支援的話應該就會幫你弄好正確的參數。

--
Ling-hua Tseng ([email protected])
Department of Computer Science, National Tsing-Hua University
Interesting: C++, Compiler, PL/PD, OS, VM, Large-scale software design
Researching: Software pipelining for VLIW architectures
Homepage: http://www.tinlans.org

--

All Comments