HOWTO: Compile jpcap 0.7 for amd64

三月 18, 2009

As was introduced in it's project home, Jpcap is a Java library for capturing and sending network packets.  However, this project hadn't been updated for quite a long time, and NO any 64bit platform version was provided.

In the Google Discussion Group, "Tri" tried to compile jpcap in Ubuntu 8.04 64bit, and failed, giving such infomation:

/usr/bin/ld: /tmp/cc7mzY1t.o: relocation R_X86_64_32 against `a localsymbol'
can not be used when making a shared object; recompile with -fPIC


/tmp/cc7mzY1t.o: could not read symbols: Bad value

collect2: ld returned 1 exit status

make: *** [libjpcap.so] Error 1

In fact this's not a big problem, can be fixed easily.

Edit the Makefile, find such pragaph:(if you compile for Linux)

ifeq ($(PLATFORM), Linux)
JNI_INCLUDE2 = $(JAVA_DIR)/include/linux
COMPILE_OPTION = -shared -L.
SUFFIX = .so

Insert -fPIC to COMPILE_OPTION as reminded:

ifeq ($(PLATFORM), Linux)
JNI_INCLUDE2 = $(JAVA_DIR)/include/linux
COMPILE_OPTION = -fPIC -shared -L.
SUFFIX = .so

OK, try to make it, it should be done in seconds, and you get a 64 version of libjpcap.so.

The -fPIC option told the gcc emit position-independent codes for dynamic linking. I think this should be added whatever system you use, but somehow it works all right without -fPIC in 32bit Linux.

The java part of jpcap didn't need to compile again anyway, for the java platform indepentdence.

Then, copy it to /usr/lib/libjpcap.so, and /usr/java/packages/lib/ext/jpcap.jar, I bet every thing goes fine.

I already packed a deb and it works perfectly in Ubuntu 8.10 amd64, it should also be compatible to the whole Debian serious. Also, I correct the deb depent form sun-jave6-jdk to sun-jave6-jre, in fact, it even works OK with OpenJDK.

Download it here : http://ptcoding.googlecode.com/files/jpcap0.7_amd64.deb

tags: , ,
posted in Unix/Linux by BOYPT

Follow comments via the RSS Feed | 留下评论 | Trackback URL

2 Comments to "HOWTO: Compile jpcap 0.7 for amd64"

  1. unknown wrote:

    Thank youuuuuuuu! :)
    The package for amd64 works fine also in ubuntu 9.10.
    Please send it to jpcap developers!

    回复回复
  2. Henry wrote:

    Tanks a lot, I tested it, also in ubuntu 9.10.

    回复回复

Leave Your Comment

注意: 评论者允许使用'@user空格'的方式将自己的评论通知另外评论者。例如, ABC是本文的评论者之一,则使用'@ABC '(不包括单引号)将会自动将您的评论发送给ABC。使用'@all ',将会将评论发送给之前所有其它评论者。请务必注意user必须和评论者名相匹配(大小写一致)。

Page optimized by WP Minify WordPress Plugin

 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org