libgcj_bc.so not embedded

View: New views
20 Messages — Rating Filter:   Alert me  
< Prev | 1 - 2 | Next >

libgcj_bc.so not embedded

by Mohsen Saboorian :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi list,

I've compiled succesfully a project (a number of JARs) into native
library using GCJ 4.1 on Ubuntu 6.10 (Edgy). When I run it on a
light-weight FC5 machine, I've getting the following error message:

error while loading shared libraries libgcj_bc.so.1

Why this library is not embedded in my executable file?
Thanks.

Re: libgcj_bc.so not embedded

by Andrew Haley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mohsen Saboorian writes:

 > I've compiled succesfully a project (a number of JARs) into native
 > library using GCJ 4.1 on Ubuntu 6.10 (Edgy). When I run it on a
 > light-weight FC5 machine, I've getting the following error message:
 >
 > error while loading shared libraries libgcj_bc.so.1
 >
 > Why this library is not embedded in my executable file?

It's not supposed to be.  The idea is that you compile your program
and it dynamically links with the libgcj installed on the system.

Andrew.

--
Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, UK
Registered in England and Wales No. 3798903

Re: libgcj_bc.so not embedded

by Mohsen Saboorian :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Andrew,

> It's not supposed to be.  The idea is that you compile your program
> and it dynamically links with the libgcj installed on the system.

Then what happens for example in Windows, where there is no such
linkable library. Is it possible to statically link my program with
this .so file so that there would be an absolute stand-alone
application?

Thanks again.

Re: libgcj_bc.so not embedded

by Andrew Haley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mohsen Saboorian writes:
 >
 > > It's not supposed to be.  The idea is that you compile your program
 > > and it dynamically links with the libgcj installed on the system.
 >
 > Then what happens for example in Windows, where there is no such
 > linkable library. Is it possible to statically link my program with
 > this .so file so that there would be an absolute stand-alone
 > application?

Not quite, but you can link using -static-libgcj.  It doesn't work for
all Java programs, and in general it's a bad idea.  Why do you want to
do this, anyway?

Andrew.

--
Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, UK
Registered in England and Wales No. 3798903

Re: libgcj_bc.so not embedded

by Mohsen Saboorian :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>  > > It's not supposed to be.  The idea is that you compile your program
>  > > and it dynamically links with the libgcj installed on the system.
>  >
>  > Then what happens for example in Windows, where there is no such
>  > linkable library. Is it possible to statically link my program with
>  > this .so file so that there would be an absolute stand-alone
>  > application?
>
> Not quite, but you can link using -static-libgcj.  It doesn't work for
> all Java programs, and in general it's a bad idea.  Why do you want to
> do this, anyway?

I have a Java application and want to have it work on OLPC
(laptop.org). OLPC uses a very light FC 5 I think, which doesn't have
any GCJ library, since their main development environment is Python
and JavaScript. I'll try -static-libgcj option to see if this works.

Thanks.

Re: libgcj_bc.so not embedded

by Marco Trudel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mohsen Saboorian wrote:

>>  > > It's not supposed to be.  The idea is that you compile your program
>>  > > and it dynamically links with the libgcj installed on the system.
>>  >
>>  > Then what happens for example in Windows, where there is no such
>>  > linkable library. Is it possible to statically link my program with
>>  > this .so file so that there would be an absolute stand-alone
>>  > application?
>>
>> Not quite, but you can link using -static-libgcj.  It doesn't work for
>> all Java programs, and in general it's a bad idea.  Why do you want to
>> do this, anyway?
>
> I have a Java application and want to have it work on OLPC
> (laptop.org). OLPC uses a very light FC 5 I think, which doesn't have
> any GCJ library, since their main development environment is Python
> and JavaScript. I'll try -static-libgcj option to see if this works.

I already had static compiled SWT and Swing applications running on OLPC :-)


Marco

Re: libgcj_bc.so not embedded

by Mohsen Saboorian :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>
> I already had static compiled SWT and Swing applications running on OLPC :-)


Macro, I was able to compile my app with GCJ 4.1 package on Ubuntu,
but could not compile it with your GCJ distrib (for Linux). Don't know
if you Linux GCJ should also be used along with  GUI or not :)

