problem with libtool under windows and cygwin

2009-04-09 Thread Andreas Otto
Hello,

  just an other question for my software porting project 

  I'm using libtool to create libraries on unix and windows
  on both system it works fine.

  later I use this library in java code as JNI library

  with:

   System.loadLibrary(javamsgque);

  this works fine on UNIX because libtool create the library

libjavamsgque.so

  from the automake rule

pkglib_LTLIBRARIES = libjavamsgque.la

  The problem is windows because libtool on windows create

cygjavamsgque.dll

   and this library have to be loaded with

   System.loadLibrary(cygjavamsgque);


  as special restriction I use the build-tools from cygwin
  but it is no cygwin library at all because I use the
  build-in mingw compiler

gcc -mno-cygwin

  and the library is a real windows libraray ...

  question: howto avoid the cyg prefix ?


thanks for help


___
http://lists.gnu.org/mailman/listinfo/libtool


Re: problem with libtool under windows and cygwin

2009-04-09 Thread Charles Wilson
Andreas Otto wrote:

 
   as special restriction I use the build-tools from cygwin
   but it is no cygwin library at all because I use the
   build-in mingw compiler
 
   gcc -mno-cygwin

This is *not* a built-in mingw compiler.  It's a hack that sometimes
works, but always causes problems.  It is deprecated and will be removed
from cygwin's gcc-4 releases.  It will be replaced by a true cross
compiler (cygwin-host, mingw-target).

   and the library is a real windows libraray ...
 
   question: howto avoid the cyg prefix ?

Tell configure (and therefore, libtool) that your eventual $host will be
mingw:

configure --build=cygwin --host=mingw CC=gcc -mno-cygwin

(The CC= part may be required for now, until cygwin begins distributing
a real cross-compiler.  OR, you could instead invoke the *mingw*
project's CC from a cygwin environment. See the mingw-users mailing
list; there was a discussion about that topic just this week.)

While all of the above may solve your problem for *nix and mingw, what
if you want to build an actual cygwin version?  I think you really need
 platform-dependent code.  My Java's a little rusty, but

MyLoadLibrary(String module_basename)
{
  if System.platform() == cygwin {
String MODULE_PREFIX = cyg
  } else {
String MODULE_PREFIX = lib
  }
  System.loadLibrary(MODULE_PREFIX + module_basename)
}

Naturally, you can make this a lot cleaner with additional abstraction
(a portability class, where MODULE_PREFIX is a final member so the
System.platform() test only happens once). You could do fancy things in
MyLoadLibrary so that module_basename can have the lib prefix and it
just gets stripped off and replaced with MODULE_PREFIX only when
necessary -- this way the rest of your code can pretend that it always
uses libfoo.  etc. etc.

--
Chuck


___
http://lists.gnu.org/mailman/listinfo/libtool