Try
g++ boosttest1.c -o boosttest1 -lboost_thread
If you get more undefined references, try appending
-lboost_system and/or -lpthread.
Thanks. The first extra argument solved the compilation issue, but I now get unexpected output (adding the suggested extra arguments does not help this). In particular, it seems that the second thread is not starting up, as I only get output from the main thread. The book says I should get a random interleaving of the lines outputted by each thread. My code:
void fxn1(){
for (int i=0; i<10; ++i){
cout << i << ") Do something in parallel with main method." << endl;
boost::this_thread::yield();
}}
int main(){
boost::thread t(&fxn1);
for (int i=0;i<10; i++){
cout << i << ". Do something in main method." << endl;
}
return 0;
}
Thanks so much.