X-Spam-Check-By: sourceware.org
From: "Dave Korn" <dave.korn@artimi.com>
To: <cygwin@cygwin.com>
Subject: RE: cygwin + JNI problem with sockets
Date: Thu, 19 Oct 2006 14:09:27 +0100
Message-ID: <02ac01c6f37f$ce414ce0$a501a8c0@CAM.ARTIMI.COM>
MIME-Version: 1.0
Content-Type: text/plain; 	charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Mailer: Microsoft Office Outlook 11
In-Reply-To:  <loom.20061019T060345-494@post.gmane.org>
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

On 19 October 2006 05:17, Chandra Sekhar wrote:

> Hi everyone,
> I am a student trying to create a dll of a socket program in cygwin using
> -mno- cygwin as following (after compilation).
>  "gcc -mno-cygwin -shared -o udpServer0.dll udpServer0.o"
> 
> but it throws the following "Errors".
> 
> udpServer0.o:udpServer0.c:(.text+0x41): undefined reference to `_htonl'
> udpServer0.o:udpServer0.c:(.text+0x50): undefined reference to `_htons'
> udpServer0.o:udpServer0.c:(.text+0x70): undefined reference to `_socket'
> udpServer0.o:udpServer0.c:(.text+0x8d): undefined reference to `_bind'
> udpServer0.o:udpServer0.c:(.text+0xb2): undefined reference to `_recv'
> collect2: ld returned 1 exit status

  I think you need to link against the winsock library.  Add "-lws32_2" to the
end of the command line.

> if i create a dll without the "-mno-cygwin" option and call the function in
> the JNI java program, it doesnt execute (doesnt respond, goes to infinite
> loop). But with "-mno-cygwin" option the other programs (other than socket
> programs), they work just fine when called from Java using JNI. Can anyone
> throw in some ideas and suggestions as to where the problem could be or the
> solution if you know. I can post the udpServer0.c if you want me to.

  A win32 program (the java interpreter) can't call a cygwin JNI.  Not
directly, anyway.  Maybe this:

http://elliotth.blogspot.com/2005/08/porting-jni-code-to-win32-with-cygwin.htm
l

could be useful.

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

