Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
144 user(s) are online (136 user(s) are browsing Forums)

Members: 2
Guests: 142

jabirulo, Mr_byte, more...

Support us!

Headlines

 
  Register To Post  

How to build a shared/static object/library?
Home away from home
Home away from home


See User information
Hello there,

i'm not much of a porter, grabbing only projects that are already cleaned up and/or have a really helpful bunch of devs that don't get freaked out on noob questions and help a lot

Now i'm working on a project which needs libmpeg2(dec) for video replay...which AmigaOS4 doesn't have.

I haven't found anything on the net explaining (for dummies) on how to build/compile a shared object (or static library for that matter) out of some source on AmigaOS4 (but maybe i have looked in the wrong places or not hard enough?).

If anyone got any pointers i'd be really glad for showing me.

The source btw is here

Thank you very much

Go to top
Re: How to build a shared/static object/library?
Quite a regular
Quite a regular


See User information
@Raziel

Most of the configure scripts have an option to activate shared/static build of a library. So there is great chance that by only passing the correct option to the configure script you'll end up with a shared object library.

PS: With my current project (which is using an open source library) I have had a problem generating both static and shared library at the same time even if it pretends to support it. So my advise would be to - if you want to generate both - to to it in two passes (one for shared and one for static) rather than in a single one.

Back to a quiet home... At last
Go to top
Re: How to build a shared/static object/library?
Home away from home
Home away from home


See User information
@abalaban

Quote:

So my advise would be to - if you want to generate both - to to it in two passes (one for shared and one for static) rather than in a single one.


This is particularly important. libtool would sort that out for you when it's working, but if not. The object files for a shared object *cannot* *mustnot* be used in static library and vice verca.

@Raziel

Building the two are quite different.

If you have a bunch of c files you want to turn into libs by hand:

Shared objects are built with gcc the files must be compiled with the -fPIC option *very important*.

eg.

gcc -o myobj.os myobj.c -fPIC <rest of CFLGS>

then combined with


gcc -o mysharedobj.so -shared myobj.os myotherobj.os mythirdobj.os -lrequiredlib -lrequiredlib

using the .os extention isn't required but helps to stop accidental mixing object files between static and non static buiilds.

Static libs are build with 'ar'

build the object files without -fPIC *very important*


then combine them with ar


ar mystaticlib.a myobj.o myotherobj.o mythirdobj.o


IMHO you not use shared libs unless you need to load modules dynamically, or combine it with something like python.



Go to top
Re: How to build a shared/static object/library?
Home away from home
Home away from home


See User information
Thanks for the hints both of you.

I think this is a goner though...it needs setjmp.h in cpu_accel.c and while i found it on the net i don't think it will work out.

Ah well...

Go to top
Re: How to build a shared/static object/library?
Home away from home
Home away from home


See User information
@Raziel Quote:
it needs setjmp.h

I must be being thick, but the following compiles for me:
#include <setjmp.h>

Author of the PortablE programming language.
Go to top
Re: How to build a shared/static object/library?
Just can't stay away
Just can't stay away


See User information
@Raziel

setjmp.h exists (and is working) in newlib so that should not be a problem.

Quote:

/SDK/newlib/include$ grep -R setjmp *
setjmp.h: setjmp.h
setjmp.h:#include <machine/setjmp.h>
setjmp.h:int _EXFUN(setjmp,(jmp_buf __jmpb));
sys/reent.h:#include <setjmp.h>

Go to top
Re: How to build a shared/static object/library?
Home away from home
Home away from home


See User information
hmm, ok then it's using clib i think...is there a way to tell it to use newlib explicitely?

I get implicit declarations on that setjmp.h

Go to top
Re: How to build a shared/static object/library?
Amigans Defender
Amigans Defender


See User information
Our gcc use newlib by default except if you use -mcrt=clib2 or -mcrt=clib2-ts OR your gcc is ancient..

i'm really tired...
Go to top
Re: How to build a shared/static object/library?
Just can't stay away
Just can't stay away


See User information
@Raziel

Have you checked that the setjmp.h file is being included in the file in question?

Go to top
Re: How to build a shared/static object/library?
Just can't stay away
Just can't stay away


See User information
@Raziel

Took a look at the libmpeg2 sources and it requires sigsetjmp() and siglongjmp() functions which are not in newlib. Note that the altivec detection in cpu_accel.c should be replaced by a call to IExec->GetCPUInfoTags() but just to get it compiled and working quickly you can use the option "--disable-accel-detect" when configuring.

In order to produce a working shared object you will also need to modify the following variables in libtool:
Quote:

# Method to check whether dependent libraries are shared objects.
deplibs_check_method="pass_all"
...
# Whether libtool must link a program against all its dependency libraries.
link_all_deplibs=yes


These are the commands I just used to configure and build libmpeg2 on my Ubuntu machine with crosscompilers installed:
Quote:

./configure --prefix=/SDK/local/newlib --host=ppc-amigaos --disable-largefile LDFLAGS=-use-dynld --disable-accel-detect
(modified libtool file)
make

Go to top
Re: How to build a shared/static object/library?
Quite a regular
Quite a regular


See User information
I had this same problem once. I don't remember what I needed it for.

Go to top
Re: How to build a shared/static object/library?
Home away from home
Home away from home


See User information
Quote:

afxgroup wrote:
Our gcc use newlib by default except if you use -mcrt=clib2 or -mcrt=clib2-ts OR your gcc is ancient..


gcc (GCC) 4.2.4 (adtools build 20090118)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Might be what salass00 said, then...

Go to top
Re: How to build a shared/static object/library?
Home away from home
Home away from home


See User information
@salass00

I merged in all your changes, but it chokes later on undefined references

Would you care to upload the libs to the Depot?
That would be grand, thank you

Thank you for the help, learned a bit again



Go to top
Re: How to build a shared/static object/library?
Just can't stay away
Just can't stay away


See User information

Go to top
Re: How to build a shared/static object/library?
Home away from home
Home away from home


See User information
@salass00

Awesome

Thank you so much

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project