You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by rakesh bhakta <ro...@gmail.com> on 2004/10/07 17:14:44 UTC

Native-Plugin - library name

I am trying to use the maven-native-plugin and have found some success
running the HelloWorld sample on both a cygwin/window and a linux
enviroment after manually renaming the library file.

The issue I have is with the resulting library name from the
HelloWorld maven build.

1) Why does the library name have a "lib" prefix ? Is this a bug ?  In
the HelloWorld sample, this prefix is causing the
System.loadLibrary("native-helloworld-1.0"; to fail . My build creates
a library called libnative-helloworld-1.0.so.  I believe the intent
might have been to create a directory "lib/".

2) Why must the lib name have a .so extension ?  It is not
overridable, and thus build not approriate for cygwin/windows.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Native-Plugin - library name

Posted by rakesh bhakta <ro...@gmail.com>.
> on my environment the native hello world sample is working. The "lib" prefix
> of the filename is necessary. If I remove the "lib" prefix of the "so" file I
> run into this error:
> Exception in thread "main" java.lang.UnsatisfiedLinkError: no
> native-helloworld-1.0 in java.library.path

Yes, I realize "lib" prefix is required on the Linux, and works on
Linux without problem. However, I have not been able to run it on
windows with the windows JVM from Sun, and then add cygwin in the mix.

I did review the maven-native-plugin-1.1/plugin.jelly code and opted
against creating my own version of it.  However, I have been able to
solve my issue with some pre/post goals like below for those
interested:

  <preGoal name="native:compile">
    <j:if test="${systemScope['os.name'].startsWith('Windows')}" >
       <echo>Setting Env lib for ${os.name}</echo>  
       <maven:set plugin="maven-native-plugin"
property="maven.native.include.os" value="win32"/>
       <maven:set plugin="maven-native-plugin"
property="maven.native.compiler.arg.start" value="-mno-cygwin"/>
       <maven:set plugin="maven-native-plugin"
property="maven.native.linker.arg.start" value="-mno-cygwin
-Wl,--add-stdcall-alias"/>
    </j:if>     
  </preGoal>
  
  <postGoal name="native:compile">
    <j:if test="${systemScope['os.name'].startsWith('Windows')}" >
       <echo>Renaming lib for ${os.name}</echo>  
       <ant:copy
file="${maven.build.dir}/native/lib${pom.artifactId}-${pom.currentVersion}.so"
	       tofile="${maven.build.dir}/native/${pom.artifactId}-${pom.currentVersion}.dll"
overwrite="true"/>
    </j:if>     
  </postGoal>

my environment:
  Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_03-b02) 
  Maven 1.0
  Maven Native Plugin 1.1
  gcc version 3.3.1 (cygming special)
  Windows XP x86

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Native-Plugin - library name

Posted by Joachim Bader <in...@joachim-bader.de>.
Hi,

On Thursday 07 October 2004 17:14, rakesh bhakta wrote:
> I am trying to use the maven-native-plugin and have found some success
> running the HelloWorld sample on both a cygwin/window and a linux
> enviroment after manually renaming the library file.
>
> The issue I have is with the resulting library name from the
> HelloWorld maven build.
>
> 1) Why does the library name have a "lib" prefix ? Is this a bug ?  In
> the HelloWorld sample, this prefix is causing the
> System.loadLibrary("native-helloworld-1.0"; to fail . My build creates
> a library called libnative-helloworld-1.0.so.  I believe the intent
> might have been to create a directory "lib/".

on my environment the native hello world sample is working. The "lib" prefix 
of the filename is necessary. If I remove the "lib" prefix of the "so" file I 
run into this error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no 
native-helloworld-1.0 in java.library.path

my environment:
JDK 1.4.2_02
Maven 1.0
Maven Native Plugin 1.1
gcc version 3.3.2 (Mandrake Linux 10.0 3.3.2-6mdk)
Linux Mandrake 10.0 x86

As you can see in 
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#loadLibrary(java.lang.String) 
and
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#mapLibraryName(java.lang.String)

the name of the native library is plattform dependend. It's new for me that on 
linux systems the "lib" prefix is not needed. 
Can you tell me something about your environment, please?
Java VM? Operating System?

If the "lib" prefix is not needed on your plattform you can easily modifie the 
maven-native.plugin jelly script.

.maven/cache/maven-native-plugin-1.1/plugin.jelly
...
<j:if test="${outputPresent == 'true'}">
	<ant:copy file="${maven.build.dir}/native/lib_.so" 
            tofile="${maven.build.dir}/native/lib${pom.artifactId}-${pom.currentVersion}.so" 
overwrite="true"/>
</j:if> 

modify the tofile argument. remove the lib prefix.

> 2) Why must the lib name have a .so extension ?  It is not
> overridable, and thus build not approriate for cygwin/windows.

other libraries extensions like .dll or something else are not supported at 
the moment. I'm waiting for commit of some patches of the native plugin. 
After then I'll implement dll support for the native plugin.

regards,
Joachim

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org