Skip to content

Visual Studio 2015 link error in example for ostream output operator of value #139

Open
@zeroxia

Description

Hi,

I build the project using CMake with Visual Studio 2015 Update 3, but the example program has link error.

Error
LNK2019
unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl docopt::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,struct docopt::value const &)" (??6docopt@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AEAV12@AEBUvalue@0@@Z) referenced in function main
docopt_example

I think this is due to the following operator<< overload function is not exported (the example program links to the DLL)

// (In docopt_value.h)
	/// Write out the contents to the ostream
 	std::ostream& operator<<(std::ostream&, value const&);

If I move this function declaration to docopt.h to enable it to use the macro DOCOPT_API, then example program is built and run successfully.

// (In docopt.h, at the end of namespace docopt)
	/// Write out the contents to the ostream
 	DOCOPT_API std::ostream& operator<<(std::ostream&, value const&);

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions