Using the getopt_pp library
Oct 19, 2009 at 8:43pm UTC
I've been trying to use the c++ version of "getopt" named "getopt_pp" in a homework assignment. After wrestling with my own code and searching the documentation for examples I tried this basic hello world code taken directly form the manual:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
#include "optLib\getopt_pp.h"
using namespace GetOpt;
using namespace std;
int main(int argc, char * argv[])
{
string who;
GetOpt_pp ops(argc, argv);
ops >> Option('n' , "name" , who, "world" );
cout << "Hello " << who << "!" << endl;
return 0;
}
after trying to compile it with the program Code::Blocks I get this build message:
1 2 3 4
obj\Debug\main.o||In function `main':|
C:\CStephan\CPTXTparser2\test\main.cpp|11|undefined reference to `GetOpt::GetOpt_pp::GetOpt_pp(int, char**)' |
C:\CStephan\CPTXTparser2\test\main.cpp|13|undefined reference to `GetOpt::GetOpt_pp::operator >>(GetOpt::_Option const &)'|
||=== Build finished: 2 errors, 0 warnings ===|
I am totally at a loss, it's the most basic example form the documentation but I can't get it to compile. Am I doing something wrong here?
Oct 19, 2009 at 9:43pm UTC
The functions/classes are implemented in some library that you need to link against.
(Sorry, don't know which OTOMH)
Oct 20, 2009 at 9:09am UTC
Thx for the reply, found a standalone header file called getopt_pp_standalone.h and it works fine now :)
Last edited on Oct 20, 2009 at 9:09am UTC
Topic archived. No new replies allowed.