You are not logged in.

#1 2009-02-26 20:32:48

_dunmer
Member
From: Bratislava, Slovakia
Registered: 2008-10-03
Posts: 40

[SOLVED] compiling jpcap on 64bit system

hello

can i compile jpcap on arch x86_64?
because when i try it i get this error:

/usr/bin/ld: /tmp/ccWFe5Db.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/tmp/ccWFe5Db.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [libjpcap.so] Error 1

i tried to serach web but i just found out that this is architecture issue but no solution..


edit:
if i use 32bit enviroment (http://wiki.archlinux.org/index.php/Arc … bit_system) to compile it will it wrok on my 64 bit?

Last edited by _dunmer (2009-02-28 13:15:28)

Offline

#2 2009-02-27 05:44:11

AndyRTR
Developer
From: Magdeburg/Germany
Registered: 2005-10-07
Posts: 1,641

Re: [SOLVED] compiling jpcap on 64bit system

Search for -fPIC compiler flag issues in our forums and mailing lists. Fix it in the corresponding Makefile. If you don't find it try export CFLAGS="$CFLAGS -fPIC" though this is not the proper way and slows it down more than needed.

Please also file an upstream bug.

Offline

#3 2009-02-27 10:05:10

_dunmer
Member
From: Bratislava, Slovakia
Registered: 2008-10-03
Posts: 40

Re: [SOLVED] compiling jpcap on 64bit system

this is whole makefile

JAVA_DIR = $(JAVA_HOME)

JNI_INCLUDE = $(JAVA_DIR)/include

# try to detect your OS using 'uname'
PLATFORM = $(shell "uname")

ifeq ($(PLATFORM), Linux)
    JNI_INCLUDE2 = $(JAVA_DIR)/include/linux
    COMPILE_OPTION = -shared -L.
    SUFFIX = .so
else
ifeq ($(PLATFORM), FreeBSD)
    JNI_INCLUDE2 = $(JAVA_DIR)/include/freebsd
    COMPILE_OPTION = -shared -L.
    SUFFIX = .so
else
ifeq ($(PLATFORM), SunOS)
    JNI_INCLUDE2 = $(JAVA_DIR)/include/solaris
    COMPILE_OPTION = -G
    SUFFIX = .so
else
ifeq ($(PLATFORM), Darwin)
    JNI_INCLUDE2 = /System/Library/Frameworks/JavaVM.framework/Headers 
    COMPILE_OPTION = -bundle -framework JavaVM
    SUFFIX = .jnilib
endif
endif
endif
endif

# Specify where pcap.h is
PCAP_INCLUDE = /usr/include
#PCAP_INCLUDE = /usr/include/pcap

#CC = cl
CC = gcc

all: libjpcap.so

libjpcap.so: JpcapCaptor.c JpcapSender.c JpcapWriter.c\
             packet_arp.c packet_datalink.c packet_icmp.c packet_ip.c\
             packet_ipv6.c packet_tcp.c packet_udp.c 
        $(CC) $(COMPILE_OPTION) -I$(JNI_INCLUDE) -I$(JNI_INCLUDE2)\
         -I$(PCAP_INCLUDE)\
        JpcapCaptor.c JpcapSender.c JpcapWriter.c\
          packet_arp.c packet_datalink.c packet_icmp.c packet_ip.c\
          packet_ipv6.c packet_tcp.c packet_udp.c\
        -o libjpcap$(SUFFIX) -lpcap
clean:
        -rm libjpcap$(SUFFIX)

witt thie make file i get this error:

[dunmer@joybox c]$ make
gcc -shared -L. -I/opt/java/include -I/opt/java/include/linux\
                 -I/usr/include\
                JpcapCaptor.c JpcapSender.c JpcapWriter.c\
          packet_arp.c packet_datalink.c packet_icmp.c packet_ip.c\
          packet_ipv6.c packet_tcp.c packet_udp.c\
                -o libjpcap.so -lpcap
JpcapCaptor.c: In function 'Java_jpcap_JpcapCaptor_processPacket':
JpcapCaptor.c:467: warning: cast to pointer from integer of different size
JpcapCaptor.c: In function 'Java_jpcap_JpcapCaptor_loopPacket':
JpcapCaptor.c:486: warning: cast to pointer from integer of different size
JpcapCaptor.c: In function 'dispatcher_handler':
JpcapCaptor.c:700: warning: cast from pointer to integer of different size
JpcapWriter.c: In function 'Java_jpcap_JpcapWriter_close':
JpcapWriter.c:47: warning: incompatible implicit declaration of built-in function 'free'
packet_icmp.c: In function 'analyze_icmp':
packet_icmp.c:79: warning: cast to pointer from integer of different size
packet_icmp.c:81: warning: cast from pointer to integer of different size
/usr/bin/ld: /tmp/cceBND7o.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/tmp/cceBND7o.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [libjpcap.so] Error 1

when i add -fPIC to CFLAGS it doesn't do anything and i get the same output

somebody tell me to chanege Linux part of make file like this:

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

whit this a i get another error:

[dunmer@joybox c]$ make
gcc  -I/opt/java/include -I/opt/java/include/linux\
                 -I/usr/include\
                JpcapCaptor.c JpcapSender.c JpcapWriter.c\
          packet_arp.c packet_datalink.c packet_icmp.c packet_ip.c\
          packet_ipv6.c packet_tcp.c packet_udp.c\
                -o libjpcap.so -lpcap
JpcapCaptor.c: In function 'Java_jpcap_JpcapCaptor_processPacket':
JpcapCaptor.c:467: warning: cast to pointer from integer of different size
JpcapCaptor.c: In function 'Java_jpcap_JpcapCaptor_loopPacket':
JpcapCaptor.c:486: warning: cast to pointer from integer of different size
JpcapCaptor.c: In function 'dispatcher_handler':
JpcapCaptor.c:700: warning: cast from pointer to integer of different size
JpcapWriter.c: In function 'Java_jpcap_JpcapWriter_close':
JpcapWriter.c:47: warning: incompatible implicit declaration of built-in function 'free'
packet_icmp.c: In function 'analyze_icmp':
packet_icmp.c:79: warning: cast to pointer from integer of different size
packet_icmp.c:81: warning: cast from pointer to integer of different size
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.3/../../../../lib/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [libjpcap.so] Error 1

nothing i could find about -fPIC helped me..

Offline

#4 2009-02-27 16:31:16

_dunmer
Member
From: Bratislava, Slovakia
Registered: 2008-10-03
Posts: 40

Re: [SOLVED] compiling jpcap on 64bit system

ok, i give up

can anybody tell what have i do to use this library compilated on 32bit system? some 32bit enviroment?

Offline

#5 2009-02-28 13:15:06

_dunmer
Member
From: Bratislava, Slovakia
Registered: 2008-10-03
Posts: 40

Re: [SOLVED] compiling jpcap on 64bit system

i created 32bit enviroment using this wiki page: http://wiki.archlinux.org/index.php/Arc … bit_system and compiled it there..
it's working or at least it looks working.

Offline

Board footer

Powered by FluxBB