Creating a shared lib (.so) using the autotools in KDev
Dries Decock
decock at tcomlabs.com
Mon Nov 14 07:55:24 GMT 2005
I have created several shared libraries for java. I leeve the target as a
probram in bin. Then I :
* set compiler flags for c++ -fPIC
* set the linker flags to : -shared -o libxxxx.so
This works for me !
I hope this helps.
On Friday 11 November 2005 20:42, David Ohlemacher wrote:
> Hi all,
>
> I am trying to create a shared library (.so) using KDevelop 3.2.2 (KDE
> 3.4.2 on FC4). I am trying to use this shared lib from within Java
> using the Java Native Interface (JNI). Has anyone done this?
>
> According to the mediaWiki FAQ
> <http://www.kdevelop.org/mediawiki/index.php/FAQ#How_to_create_a_.so_librar
>y.3F>, I need to follow these steps:
>
> * Add a target to the project
> o primary: Library
> o prefix: noinst
> o file name: your_lib.so
> o Linker Flags->Other: -shared
> * Add the cpp/h files to this target
> * set compiler flags for c++ -fPIC
>
> I did all these things. The library gets created as
> libJniHelloWorld.so.a, which is wrong. Also, all the options remained
> grayed out when I select the library and noinst options. I had to apply
> them, then open the properties, in order to add -shared.
>
> When I try to use the library, I get "invalid ELF header" from Java.
>
> If I manually make the library, w/o kdevelop, I get a proper shared lib:
> * gcc -shared -I/opt/j2sdk1.4.2_10/include/
> -I/opt/j2sdk1.4.2_10/include/linux/ JniHelloWorld.c -o libJniHelloWorld.so
> This lib works fine.
>
> I also have created and tried a libtool library, libJniHelloWorld.la.
> The JNI refuses to load this at all, since it only lets you specify
> "JniHelloWorld" and it assumes the lib prefix and .so extension. I did
> set LD_LIBRARY_PATH to include the pwd.
> java.lang.UnsatisfiedLinkError: no libnumlist.la in java.library.path
>
> I either need to get the autotools to create a shared library (.so), or
> get the JNI to load a .la file.
>
> Thanks,
> -d
>
>
>
>
> -
> to unsubscribe from this list send an email to
> kdevelop-request at kdevelop.org with the following body: unsubscribe
> »your-email-address«
--
Dries Decock
Software Engineer
tComLabs
Gildestraat 8
9000 Gent - Belgium
-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
unsubscribe »your-email-address«
More information about the KDevelop
mailing list