* pthread_mutex_init() with gcc-3.4.3 on Tru64 UNIX
@ 2005-07-08 23:44 Albert Chin
2005-07-09 13:17 ` Ishwar Rattan
0 siblings, 1 reply; 10+ messages in thread
From: Albert Chin @ 2005-07-08 23:44 UTC (permalink / raw)
To: gcc-help
$ uname -a
OSF1 [name] V4.0 878 alpha
$ uname -a
OSF1 [name] V5.1 732 alpha
$ cat mutex.c
#include <stdlib.h>
#include <pthread.h>
int
main (void) {
pthread_mutex_t lck;
if (pthread_mutex_init(&lck, 0) != 0)
exit (2);
if (pthread_mutex_lock(&lck) != 0)
exit (3);
if (pthread_mutex_unlock(&lck) != 0)
exit (4);
if (pthread_mutex_destroy(&lck) != 0)
exit (5);
exit (0);
}
$ cc mutex.c
ld:
Unresolved:
__pthread_mutex_init
__pthread_mutex_destroy
__pthread_mutex_lock
__pthread_mutex_unlock
$ cc -pthread mutex.c
$ ls -ld a.out
-rwxrwxr-x 1 china china 20288 Jul 8 18:40 a.out
$ nm a.out | grep pthread_mutex
__pthread_mutex_destroy | 0000000000000000 | U | 0000000000000008
__pthread_mutex_init | 0000000000000000 | U | 0000000000000008
__pthread_mutex_lock | 0000000000000000 | U | 0000000000000008
__pthread_mutex_unlock | 0000000000000000 | U | 0000000000000008
$ /opt/TWWfsw/gcc343/bin/gcc -v
Reading specs from
/opt/TWWfsw/gcc343/lib/gcc/alpha-dec-osf5.1/3.4.3/specs
Configured with: /opt/build/gcc-3.4.3/configure --enable-nls
--with-included-gettext --enable-shared --enable-threads
--host=alpha-dec-osf5.1 --with-local-prefix=/opt/TWWfsw/gcc343
--prefix=/opt/TWWfsw/gcc343
Thread model: posix
gcc version 3.4.3 (TWW)
$ /opt/TWWfsw/gcc343/bin/gcc mutex.c
$ ls -ld a.out
-rwxrwxr-x 1 china china 41072 Jul 8 18:40 a.out
$ nm a.out | grep pthread_mutex
__pthread_mutex_destroy | 0000004831844816 | T | 0000000000000008
__pthread_mutex_init | 0000004831844800 | T | 0000000000000008
__pthread_mutex_lock | 0000004831844640 | T | 0000000000000008
__pthread_mutex_trylock | 0000004831844656 | T | 0000000000000008
__pthread_mutex_unlock | 0000004831844672 | T | 0000000000000008
$ /opt/TWWfsw/gcc332/bin/gcc -v
Reading specs from
/opt/TWWfsw/gcc332/lib/gcc-lib/alphaev67-dec-osf5.1/3.3.2/specs
Configured with: /opt/build/gcc-3.3.2/configure --enable-nls
--with-included-gettext --enable-shared --enable-threads
--with-local-prefix=/opt/TWWfsw/gcc332 --prefix=/opt/TWWfsw/gcc332
Thread model: single
gcc version 3.3.2 (TWW)
$ /opt/TWWfsw/gcc332/bin/gcc mutex.c
__pthread_mutex_init
__pthread_mutex_lock
__pthread_mutex_unlock
__pthread_mutex_destroy
collect2: ld returned 1 exit status
So, why does /opt/TWWfsw/gcc343/bin/gcc resolve the pthread_mutex_*
symbols and cc does not? Should the GCC behavior mirror the cc
behavior?
--
albert chin (china@thewrittenword.com)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: pthread_mutex_init() with gcc-3.4.3 on Tru64 UNIX
2005-07-08 23:44 pthread_mutex_init() with gcc-3.4.3 on Tru64 UNIX Albert Chin
@ 2005-07-09 13:17 ` Ishwar Rattan
2005-07-09 15:03 ` Albert Chin
0 siblings, 1 reply; 10+ messages in thread
From: Ishwar Rattan @ 2005-07-09 13:17 UTC (permalink / raw)
To: gcc-help
On Fri, 8 Jul 2005, Albert Chin wrote:
> $ uname -a
> OSF1 [name] V4.0 878 alpha
> $ uname -a
> OSF1 [name] V5.1 732 alpha
>
> $ cat mutex.c
> #include <stdlib.h>
> #include <pthread.h>
>
> int
> main (void) {
> pthread_mutex_t lck;
>
> if (pthread_mutex_init(&lck, 0) != 0)
> exit (2);
> if (pthread_mutex_lock(&lck) != 0)
> exit (3);
> if (pthread_mutex_unlock(&lck) != 0)
> exit (4);
> if (pthread_mutex_destroy(&lck) != 0)
> exit (5);
>
> exit (0);
> }
>
> $ cc mutex.c
Try cc mutex.c -lpthread
-ishwar
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: pthread_mutex_init() with gcc-3.4.3 on Tru64 UNIX
2005-07-09 13:17 ` Ishwar Rattan
@ 2005-07-09 15:03 ` Albert Chin
2005-07-09 17:27 ` Ishwar Rattan
0 siblings, 1 reply; 10+ messages in thread
From: Albert Chin @ 2005-07-09 15:03 UTC (permalink / raw)
To: gcc-help
On Sat, Jul 09, 2005 at 09:15:18AM -0400, Ishwar Rattan wrote:
>
>
> On Fri, 8 Jul 2005, Albert Chin wrote:
>
> > $ uname -a
> > OSF1 [name] V4.0 878 alpha
> > $ uname -a
> > OSF1 [name] V5.1 732 alpha
> >
> > $ cat mutex.c
> > #include <stdlib.h>
> > #include <pthread.h>
> >
> > int
> > main (void) {
> > pthread_mutex_t lck;
> >
> > if (pthread_mutex_init(&lck, 0) != 0)
> > exit (2);
> > if (pthread_mutex_lock(&lck) != 0)
> > exit (3);
> > if (pthread_mutex_unlock(&lck) != 0)
> > exit (4);
> > if (pthread_mutex_destroy(&lck) != 0)
> > exit (5);
> >
> > exit (0);
> > }
> >
> > $ cc mutex.c
>
> Try cc mutex.c -lpthread
I know. I'm curious why:
$ /opt/TWWfsw/gcc343/bin/gcc mutex.c
succeeds. I'd expect it to fail, just as 'cc mutex.c' failed.
--
albert chin (china@thewrittenword.com)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: pthread_mutex_init() with gcc-3.4.3 on Tru64 UNIX
2005-07-09 15:03 ` Albert Chin
@ 2005-07-09 17:27 ` Ishwar Rattan
2005-07-11 10:55 ` Albert Chin
0 siblings, 1 reply; 10+ messages in thread
From: Ishwar Rattan @ 2005-07-09 17:27 UTC (permalink / raw)
To: gcc-help
On Sat, 9 Jul 2005, Albert Chin wrote:
> I know. I'm curious why:
> $ /opt/TWWfsw/gcc343/bin/gcc mutex.c
> succeeds. I'd expect it to fail, just as 'cc mutex.c' failed.
Try /opt/TWWfsw/gcc343/bin/gcc -v | grep thread
-ishwar
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: pthread_mutex_init() with gcc-3.4.3 on Tru64 UNIX
2005-07-09 17:27 ` Ishwar Rattan
@ 2005-07-11 10:55 ` Albert Chin
2005-07-11 11:24 ` Eljay Love-Jensen
0 siblings, 1 reply; 10+ messages in thread
From: Albert Chin @ 2005-07-11 10:55 UTC (permalink / raw)
To: gcc-help
On Sat, Jul 09, 2005 at 01:24:58PM -0400, Ishwar Rattan wrote:
>
> On Sat, 9 Jul 2005, Albert Chin wrote:
>
> > I know. I'm curious why:
> > $ /opt/TWWfsw/gcc343/bin/gcc mutex.c
> > succeeds. I'd expect it to fail, just as 'cc mutex.c' failed.
> Try /opt/TWWfsw/gcc343/bin/gcc -v | grep thread
Reading specs from
/opt/TWWfsw/gcc343/lib/gcc/alpha-dec-osf5.1/3.4.3/specs
Configured with: /opt/build/gcc-3.4.3/configure --enable-nls
--with-included-gettext --enable-shared --enable-threads
--host=alpha-dec-osf5.1 --with-local-prefix=/opt/TWWfsw/gcc343
--prefix=/opt/TWWfsw/gcc343
Thread model: posix
gcc version 3.4.3 (TWW)
Does it succeed because I compiled with --enable-threads?
--
albert chin (china@thewrittenword.com)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: pthread_mutex_init() with gcc-3.4.3 on Tru64 UNIX
2005-07-11 10:55 ` Albert Chin
@ 2005-07-11 11:24 ` Eljay Love-Jensen
2005-07-11 14:22 ` Albert Chin
0 siblings, 1 reply; 10+ messages in thread
From: Eljay Love-Jensen @ 2005-07-11 11:24 UTC (permalink / raw)
To: gcc-help
Hi Ishwar,
Use 'gcc -v' while compiling, and 'ldd a.out' to see loader dynamic libraries.
The '-pthreads' does several things. (The '-v' will help clarify what those things are.)
--Eljay
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: pthread_mutex_init() with gcc-3.4.3 on Tru64 UNIX
2005-07-11 11:24 ` Eljay Love-Jensen
@ 2005-07-11 14:22 ` Albert Chin
2005-07-11 15:13 ` Ishwar Rattan
0 siblings, 1 reply; 10+ messages in thread
From: Albert Chin @ 2005-07-11 14:22 UTC (permalink / raw)
To: gcc-help
On Mon, Jul 11, 2005 at 06:26:14AM -0500, Eljay Love-Jensen wrote:
> Use 'gcc -v' while compiling, and 'ldd a.out' to see loader dynamic
> libraries.
The previous email gives the /opt/TWWfsw/gcc343/bin/gcc -v output.
'ldd a.out' shows a dependency with libc only.
> The '-pthreads' does several things. (The '-v' will help clarify
> what those things are.)
I'm not building with -pthreads.
--
albert chin (china@thewrittenword.com)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: pthread_mutex_init() with gcc-3.4.3 on Tru64 UNIX
2005-07-11 14:22 ` Albert Chin
@ 2005-07-11 15:13 ` Ishwar Rattan
2005-07-11 15:25 ` Albert Chin
0 siblings, 1 reply; 10+ messages in thread
From: Ishwar Rattan @ 2005-07-11 15:13 UTC (permalink / raw)
To: gcc-help
On Mon, 11 Jul 2005, Albert Chin wrote:
> On Mon, Jul 11, 2005 at 06:26:14AM -0500, Eljay Love-Jensen wrote:
> > Use 'gcc -v' while compiling, and 'ldd a.out' to see loader dynamic
> > libraries.
>
> The previous email gives the /opt/TWWfsw/gcc343/bin/gcc -v output.
> 'ldd a.out' shows a dependency with libc only.
I first thought that cc linked to /opt/TWWfsw/gcc343/bin/gcc are same.
If /opt/TWWfsw/gcc343/bin/gcc was not built locally then it might have
posix thread library compiled into it?
-ishwar
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: pthread_mutex_init() with gcc-3.4.3 on Tru64 UNIX
2005-07-11 15:13 ` Ishwar Rattan
@ 2005-07-11 15:25 ` Albert Chin
2005-07-11 15:54 ` Ishwar Rattan
0 siblings, 1 reply; 10+ messages in thread
From: Albert Chin @ 2005-07-11 15:25 UTC (permalink / raw)
To: gcc-help
On Mon, Jul 11, 2005 at 11:11:30AM -0400, Ishwar Rattan wrote:
> On Mon, 11 Jul 2005, Albert Chin wrote:
>
> > On Mon, Jul 11, 2005 at 06:26:14AM -0500, Eljay Love-Jensen wrote:
> > > Use 'gcc -v' while compiling, and 'ldd a.out' to see loader dynamic
> > > libraries.
> >
> > The previous email gives the /opt/TWWfsw/gcc343/bin/gcc -v output.
> > 'ldd a.out' shows a dependency with libc only.
>
> I first thought that cc linked to /opt/TWWfsw/gcc343/bin/gcc are same.
> If /opt/TWWfsw/gcc343/bin/gcc was not built locally then it might have
> posix thread library compiled into it?
cc is the compiler from Compaq. /opt/TWWfsw/gcc343/bin/gcc was built
locally. It does not have the posix thread library compiled into it.
--
albert chin (china@thewrittenword.com)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: pthread_mutex_init() with gcc-3.4.3 on Tru64 UNIX
2005-07-11 15:25 ` Albert Chin
@ 2005-07-11 15:54 ` Ishwar Rattan
0 siblings, 0 replies; 10+ messages in thread
From: Ishwar Rattan @ 2005-07-11 15:54 UTC (permalink / raw)
To: gcc-help
On Mon, 11 Jul 2005, Albert Chin wrote:
> On Mon, Jul 11, 2005 at 11:11:30AM -0400, Ishwar Rattan wrote:
> > I first thought that cc linked to /opt/TWWfsw/gcc343/bin/gcc are same.
> > If /opt/TWWfsw/gcc343/bin/gcc was not built locally then it might have
> > posix thread library compiled into it?
>
> cc is the compiler from Compaq. /opt/TWWfsw/gcc343/bin/gcc was built
> locally. It does not have the posix thread library compiled into it.
This is the last one: find the switch for gcc for not using built-in
functions for linking and tell it to do so..
-ishwar
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2005-07-11 15:54 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-08 23:44 pthread_mutex_init() with gcc-3.4.3 on Tru64 UNIX Albert Chin
2005-07-09 13:17 ` Ishwar Rattan
2005-07-09 15:03 ` Albert Chin
2005-07-09 17:27 ` Ishwar Rattan
2005-07-11 10:55 ` Albert Chin
2005-07-11 11:24 ` Eljay Love-Jensen
2005-07-11 14:22 ` Albert Chin
2005-07-11 15:13 ` Ishwar Rattan
2005-07-11 15:25 ` Albert Chin
2005-07-11 15:54 ` Ishwar Rattan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).