I am trying to develop a simple program in C++ with the boost library. I develop with Visual Studio 2017 and a remote bash shell of ubuntu to compile and debug.
I installed gdb, gdbserver, all the compiler and the boost library on ubuntu.
Simple programs without boost compile and run without problem from the shell directly as from Visual Studio !
When I compile the following program directly from the ubuntu bash with the following command : g++ test.cpp -std=c++11 -lboost_program_options -o t
It compiles and runs also!
#include <boost/program_options.hpp>
#include <iostream>
using namespace boost::program_options;
int main(int argc, const char *argv[])
{
try
{
options_description desc{ "Options" };
desc.add_options()
("help,h", "Help screen");
variables_map vm;
store(parse_command_line(argc, argv, desc), vm);
notify(vm);
if (vm.count("help"))
std::cout << desc << '\n';
}
catch (const error &ex)
{
std::cerr << ex.what() << '\n';
}
}
But if I put the same code in Visual Studio in a file and try to compile remotely it doesn't work :
1>------ Build started: Project: ACO-PPS, Configuration: Debug x64 ------
1>Validating architecture
1>Validating sources
1>Copying sources remotely to 'localhost'
1>Starting remote build
1>Compiling sources:
1>main.cpp
1>Linking objects
1>/home/marius/projects/ACO-PPS/obj/x64/Debug/main.o : In the function main :
1>/home/marius/projects/ACO-PPS/main.cpp:11 : undefined reference to « boost::program_options::options_description::m_default_line_length »
and so on ...
In the project properties I have included -lboost_program_options
under :
Configuration Properties > C/C++ > All Options > Additional Options
and under :
Configuration Properties > Linker > All Options > Additional Options
What am I doing wrong ?