Thanks.

Re: libgcj_bc.so not embedded

by Marco Trudel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andrew Haley wrote:

> Mohsen Saboorian writes:
>  >
>  > > It's not supposed to be.  The idea is that you compile your program
>  > > and it dynamically links with the libgcj installed on the system.
>  >
>  > Then what happens for example in Windows, where there is no such
>  > linkable library. Is it possible to statically link my program with
>  > this .so file so that there would be an absolute stand-alone
>  > application?
>
> Not quite, but you can link using -static-libgcj.  It doesn't work for
> all Java programs,

Which ones doesn't work? If you know how to manually add objects that
are not referenced (and thus aren't pulled into the binary), then
everything is fine. At least for me...

> and in general it's a bad idea.  Why do you want to
> do this, anyway?

There seem to be two different universes of GCJ users. Both do not
understand why the other even exists. I also live in the one that only
wants GCJ to create standalone binaries. I can't imagine a reason why to
use GCJ as JVM...
GCJ is (for me), good to:
- get around the problem of telling users to install a JVM. If they have
to install one anyway, why don't then just use one from Sun which has
less bugs?
- better protect the written code
The only other place where GCJ becomes handy are embedded devices. Of
course there you can't install a JVM either and need standalone
binaries... There then come's the other problem of the huge binaries ;-)

Just my 2cents...

Marco

Parent Message unknown Re: libgcj_bc.so not embedded

by J.C. Pizarro :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here's a summary of other conversation:

> > > > Excessive code size growth could also be problem for some programs.
> > > >
>  > > 1) A solution is using the -shared option to generate ".so" library.
>  >
>  > That does not solve things in environments like embedded
>  > environments where there are no shared libraries.
>
>  Use -Os and "strip --strip-all". And remove code if you don't like it.
>
>  > > 2) Another future solution is pack the big ".so" library with UPX
>  > > (Ultimate Packer for eXecutables) or extend the ELF format to
>  > > permit pack the sections with GZ, BZ2 or LZMA.
>  >
>  > We are worried about code space in memory, not space on disk!
>
>  Or extend the ELF format to permit pack non-solidly or solidly (=>
>  slower stream) many subsections with GZ, BZ2, UPX or
>  LZMA (<=1MiB to uncompress e.g.) variants to be refined all in one
>  for better space ( only options -9, -best, ultra, ..).
>
>  Their buffers are very small to permit to raise an exception.
>  Like squashfs for embedded systems instead of cramfs.

This same idea is applicable to pack the gigantic /usr/lib/libgcj.so that
its current non-packed size on disk is >=9 MiB, sometimes >=50 MiB.

Remember, Java is generated to C++ with gcj and compiled with g++.

Re: libgcj_bc.so not embedded

by David Daney :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

J.C. Pizarro wrote:
>
> Remember, Java is generated to C++ with gcj and compiled with g++.
That is incorrect and always has been.

gcj directly generates assembly code for the target processor, just like
all the other GCC language frontends.

David Daney

Re: libgcj_bc.so not embedded

by J.C. Pizarro :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2007/4/7, David Daney <ddaney@...>:

> J.C. Pizarro wrote:
> >
> > Remember, Java is generated to C++ with gcj and compiled with g++.
> That is incorrect and always has been.
>
> gcj directly generates assembly code for the target processor, just like
> all the other GCC language frontends.
>
> David Daney
>

Sure? Why GCJ depends on C++ of GCC?

Re: libgcj_bc.so not embedded

by J.C. Pizarro :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2007/4/7, J.C. Pizarro <jcpiza@...>:

> 2007/4/7, David Daney <ddaney@...>:
> > J.C. Pizarro wrote:
> > >
> > > Remember, Java is generated to C++ with gcj and compiled with g++.
> > That is incorrect and always has been.
> >
> > gcj directly generates assembly code for the target processor, just like
> > all the other GCC language frontends.
> >
> > David Daney
> >
>
> Sure? Why GCJ depends on C++ of GCC?
>

The proof,

