|
Boost Users : |
From: Raul Huertas (raulh39_at_[hidden])
Date: 2006-01-07 07:15:17
Brian Plummer escribió:
>The following simple program seg faults. (I have boiled it down to the
>bare essentials to product the fault:
>
>
I changed your test program to make compiler happy.
This is my modified version:
=========bug.cc========
#include <boost/thread.hpp>
void MMULT2(void);
void MMULT2CalcMaster(void);
int main(void) {
MMULT2();
}
class MMULT2ThreadClass {
void calculate(void) {}
public :
MMULT2ThreadClass() {}
void operator ()() { calculate(); }
};
void MMULT2CalcMaster(void) {
int numThreads = 2;
boost::thread_group threads;
for (int i = 0; i < numThreads; ++i)
threads.create_thread(MMULT2ThreadClass());
threads.join_all();
}
void MMULT2(void) {
MMULT2CalcMaster();
}
================
(I have changed "void *" to "void" in several places).
It works ok for me.
I've compiled with:
gcc -c -Wall -g \
-D_REENTRANT -D_THREAD_SAFE -D_GNU_SOURCE \
-I/opt/boost_1_33_1/include bug.cc -o _linux.O/bug.o
And I've linked with:
gcc -Wall -g -Ihdrs \
-D_REENTRANT -D_THREAD_SAFE -D_GNU_SOURCE \
-I/opt/boost_1_33_1/include _linux.O/bug.o \
-o ../_linux.O/bug -L/opt/boost_1_33_1/lib \
-Wl,-rpath,/opt/boost_1_33_1/lib \
-lboost_thread-mt-d -lpthread -lstdc++
My gcc is 4.0.2.
Hope this helps.
Raúl.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net