V
vichy.kuo
Dear all:
I try to write a simple program and use ld to link it as static.
But I get some link error as I attached at the end of my mail.
In the beginning, I thought maybe there is some libs I need to
include.
But the message says there is multiple definitions?
If I drop '-lc' or '-lpthread', ld will say it need any one of them.
Did I miss some options passing to ld?
Sincerely Yours,
vichy
#include<stdio.h>
#include<pthread.h>
#include<stdlib.h>
void *pmtthread_func(void* arg) {
printf("enter pthread\n");
}
int main(void)
{
unsigned char* ptmp;
pthread_t pmtthread;
pthread_create(&pmtthread, NULL, pmtthread_func, NULL);
getchar();
ptmp = malloc(sizeof(unsigned char)*128);
ptmp[0]=100;
ptmp[1]=1;
printf("ptmp[0] = %d\n",ptmp[0]);
pthread_join(pmtthread, NULL);
return 0;
}
# gcc -c test.c
# ls
a.out mips test.c test_mips test.o
# ld -static -o test test.o -lc -lpthread
/usr/lib/libpthread.a(lowlevellock.o): In function
`__lll_lock_wait_private':
(.text+0x0): multiple definition of `__lll_lock_wait_private'
/usr/lib/libc.a(libc-lowlevellock.o).text+0x0): first defined here
/usr/lib/libpthread.a(lowlevellock.o): In function
`__lll_unlock_wake_private':
(.text+0x100): multiple definition of `__lll_unlock_wake_private'
/usr/lib/libc.a(libc-lowlevellock.o).text+0x30): first defined here
ld: warning: cannot find entry symbol _start; defaulting to
00000000080480c0
/usr/lib/libc.a(ioputs.o): In function `puts':
(.text+0x16d): undefined reference to `_Unwind_Resume'
........
I try to write a simple program and use ld to link it as static.
But I get some link error as I attached at the end of my mail.
In the beginning, I thought maybe there is some libs I need to
include.
But the message says there is multiple definitions?
If I drop '-lc' or '-lpthread', ld will say it need any one of them.
Did I miss some options passing to ld?
Sincerely Yours,
vichy
#include<stdio.h>
#include<pthread.h>
#include<stdlib.h>
void *pmtthread_func(void* arg) {
printf("enter pthread\n");
}
int main(void)
{
unsigned char* ptmp;
pthread_t pmtthread;
pthread_create(&pmtthread, NULL, pmtthread_func, NULL);
getchar();
ptmp = malloc(sizeof(unsigned char)*128);
ptmp[0]=100;
ptmp[1]=1;
printf("ptmp[0] = %d\n",ptmp[0]);
pthread_join(pmtthread, NULL);
return 0;
}
# gcc -c test.c
# ls
a.out mips test.c test_mips test.o
# ld -static -o test test.o -lc -lpthread
/usr/lib/libpthread.a(lowlevellock.o): In function
`__lll_lock_wait_private':
(.text+0x0): multiple definition of `__lll_lock_wait_private'
/usr/lib/libc.a(libc-lowlevellock.o).text+0x0): first defined here
/usr/lib/libpthread.a(lowlevellock.o): In function
`__lll_unlock_wake_private':
(.text+0x100): multiple definition of `__lll_unlock_wake_private'
/usr/lib/libc.a(libc-lowlevellock.o).text+0x30): first defined here
ld: warning: cannot find entry symbol _start; defaulting to
00000000080480c0
/usr/lib/libc.a(ioputs.o): In function `puts':
(.text+0x16d): undefined reference to `_Unwind_Resume'
........