./configure ... --enable-languages=c,java doesn't work

./configure ... --enable-languages=c,c++,java works.

The tools gcjh and g++ are used.

Re: libgcj_bc.so not embedded

by Mohsen Saboorian :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

When using "-static-libgcj", I'm getting this error:
/usr/bin/ld: cannot find -lgcj_bc

On 4/7/07, J.C. Pizarro <jcpiza@...> wrote:

> 2007/4/7, J.C. Pizarro <jcpiza@...>:
> > 2007/4/7, David Daney <ddaney@...>:
> > > J.C. Pizarro wrote:
> > > >
> > > > Remember, Java is generated to C++ with gcj and compiled with g++.
> > > That is incorrect and always has been.
> > >
> > > gcj directly generates assembly code for the target processor, just like
> > > all the other GCC language frontends.
> > >
> > > David Daney
> > >
> >
> > Sure? Why GCJ depends on C++ of GCC?
> >
>
> The proof,
>
> ./configure ... --enable-languages=c,java doesn't work
>
> ./configure ... --enable-languages=c,c++,java works.
>
> The tools gcjh and g++ are used.
>

Re: libgcj_bc.so not embedded

by Andrew Pinski-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 4/7/07, J.C. Pizarro <jcpiza@...> wrote:
> Sure? Why GCJ depends on C++ of GCC?

Because part of the libgcj library is written in C++ :).  GCJ's
runtime library is written in Java, C, and C++ and C++ code can call
Java code via the CNI interface which was created even before JNI was
designed :).  GCJ does support JNI now too but GCJ was the first Java
implementation to support native libraries even before Sun did.

Someone needs to read code more.

-- Pinski

Re: libgcj_bc.so not embedded

by Andrew Haley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mohsen Saboorian writes:
 > >  > > It's not supposed to be.  The idea is that you compile your program
 > >  > > and it dynamically links with the libgcj installed on the system.
 > >  >
 > >  > Then what happens for example in Windows, where there is no such
 > >  > linkable library. Is it possible to statically link my program with
 > >  > this .so file so that there would be an absolute stand-alone
 > >  > application?
 > >
 > > Not quite, but you can link using -static-libgcj.  It doesn't work for
 > > all Java programs, and in general it's a bad idea.  Why do you want to
 > > do this, anyway?
 >
 > I have a Java application and want to have it work on OLPC
 > (laptop.org). OLPC uses a very light FC 5 I think, which doesn't have
 > any GCJ library, since their main development environment is Python
 > and JavaScript. I'll try -static-libgcj option to see if this works.

OK, that makes sense.  If you are installing into a standard Fedora
system it makes no sense at all even if statically linking does work
for your particular application, since libgcj is backwards compatible
and if you link statically you won't automatically get bug fixes to
libgcj.  If you're the only application usig libgcj it might well make
sense to save space.

Andrew.

--
Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, UK
Registered in England and Wales No. 3798903

Re: libgcj_bc.so not embedded

by Andi Vajda :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Sat, 7 Apr 2007, Andrew Pinski wrote:

> On 4/7/07, J.C. Pizarro <jcpiza@...> wrote:
>> Sure? Why GCJ depends on C++ of GCC?
>
> Because part of the libgcj library is written in C++ :).  GCJ's
> runtime library is written in Java, C, and C++ and C++ code can call
> Java code via the CNI interface which was created even before JNI was
> designed :).  GCJ does support JNI now too but GCJ was the first Java
> implementation to support native libraries even before Sun did.

And, I might add in reply to an earlier message, CNI is the other major reason
to use gcj. It makes it possible to treat a body of Java code like any other
C/C++ library out there. gcj makes Java code usable and accessible to the
non-Java world. This is where the static linking requirements keeps coming
from.

Andi..

Re: libgcj_bc.so not embedded

by Andrew Haley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Marco Trudel writes:
 > Andrew Haley wrote:
 > > Mohsen Saboorian writes:
 > >  >
 > >  > > It's not supposed to be.  The idea is that you compile your program
 > >  > > and it dynamically links with the libgcj installed on the system.
 > >  >
 > >  > Then what happens for example in Windows, where there is no such
 > >  > linkable library. Is it possible to statically link my program with
 > >  > this .so file so that there would be an absolute stand-alone
 > >  > application?
 > >
 > > Not quite, but you can link using -static-libgcj.  It doesn't work for
 > > all Java programs,
 >
 > Which ones doesn't work?

Anything that loads core classes via reflection or via its own class
loaders, as you must already know by now.

 > If you know how to manually add objects that
 > are not referenced (and thus aren't pulled into the binary), then
 > everything is fine. At least for me...
 >
 > > and in general it's a bad idea.  Why do you want to
 > > do this, anyway?
 >
 > There seem to be two different universes of GCJ users. Both do not
 > understand why the other even exists. I also live in the one that only
 > wants GCJ to create standalone binaries. I can't imagine a reason why to
 > use GCJ as JVM...

 > GCJ is (for me), good to:
 > - get around the problem of telling users to install a JVM. If they have
 > to install one anyway, why don't then just use one from Sun which has
 > less bugs?

Aside from the technical reasons:

It's a different way of thinking about the world.  With free software,
we share libraries between applications.  That way, if a user of one
application finds a bug in a library, they report it and it gets
fixed, and all the other applications that link to the library get the
fix too.  By co-operating we all benefit.  By linking statically you
make sure that other users can't use the library code you have linked,
but you don't get their help either.

 > - better protect the written code

Protect it from what?  Alien invasion?  Herds of rampaging Wildebeest?  :-)

Andrew.

--
Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, UK
Registered in England and Wales No. 3798903

Re: libgcj_bc.so not embedded

by David Daney :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mohsen Saboorian wrote:
> When using "-static-libgcj", I'm getting this error:
> /usr/bin/ld: cannot find -lgcj_bc
>
Please post your complete command line or file a complete bug report.  
If there is a problem in GCC we can fix it.

David Daney


Re: libgcj_bc.so not embedded

by Mohsen Saboorian :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have compiled all jar dependencies into .o files using
-findirect-dispatch option. My last command line to make all-in-one
executable file looks like this:
$ gcj-4.1 -omyApp.executable -static-libgcj -O3 --main=my.main.Class
-findirect-dispatch -fjni jar1.o jar2.o jar3.o

as I addded -static-libgcj, it gives me:
/usr/bin/ld: cannot find -lgcj_bc
collect2: ld return ed 1 exit status

I believe I'm doing something wrong and this simple usage should not be a bug.

Thanks.

On 4/7/07, David Daney <ddaney@...> wrote:

> Mohsen Saboorian wrote:
> > When using "-static-libgcj", I'm getting this error:
> > /usr/bin/ld: cannot find -lgcj_bc
> >
> Please post your complete command line or file a complete bug report.
> If there is a problem in GCC we can fix it.
>
> David Daney
>
>

Re: libgcj_bc.so not embedded

by David Daney :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mohsen Saboorian wrote:
> I have compiled all jar dependencies into .o files using
> -findirect-dispatch option. My last command line to make all-in-one
> executable file looks like this:
> $ gcj-4.1 -omyApp.executable -static-libgcj -O3 --main=my.main.Class
> -findirect-dispatch -fjni jar1.o jar2.o jar3.o
>

-static-libgcj has never been tested with -findirect-dispatch or -fjni.  
If you are statically linking there should be no need for
-findirect-dispatch as you will never be upgrading the runtime (or
anything else for that matter).


> as I addded -static-libgcj, it gives me:
> /usr/bin/ld: cannot find -lgcj_bc
> collect2: ld return ed 1 exit status
>
> I believe I'm doing something wrong and this simple usage should not
> be a bug.
>
> Thanks.
>
> On 4/7/07, David Daney <ddaney@...> wrote:
>> Mohsen Saboorian wrote:
>> > When using "-static-libgcj", I'm getting this error:
>> > /usr/bin/ld: cannot find -lgcj_bc
>> >
>> Please post your complete command line or file a complete bug report.
>> If there is a problem in GCC we can fix it.
>>
>> David Daney
>>
>>


< Prev | 1 - 2 | Next >