Any word on support for Mac (specifically 10.6)?

10 replies [Last post]
L3fty
Offline
Joined: 01/31/2011

I've found the patch from 2009 for building the libraries on Mac, but it doesn't seem to work with the latest version of code. I see that there are plans for including that support in the future. Any update on the progress of that support?

Thanks!

Mark Bednarczyk
Offline
Joined: 03/22/2008
I have been unable to

I have been unable to install libpcap on a mac machine. I have tried everything I know and still unable to get libpcap compiled on a mac machine.

If anyone has ideas or experience it would be trivial to get jnepcap built a OSX/Darwin/OpenDarwin.

Sly Technologies, Inc.
http://slytechs.com

L3fty
Offline
Joined: 01/31/2011
Are the dylib's insufficient?

I'm no pro at this, but I see /usr/lib/libpcap.dylib and /usr/lib/libpcap.A.dylib. From what I read, these are the dynamic libraries on Mac. Are you needing the .so files?

Mark Bednarczyk
Offline
Joined: 03/22/2008
I don't know. They weren't

I don't know. They weren't there the last time I tried to get it to work. It was unable to link the pcap_* native symbols because of the missing library. I did try a bunch of packages and downloads and compiling libpcap with XCode with no luck at the time. Eclipse and java side were super easy to get setup, its just the libpcap.

I'm looking at my MAC machine now and I do see the same library files as well as the /usr/include/pcap.h which was another thing that was missing.

I'll see if I can get this going. Release 1.4 is all about adding new protocols and getting jnetpcap working on as many platforms as possible. Mac would definitely be a big plus.

Sly Technologies, Inc.
http://slytechs.com

Mark Bednarczyk
Offline
Joined: 03/22/2008
I looked into it a bit more

I looked into it a bit more and I think I have everything. However getting java SDK and compiling the native side with ant and OSX cc command will require quiet a bit of tweaking. I found documentation on it, so that should help.

I have the native components that are not portable already ported to BSD which should work the same on Darwin/OSX.

Sly Technologies, Inc.
http://slytechs.com

L3fty
Offline
Joined: 01/31/2011
Let me know how I can help

I'm not very familiar with the JNI side, but I'm definitely interested and willing in helping to test it out. I'm writing some code that jnetpcap would be perfect for, but working on Mac is a requirement.

Thanks for the quick response.

effzeus
Offline
Joined: 02/10/2011
Having support for

Having support for Darwin/MacOS X will certainly help my application too.

pfoomer
Offline
Joined: 03/01/2011
This is what I did yesterday

Hi

I created using Netbeans 6.9.1 on OSX 10.6.6, with the latest Java ADC release (though this shouldnt be an issue) two projects, one for the java (trunk Version 2), the other for the C++.

I modified the C++ using a stripped down diff file from the one on sourceforge, to modify jnetpcap_utils.cpp.

I modified the calls to SystemLoadLibrary like this...

public static final String JNETPCAP_LIBRARY_NAME = "jnetpcap.jnilib";

String value =
System.getProperty("java.library.path",
"defaultvalue");

System.out.println("Library Path: " + value);

// System.loadLibrary(JNETPCAP_LIBRARY_NAME);

//System.loadLibrary("libJNDIjIroxLib.dylib");
System.load(value + "/" + JNETPCAP_LIBRARY_NAME);

(SystemLoadLibrary has never worked for me on OSX)

This is used in a couple of files, you will find it when the run time runs!!

I built the jni's (lots of them) like this...

javah -classpath ../build/classes -o org_jnetpcap_Pcap.h org.jnetpcap.Pcap

I placed the resultant headers into the C++ project, modified the build to ensure correct architecture

I built the resultant library, jnetpcap.jnilib in

/Library/Java/Extensions

these are the options I used

Headers

/Developer/SDKs/MacOSX10.6.sdk/usr/include
/System/Library/Frameworks/JavaVM.framework/Headers
/System/Library/Frameworks/IOKit.framework/Headers
/System/Library/Frameworks/Kernel.framework/Versions/A/Headers

Link Options
-dynamiclib -install_name jnetpcap.jnilib -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/jnetpcap.jnilib -fPIC -L/usr/lib -lpcap
-mmacosx-version-min=10.6 -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -framework JavaVM -lstdc++

(note I am building on intel 32bit, other flags required for 64bit)

I called the test program from netbeans like this...

Main Class: org.jnetpcap.TestPcapBetaJNI

VM Options -Djava.library.path="/Library/Java/Extensions" -Xmx256M

(the Xmx sets the memory, the important bit is the -D option

it all ran up, then I had to decide what to do with this now I have got it working!!!

Mark Bednarczyk
Offline
Joined: 03/22/2008
Thanks for the info. I'll

Thanks for the info. I'll try and incorporate it into the build scripts. I too have it almost running, but there was a place where I got stuck. I'll see if between your and my approach I can get this finally done. (Starting in 1.4, I will not back port the build scripts to 1.3).

Sly Technologies, Inc.
http://slytechs.com

pfoomer
Offline
Joined: 03/01/2011
Netbeans etc

Hi

tried to pm you didn't work (as well as the starter of this thread), I could let you have the netbeans files and other stuff if you want, then you could crib them for your environment.

I am using your ver2 trunk, but apart from a few directory changes, it should work ok on the previous version.

What you using for development?

Let me know what you need

Mark Bednarczyk
Offline
Joined: 03/22/2008
I'm using Elicpse, although

I'm using Eclipse, although I have Netbeans installed as well for troubleshooting when needed.

My smtp email relay is getting spammed to oblivion right now and causing email to be rejected.

Sly Technologies, Inc.
http://slytechs.com

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.