Syllable Forum Index Syllable
Syllable Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

shared libraries ?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Syllable Forum Index -> Syllable Desktop
View previous topic :: View next topic  
Author Message
neundorf



Joined: 13 Nov 2007
Posts: 13

PostPosted: Tue Nov 13, 2007 5:49 pm    Post subject: shared libraries ? Reply with quote

Hi,

sorry for a Syllable-newbie question: does Syllable support shared libraries ?
Using google I came to the result that it basically does, but they are not used and the GNU tools don't know how to do it.
So, here are my questions:
-are shared libraries supported ?
-what is their naming convention, the same as on Linux (libXXX.so) ?
-what is the command line to create a shared library from a set of object files ?
-does linking to a shared library work differently than under Linux ?
-is dlopen() or something similar supported ?

Thanks
Alex
Back to top
View user's profile Send private message Send e-mail
Vanders
The Knights of Syllable


Joined: 14 Sep 2007
Posts: 849

PostPosted: Wed Nov 14, 2007 3:43 am    Post subject: Re: shared libraries ? Reply with quote

[quote="neundorf"]Hi,
sorry for a Syllable-newbie question: does Syllable support shared libraries ?
[/quote]

Yes. Syllable uses ELF and supports ELF Dynamic Shared Objects (DSOs, shared libraries).

[quote]
So, here are my questions:
-are shared libraries supported ?
-what is their naming convention, the same as on Linux (libXXX.so) ?
[/quote]

Yes, including versioned libraries I.e. you may have multiple versions of libfoo.so such as libfoo.so.1.0.4 & libfoo.so.2.5

[quote]
-what is the command line to create a shared library from a set of object files ?
[/quote]

Same as with Linux I.e. "gcc foo.o -shared -o libfoo.so" and all the additional linker options you can use (I.e. -Wl,-soname etc.)

[quote]
-does linking to a shared library work differently than under Linux ?
[/quote]

Nope.

[quote]
-is dlopen() or something similar supported ?
[/quote]

Yup. There are two APIs: the native one (open_library() etc.) and a dlfcn one via. libdl (Which is a wrapper over the native API).

You missed some question though, so let me expand. The problem we used to have was the libtool was not ported to Syllable, so although shared objects were supported it did not know how to do it. Any Autotools configure script that used libtool would build static libraries only because of it. libtool has been available for a while now, and Builder supports the "make-shared" directive which ensures the source is updated with out libtool port and can build shared libraries.

It's also worth noting that Syllable has the ELF loader and Runtime Linker Deamon (RTLD, ld.so in Linux) in the kernel, so there is no ld.so and no need for things like ldconfig etc. The kernel takes care of it all. So working with shared libraries on Syllable can actually be a little easier than on other platforms.

Help that helps!
Back to top
View user's profile Send private message Send e-mail
neundorf



Joined: 13 Nov 2007
Posts: 13

PostPosted: Wed Nov 14, 2007 11:30 am    Post subject: two more questions: file system layout and strace ? Reply with quote

Thanks Smile

Now I have two more questions:

I found that there is strace, but it seems it has to be used differently than under Linux and "man strace" says there is no man page. Where can I find documentation ?
(I want to log the file accesses of a process into a file)

Second: where can I find information about the file system layout of Syllable ? It has directories like /usr/indexes/bin/ or /usr/make/bin/, which are quite different than under Linux. Is there a document somewhere ?

Thanks
Alex
Back to top
View user's profile Send private message Send e-mail
Kaj
The Knights of Syllable


Joined: 14 Sep 2007
Posts: 2207
Location: Friesland

PostPosted: Wed Nov 14, 2007 11:42 am    Post subject: Reply with quote

STrace is described in the How to Start Developing tutorial on the new Development site.

I'm actually extending the filesystem layout right now. Smile There's no document of it in particular, but you should read the Builder manual and have a look at the package command;

package ?

for example.

Ports from generic Unix have their own application directories under /usr/, that are symlinked in /usr/indexes/. I'm now introducing an extra, versioned pool under /system/resources/, with symlinks in /system/indexes/, and moving the system libraries there. I wrote a rationale in syllable/system/doc/ChangeLog in CVS.
Back to top
View user's profile Send private message Visit poster's website
neundorf



Joined: 13 Nov 2007
Posts: 13

PostPosted: Thu Nov 15, 2007 12:32 am    Post subject: what's wrong here ? Reply with quote

Now when linking, I get:
g++ -fPIC <object files....> -o foo -Wl,-Bstatic -lmylib1 -lmylib2 -Wl,-Bdynamic -ldl -Wl,-Bstatic -lncurses
/usr/indexes/lib/libc.a (init-first.o): multiple definition of '__libc_enable_secure'
/usr/indexes/lib/libc.a (libc-start.o): first defined here

Any idea what is wrong here ?

Thanks again
Alex
Back to top
View user's profile Send private message Send e-mail
Vanders
The Knights of Syllable


Joined: 14 Sep 2007
Posts: 849

PostPosted: Thu Nov 15, 2007 1:42 am    Post subject: Re: what's wrong here ? Reply with quote

[quote="neundorf"]
Any idea what is wrong here ?
[/quote]

Yes, it's a known bug in the static libc that you've reminded me of.
Back to top
View user's profile Send private message Send e-mail
neundorf



Joined: 13 Nov 2007
Posts: 13

PostPosted: Sun Nov 18, 2007 6:55 pm    Post subject: now the exit code... Reply with quote

Is there anything special about handling of exitcode under Syllable ?
Somehow the exit code of my app always seems to be 0 when checked using WEXITSTATUS(status), although I exit with an error code from main().

Any ideas ?

Alex
Back to top
View user's profile Send private message Send e-mail
neundorf



Joined: 13 Nov 2007
Posts: 13

PostPosted: Sun Nov 18, 2007 6:57 pm    Post subject: exit code... Reply with quote

I forgot to mention, I got the status using waitpid(), this always seems to return 0 as exit code.

Alex
Back to top
View user's profile Send private message Send e-mail
Vanders
The Knights of Syllable


Joined: 14 Sep 2007
Posts: 849

PostPosted: Mon Nov 19, 2007 5:21 am    Post subject: Reply with quote

It's possible it is a bug; the implementation should be the same as POSIX. Can you provide a small test case that reproduces the problem?
Back to top
View user's profile Send private message Send e-mail
neundorf



Joined: 13 Nov 2007
Posts: 13

PostPosted: Mon Nov 19, 2007 11:25 am    Post subject: Missing RPATH ? Reply with quote

Ok, I was on the wrong track. The process really doesn't start, but if I start it at the prompt it just silently does nothing, no error message or something like this.
I guess the reason is that it can't find a shared library, which should be found via RPATH.
Is RPATH supported ?
This is how the executable was linked:

gcc -fPIC main.o -o test -L/home/alex/src/build/lib -lfoo -Wl,-rpath,/home/alex/src/build/lib

libfoo.so exists in home/alex/src/build/lib/, but it seems the executable doesn't run (I see know output), but the loader doesn't complain about missing libraries.

How can I find out more ?

Alex
Back to top
View user's profile Send private message Send e-mail
Kaj
The Knights of Syllable


Joined: 14 Sep 2007
Posts: 2207
Location: Friesland

PostPosted: Mon Nov 19, 2007 11:28 am    Post subject: Reply with quote

What does /var/log/kernel say?
Back to top
View user's profile Send private message Visit poster's website
neundorf



Joined: 13 Nov 2007
Posts: 13

PostPosted: Mon Nov 19, 2007 11:49 am    Post subject: Reply with quote

Thanks for the hint.

WARNING: open_library_file() failed to find libfoo.so in search path
Error: Failed to open libfoo.so
ERROR: execve(./lib/foobar) failed. Too late to recover, will exit.

So where does syllable search for shared libs ?
Does it support a compiled-in RPATH ? Does it look in the directory of the executable ? Does it support PATH, LD_LIBRARY_PATH or something similar ?

Alex
Back to top
View user's profile Send private message Send e-mail
Kaj
The Knights of Syllable


Joined: 14 Sep 2007
Posts: 2207
Location: Friesland

PostPosted: Mon Nov 19, 2007 12:02 pm    Post subject: Reply with quote

At run-time, libraries are searched in $DLL_PATH. At link-time, they're searched through $LIBRARY_PATH.
Back to top
View user's profile Send private message Visit poster's website
neundorf



Joined: 13 Nov 2007
Posts: 13

PostPosted: Mon Nov 19, 2007 12:30 pm    Post subject: Reply with quote

So the only way to add search paths is the environment variable DLL_PATH ?
Hmm, that's not really ideal :-/
No way to compile some path into the executable (like RPATH/RUNPATH on UNIX or install_name_dir on OSX) ?
And it also doesn't look in the current directory as under Windows ?

Alex
Back to top
View user's profile Send private message Send e-mail
Kaj
The Knights of Syllable


Joined: 14 Sep 2007
Posts: 2207
Location: Friesland

PostPosted: Mon Nov 19, 2007 12:43 pm    Post subject: Reply with quote

Yes it is. Smile It's very flexible. I constantly have to fight hardcoded paths on Linux when building Syllable Server. Syllable Desktop is a lot easier to handle.

You can search the current directory if it's in DLL_PATH. But in fact, the pattern implemented in Syllable is that it searches in a "lib" subdirectory relative to the executable.

As far as I know, RPath is supported, but you should really avoid using fixed paths. Most software can be ported without fiddling with paths. The use of the search paths should be encapsulated by the system and the toolchain, and indeed, most software doesn't need to know. If your software does require such fiddling, you should think very hard if not something is wrong with it.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Syllable Forum Index -> Syllable Desktop All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group