difference between "g++ -pthread" and "g++ -lpthread"

Message ID 516AC83D.4060401@flensrocker.de
State New
Headers

Commit Message

L. Hanisch April 14, 2013, 3:16 p.m. UTC
  Hi,

 I'm hunting some race condition in my plugins which produce a segfault in libc or libavahi (still searching the right
packages with debug symbols, race condition may be related to having to dbus-mainloops in dbus2vdr and avahi4vdr, but I
don't know yet).
 While investigating this I found something about the option "-pthread" of g++.

 According to g++'s manpage this will set the right options for the preprocessor and compiler so the program can use the
pthreads lib. Especially it will set -D_REENTRANT and -lpthread etc.

 vdr seems only to use -lpthread and no other pthread-specific options.

 I'm not an expert on this topic, so I would like to know if someone can shed some light on this.
 Makefile may than be patched with:

==========

 Recompiled vdr and plugins do run as before (haven't solved my segfault).

 What do you think?

Lars.
  

Patch

==========
--- a/Makefile
+++ b/Makefile
@@ -14,12 +14,12 @@ 
 CFLAGS   ?= -g -O3 -Wall

 CXX      ?= g++
-CXXFLAGS ?= -g -O3 -Wall -Werror=overloaded-virtual -Wno-parentheses
+CXXFLAGS ?= -g -O3 -Wall -Werror=overloaded-virtual -Wno-parentheses -pthread

 CDEFINES  = -D_GNU_SOURCE
 CDEFINES += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE

-LIBS      = -ljpeg -lpthread -ldl -lcap -lrt $(shell pkg-config --libs freetype2 fontconfig)
+LIBS      = -ljpeg -ldl -lcap -lrt $(shell pkg-config --libs freetype2 fontconfig)
 INCLUDES ?= $(shell pkg-config --cflags freetype2 fontconfig)

 # Directories: