|
Boost Users : |
Subject: [Boost-users] [thread] - install - libraries not referencing?
From: floobit (floobit_at_[hidden])
Date: 2011-12-07 12:39:17
I apologize if this question is asked frequently by noobs. Essentially,
the boost functions are not recognized. I installed the prebuilt boost
package on ubuntu (ostensibly 1.43), and wonder if it's working correctly.
I am working through the threading chapter from *Introduction to the C++
Boost Libraries Volume I Foundations,* and replicated their first
example:
#include <boost/thread.hpp>
#include<iostream>
using namespace std;
using namespace boost;
using namespace boost::this_thread;
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;
}
using
g++ boosttest1.c -o boosttest1
the compiler throws errors to each reference of a boost function (I have
removed the names of temp files referenced by the compiler):
undefined reference to `boost::this_thread::yield()'
undefined reference to `boost::thread::~thread()'
In function
`boost::detail::thread_data_base::thread_data_base()': undefined reference
to `vtable for boost::detail::thread_data_base'
In function `boost::thread::thread<void (*)()>(void (*)(),
boost::disable_if<boost::is_convertible<void (*&)(),
boost::detail::thread_move_t<void (*)()> >,
boost::thread::dummy*>::type)': undefined reference to
`boost::thread::start_thread()'
etc. Please respond if the remainder of the messages are cogent.
If I comment out both lines with boost, the compile works perfectly, and if
I comment out only the second, I receive:
In function `fxn1()':
boostthreadtest.c:(.text+0x43): undefined reference to
`boost::this_thread::yield()'
collect2: ld returned 1 exit status
How do I reference the libraries correctly? It seems as though the more
detailed thread.hpp files are correctly referenced and present, but are not
being noticed by the compiler.
Thanks for your patience.
floobit
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