ld: fatal: Symbol referencing errors.

I'm getting an error that I can't seem to resolve when attempting to implement the Boost Program Options code. I'm basically using the example from their website (url below) and it just won't work.

http://www.boost.org/doc/libs/1_44_0/doc/html/program_options/tutorial.html#id2083241

I'm compiling with gcc on a Solaris box.

The error:
 
ld: fatal: Symbol referencing errors. No output written to program


The code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <boost/program_options.hpp>
#include <boost/ref.hpp>
#include <stdexcept>
#include "ParseConfig.h"

/** Parse the command-line parameters using Boost program_options.  The
 *  command-line options are parsed and the configuration options are
 *  set in the parseConfig parameter.
 *
 *  @return true if the program should exit, such as when help or version
 *      information has been displayed, or false if the program should
 *      continue running.
 */
bool parse(int argc, char* argv[], ParseConfig& parseConfig)
{
    namespace po = boost::program_options;

    // Declare the supported options.
    po::options_description desc(
        "Program options");
    desc.add_options()
        ("help,h", "Print this help message and exit.")
        ("version,v", "Print the application version and exit.")
        ("input,i", po::value<std::string>(&(parseConfig.input)),
            "Input file (required).")
        ("output,o", po::value<std::string>(&(parseConfig.output)),
            "Output file (default is STDOUT).");

    po::variables_map vm;
    po::store(po::parse_command_line(argc, argv, desc), vm);
    po::notify(vm);

    if (vm.count("help"))
    {
        std::cout << "Run program" << std::endl << desc << std::endl;
        return true;
    }

    if (vm.count("version"))
    {
        std::cout << argv[0] << ": " << EXEC_VERSION << std::endl;
        return true;
    }

    return false;
}

int main(int argc, char *argv[])
{
	ParseConfig parseConfig;
	int result = 0;

	try
    {
    	/** Parse the command-line to configure input and output files
    	 *  or display program version or help menu.
    	 */
    	if (parse(argc, argv, parseConfig))
    	{
    		return result;
    	}

        result = 0;
    }
    catch (std::exception& ex)
    {
        std::cerr << std::endl << ex.what() << std::endl;
        result = 1;
    }
    catch (...)
    {
        std::cerr << std::endl << " unknown error ***" << std::endl;
        result = 1;
    }

    return result;
}


Any thoughts?

- Rico
You are linking against the library, right? (This library is not a header-only library).
I think so but I'm fairly new to this. I'm using Eclipse and do my linking with Cygwin.

Is there something else I should check for?
Yes, after further investigation I found the linking problem you suspected, jsmith. Thank you very much.

In the makefile I needed to add the following:

1
2
BOOST_LIBS = boost_iostreams boost_system boost_thread boost_program_options
BOOST_LIBS += boost_date_time
Topic archived. No new replies allowed.