Linux-Bulgaria.ORG
навигация

 

начало

пощенски списък

архив на групата

семинари ...

документи

как да ...

 

 

Предишно писмо Следващо писмо Предишно по тема Следващо по тема По Дата По тема (thread)

Re: lug-bg: LKM compilation


  • Subject: Re: lug-bg: LKM compilation
  • From: alex@xxxxxx (Alexander Atanasov)
  • Date: Sat, 13 Apr 2002 19:19:35 +0300 (EEST)



On Fri, 12 Apr 2002, Dimitar Peikov wrote:

> BTW: Njakoj na Slackware da e podkarval shared library kojato izpolzva
> funkcia 'stat' s libc.so? Ne govorja za compilirane a za trugvane!

ts.c:
#include <sys/stat.h>
#include <unistd.h>

int my_stat(struct stat *s, const char *path)
{
        return stat(path,s);
}

gcc -Wall -fPIC -shared -o libts.so ts.c

tsm.c:
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>

int my_stat(struct stat *s, const char *path);

int main(int argc, char **argv)
{
        struct stat st;
        int rc;

        rc=my_stat(&st,((argc>1)?argv[1]:argv[0]));
        if(!rc)
        {
                printf("size: %lu\n",st.st_size);
        } else {
                        printf("rc=%d errno=%d (%s)\n",rc,errno,strerror(errno));
        }
        return 0;
}

gcc -Wall -o tsm tsm.c -L. -lts

export LD_LIBRARY_PATH=.
./tsm
size: 19629
ls -al tsm
-rwxr-xr-x   1 root     root        19629 Apr 13 19:10 tsm*
./tsm a
rc=-1 errno=2 (No such file or directory)

ldd ./tsm

        libts.so => ./libts.so (0x40016000)
        libc.so.6 => /lib/libc.so.6 (0x40027000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

lrwxrwxrwx   1 root     root           13 Mar 19 02:14 /lib/libc.so.6 ->
libc-2.2.5.so*
gcc --version
egcs-2.91.66

Tova stava li, na slackware e?


-- 
have fun,
alex

===========================================================================
A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers)
http://www.linux-bulgaria.org/ Hosted by Internet Group Ltd. - Stara Zagora




 

наши приятели

 

линукс за българи
http://linux-bg.org

FSA-BG
http://fsa-bg.org

OpenFest
http://openfest.org

FreeBSD BG
http://bg-freebsd.org

KDE-BG
http://kde.fsa-bg.org/

Gnome-BG
http://gnome.cult.bg/

проект OpenFMI
http://openfmi.net

NetField Forum
http://netField.ludost.net/forum/

 

 

Linux-Bulgaria.ORG

Mailing list messages are © Copyright their authors.