Re: [Mingw-w64-public] Difficulty using Boost library with MSYS2/MINGW64

2017-05-30 Thread Norbert Pfeiler
Your setup is fine, and yes you need to specify libraries to resolve your
undefined references.
I’d consider using cmake to avoid having to figure out the necessary
library names yourself:
find_package(Boost REQUIRED COMPONENTS program_options)
target_link_libraries(${PROJECT_NAME} Boost::program_options)

which links to msys64/mingw64/lib/libboost_program_options-mt.dll.a in my
case

Best, Norbert.

On Wed, May 31, 2017 at 2:08 AM Leif AMO  wrote:

> It's been a while since I installed MinGW-w64 so I can't remember the
> specific installation options selected (thread models, etc), or if that
> is relevant.
>
> I've been able to compile a few relatively simple C and C++ programs.
> Using the MSYS2/MINGW64 shell for program compilation.  Installed boost
> for using pacman under the MSYS2 shell (not MINGW32 or MINGW64).
>
>  pacman -Ss | grep boost
>  mingw32/mingw-w64-i686-boost 1.63.0-1 [installed]
>  mingw64/mingw-w64-x86_64-boost 1.63.0-1 [installed]
>
> I'm able to compile and run a "simple" boost example (simple.cpp.txt [1]
> attached) without errors using:
>
>  g++ simple.cpp -o simple
>
> However, when trying to compile the program_options "first" example
> (po_first.cpp.txt attached), I get a lot of errors (po_first.log.txt).
>
>  g++ po_first.cpp -o po_first
>
> I don't know if I set up MinGW-w64 correctly, or if I need to specify
> includes or libraries to link to on g++ command line.  Any tips
> appreciated.
>
> [1] Note: Attachments given .txt extension in hopes that mailing list
> software doesn't eat the file.  Rename locally as needed.
>
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> Mingw-w64-public mailing list
> Mingw-w64-public@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public


[Mingw-w64-public] Difficulty using Boost library with MSYS2/MINGW64

2017-05-30 Thread Leif AMO
It's been a while since I installed MinGW-w64 so I can't remember the 
specific installation options selected (thread models, etc), or if that 
is relevant.


I've been able to compile a few relatively simple C and C++ programs. 
Using the MSYS2/MINGW64 shell for program compilation.  Installed boost 
for using pacman under the MSYS2 shell (not MINGW32 or MINGW64).


pacman -Ss | grep boost
mingw32/mingw-w64-i686-boost 1.63.0-1 [installed]
mingw64/mingw-w64-x86_64-boost 1.63.0-1 [installed]

I'm able to compile and run a "simple" boost example (simple.cpp.txt [1] 
attached) without errors using:


g++ simple.cpp -o simple

However, when trying to compile the program_options "first" example 
(po_first.cpp.txt attached), I get a lot of errors (po_first.log.txt).


g++ po_first.cpp -o po_first

I don't know if I set up MinGW-w64 correctly, or if I need to specify 
includes or libraries to link to on g++ command line.  Any tips appreciated.


[1] Note: Attachments given .txt extension in hopes that mailing list 
software doesn't eat the file.  Rename locally as needed.
#include 
#include 
#include 
#include 

int main()
{
using namespace boost::lambda;
typedef std::istream_iterator in;

std::for_each(
in(std::cin), in(), std::cout << (_1 * 3) << " " );
}
// Copyright Vladimir Prus 2002-2004.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)

/* The simplest usage of the library.
 */

#include 
namespace po = boost::program_options;

#include 
#include 
using namespace std;

int main(int ac, char* av[])
{
try {

po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("compression", po::value(), "set compression 
level")
;

po::variables_map vm;
po::store(po::parse_command_line(ac, av, desc), vm);
po::notify(vm);

if (vm.count("help")) {
cout << desc << "\n";
return 0;
}

if (vm.count("compression")) {
cout << "Compression level was set to "
 << vm["compression"].as() << ".\n";
} else {
cout << "Compression level was not set.\n";
}
}
catch(exception& e) {
cerr << "error: " << e.what() << "\n";
return 1;
}
catch(...) {
cerr << "Exception of unknown type!\n";
}

return 0;
}
E:\msys64\tmp\ccGFMUW8.o:first.cpp:(.text+0x86): undefined reference to 
`boost::program_options::options_description::options_description(std::__cxx11::basic_string const&, unsigned int, unsigned 
int)'
E:\msys64\tmp\ccGFMUW8.o:first.cpp:(.text+0xb8): undefined reference to 
`boost::program_options::options_description::add_options()'
E:\msys64\tmp\ccGFMUW8.o:first.cpp:(.text+0xdc): undefined reference to 
`boost::program_options::options_description_easy_init::operator()(char const*, 
char const*)'
E:\msys64\tmp\ccGFMUW8.o:first.cpp:(.text+0xf5): undefined reference to 
`boost::program_options::options_description_easy_init::operator()(char const*, 
boost::program_options::value_semantic const*, char const*)'
E:\msys64\tmp\ccGFMUW8.o:first.cpp:(.text+0x101): undefined reference to 
`boost::program_options::variables_map::variables_map()'
E:\msys64\tmp\ccGFMUW8.o:first.cpp:(.text+0x163): undefined reference to 
`boost::program_options::store(boost::program_options::basic_parsed_options
 const&, boost::program_options::variables_map&, bool)'
E:\msys64\tmp\ccGFMUW8.o:first.cpp:(.text+0x18d): undefined reference to 
`boost::program_options::notify(boost::program_options::variables_map&)'
E:\msys64\tmp\ccGFMUW8.o:first.cpp:(.text+0x210): undefined reference to 
`boost::program_options::operator<<(std::ostream&, 
boost::program_options::options_description const&)'
E:\msys64\tmp\ccGFMUW8.o:first.cpp:(.text$_ZN5boost15program_options16validation_errorC1ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i[_ZN5boost15program_options16validation_errorC1ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i]+0x2f):
 undefined reference to 
`boost::program_options::validation_error::get_template[abi:cxx11](boost::program_options::validation_error::kind_t)'
E:\msys64\tmp\ccGFMUW8.o:first.cpp:(.text$_ZN5boost15program_options16validation_errorC1ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i[_ZN5boost15program_options16validation_errorC1ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i]+0x4e):
 undefined reference to