Problem with boost::program_options

Hi, I am a newbie to Boost. I am writing a sample code using the Boost libaries and am getting the following error during linking. *Command Line Usage * * **g++ -I /usr/include/boost/ example.cpp -o example.o* *Code* *#include <boost/lambda/lambda.hpp> #include <iostream> #include <iterator> #include <algorithm> #include <boost/program_options/options_description.hpp> #include <boost/program_options/positional_options.hpp> #include <boost/program_options/variables_map.hpp> #include <boost/program_options/parsers.hpp> #include <cstdlib> #include <iostream> #include <iomanip> #include <map> #include <string> using namespace boost::program_options; //namespace po = boost::program_options; int main() { using namespace boost::lambda; // using namespace boost::program_options; typedef std::istream_iterator<int> in; std::for_each( in(std::cin), in(), std::cout << (_1 * 3) << " " ); option_description opts; } * *Error Message* /tmp/ccO0HWa7.o(.text+0xb0): In function `main': example.cpp: undefined reference to `boost::program_options::option_description::option_description()' /tmp/ccO0HWa7.o(.text+0xbf):example.cpp: undefined reference to `boost::program_options::option_description::~option_description()' collect2: ld returned 1 exit status $LD_LIBRARY_PATH has the following value set. /home/suhas/boost/lib:/usr/lib:/usr/include/boost/ I am stuck, any help will be really appreciated. Thanks in advance. Regards, Eswar

On Dec 30, 2007 9:11 AM, Eswar K <kja.eswar@gmail.com> wrote:
Hi,
I am a newbie to Boost. I am writing a sample code using the Boost libaries and am getting the following error during linking.
Command Line Usage
g++ -I /usr/include/boost/ example.cpp -o example.o
Shouldn't this be something like g++ -L /usr/include/boost/ -lboost_program_options example.cpp -o example.o [substitute the name of the program options library on your system for boost_program_options] Chris

Thanks, Chris. It worked. Regards, Eswar On Dec 31, 2007 4:20 AM, Chris Weed <chrisweed@gmail.com> wrote:
Hi,
I am a newbie to Boost. I am writing a sample code using the Boost
On Dec 30, 2007 9:11 AM, Eswar K <kja.eswar@gmail.com> wrote: libaries
and am getting the following error during linking.
Command Line Usage
g++ -I /usr/include/boost/ example.cpp -o example.o
Shouldn't this be something like g++ -L /usr/include/boost/ -lboost_program_options example.cpp -o example.o
[substitute the name of the program options library on your system for boost_program_options]
Chris _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Try adding -lboost_program_options to the g++ command line options. /Mikko Eswar K wrote:
Hi,
I am a newbie to Boost. I am writing a sample code using the Boost libaries and am getting the following error during linking.
_*Command Line Usage *_ * */g++ -I /usr/include/boost/ example.cpp -o example.o/
_*Code*_
/#include <boost/lambda/lambda.hpp> #include <iostream> #include <iterator> #include <algorithm> #include <boost/program_options/options_description.hpp> #include <boost/program_options/positional_options.hpp> #include <boost/program_options/variables_map.hpp> #include <boost/program_options/parsers.hpp>
#include <cstdlib> #include <iostream> #include <iomanip> #include <map> #include <string>
using namespace boost::program_options; //namespace po = boost::program_options;
int main() { using namespace boost::lambda; // using namespace boost::program_options; typedef std::istream_iterator<int> in;
std::for_each( in(std::cin), in(), std::cout << (_1 * 3) << " " ); option_description opts; } / _*Error Message*_
/tmp/ccO0HWa7.o(.text+0xb0): In function `main': example.cpp: undefined reference to `boost::program_options::option_description::option_description()' /tmp/ccO0HWa7.o(.text+0xbf): example.cpp: undefined reference to `boost::program_options::option_description::~option_description()' collect2: ld returned 1 exit status
$LD_LIBRARY_PATH has the following value set. /home/suhas/boost/lib:/usr/lib:/usr/include/boost/
I am stuck, any help will be really appreciated.
Thanks in advance.
Regards, Eswar
------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Chris Weed
-
Eswar K
-
Mikko Vainio