linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Glynn Clements <glynn@gclements.plus.com>
To: "Huber, George K RDECOM CERDEC STCD SRI" <George.K.Huber@us.army.mil>
Cc: linux-c-programming@vger.kernel.org
Subject: RE: Multithreading with C++ - solved
Date: Sat, 9 Apr 2005 00:04:27 +0100	[thread overview]
Message-ID: <16983.3579.943387.918959@gargle.gargle.HOWL> (raw)
In-Reply-To: <D2AA47A6FB2C1A48AF0526440C0F245CAA367B@monm207.nae.ds.army.mil>


Huber, George K RDECOM CERDEC STCD SRI wrote:

> Thanks for all of the suggestions. Actually, Eric hit the nail on
> the head - I was forgetting to link to libpthread. Knew I had to,
> remember thinking that I need to change my makefile and add
> libpthread to the list of libraries that I was linking to. Would
> have bet money that I did this. Oh well....
> 
> Now this bring up an interesting question - how can a program using
> pthread compile cleanly when it is not linked to libpthread? I would
> expect unresolved externals on all pthread functions?

Maybe you were linking against another library which had libpthread as
a dependency; that would cause it to be linked in.

However, while that will prevent unresolved symbols, it won't
generally be sufficient for the resulting program to execute
correctly.

The reason is that libpthread overrides a number of libc functions.

If you explicitly link against libpthread, everything which uses those
functions will use the libpthread versions; however, if you rely upon
libpthread being linked implicitly, some code will use the libpthread
versions while other code will use the libc versions. This tends to
cause crashes.

-- 
Glynn Clements <glynn@gclements.plus.com>

      reply	other threads:[~2005-04-08 23:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-08 14:04 Multithreading with C++ - solved Huber, George K RDECOM CERDEC STCD SRI
2005-04-08 23:04 ` Glynn Clements [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=16983.3579.943387.918959@gargle.gargle.HOWL \
    --to=glynn@gclements.plus.com \
    --cc=George.K.Huber@us.army.mil \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).