Boost logo

Boost :

Subject: [boost] [program_options] -d directory is falling into positional input-files 1_62_0
From: Roger Martin (roger_at_[hidden])
Date: 2016-10-14 14:22:50


Pulled this from a larger application to isolate to the problem: -d
./tmp or -d "./tmp" doesn't go to directory string but is with the

#include <stdlib.h>
#include <iostream>
#include <exception>
#include <string>
#include <cstring>
#include <memory>
#include <fstream>

#include "boost/program_options.hpp"

int main(int argc, char** argv) {
     try {
         boost::program_options::positional_options_description p;
         p.add("input-file", -1);
         std::string directory = "./";
         boost::program_options::options_description visible("Allowed
boost::program_options::value<std::vector<std::string>>(), "input files
can be *.xml, *.pdb, *.mol2, *.mtz, *.cif, *.csv, and *.sdf. Csv and sdf
formats are for NMR calculations. csv lists the atoms for which the
shifts will be computed. 1st line containts the Header:
\"Chain\",\"Residue ID\",\"Sequence\",\"Atom Name\",\"Unbound
ppm\",\"Bound ppm\". Then atoms may be listed i.e
\"A\",\"MET\",231,\"CE\",10.30,10.50. sdf file contains the ligands for
a CSP calculation. ")
"Directory for publishing output.")
         boost::program_options::options_description all("Allowed options");

         boost::program_options::variables_map vm;
argv).options(all).positional(p).run(), vm);
         std::vector<std::string> fileList = vm["input-file"].as <
std::vector < std::string >> ();
                 for (unsigned int fileListIndex = 0; fileListIndex <
fileList.size(); fileListIndex++) {
                     std::cout<<" "<<fileList[fileListIndex]<<"

     } catch (std::exception& e) {
         std::cout << e.what() << std::endl;
     return 0;

Built with g++ 4.9.0 on Linux #1 SMP Wed Sep 23 03:02:55 UTC
2015 x86_64 x86_64 x86_64 GNU/Linux

g++ -fPIE -std=c++11 -I${BOOST_HOME}/include
-Wl,--allow-multiple-definition -MT main.o -MMD -MP -O3 -c -o main.o
g++ -pie -Wl,--allow-multiple-definition -o main main.o
-L${BOOST_HOME}/lib -lboost_program_options -lc -lm -lpthread -lz
-lstdc++ -ldl -lrt

And run as

./main 2-aminoethanol.pdb -d ./tmp

which results in


This code had been working with 1_57_0. Some change in the API I need
to adjust for?

Boost list run by bdawes at, gregod at, cpdaniel at, john at