Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

On Solaris:

basename.c

#include <stdio.h>
#include <libgen.h>

int main(int argc, char* argv[])
{
    int len = strlen(argv[0]);
    char *bsname = basename(argv[0]);
    printf("%s\n", bsname);
    printf("%d\n", len);
    return 0;
}
cc basename.c
ldd a.out

output:

libc.so.1 => /lib/libc.so.1
libm.so.1
......

On Linux:

basename.c

#include <stdio.h>
#include <libgen.h>

int main(int argc, char* argv[])
{
    int len = strlen(argv[0]);
    char *bsname = basename(argv[0]);
    printf("%s\n", bsname);
    printf("%d\n", len);
    return 0;
}
gcc basename.c
ldd a.out

output:

libc.so.6 => /lib/libc.so.6 
......

Is Solaris libc is based on GNU libc? Is libc.so.1 on Solaris the same as libc.so.6 on Linux?

share|improve this question

3 Answers 3

up vote 15 down vote accepted

The Solaris C library is not based on the GNU C Library. They both implement the C standard and POSIX interfaces and some other standards, but they don't share a common heritage beyond that.

Solaris libc.so.1 traces its history to the AT&T System V C library.

GNU libc.so.6 is based on glibc 2.0 or greater. The earlier versions (e.g. libc.so.5) of the Linux C library were a fork of an earlier glibc 1.x release.

You will find that there are some difference between the two libraries. For example, Solaris libc contains some string operations that glibc does not, strlcpy() being the most obvious to me.

share|improve this answer
2  
Btw, there is libbsd to use library functions that originate from BSD like strlcpy() under Linux or other systems that don't have a strong BSD influence. –  maxschlepzig Mar 21 '12 at 7:08

Solaris libc is not at all based on GNU libc but they provide similar interfaces.

share|improve this answer

Why? Because they both call themselves libc?

No.

They're both called libc because GNU libc tries to be a compatible replacement for libc on proprietary Unices. This is the reason the LGPL license was created.

A quick web search shows some of the source code for Solaris libc. Picking a file at random, the copyright messages there say

/*  Copyright (c) 1988 AT&T */
/*    All Rights Reserved   */


/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

so it should be pretty obvious the code doesn't come from GNU.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.