[llvm-dev] Problem using Boost Filesystem with Clang

Hubert Tong via llvm-dev llvm-dev at lists.llvm.org
Wed Feb 15 13:22:04 PST 2017


The more likely explanation is that the Boost libraries you are linking
with were built against libstdc++.
libc++ and libstdc++ are not designed to be binary-compatible, so, if your
program ends up encountering one form of a class (either the libc++ or
libstdc++ one) while expecting the other one, then you would experience
breakage.

-- HT

On Wed, Feb 15, 2017 at 4:04 PM, Simone Atzeni via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> I solved the problem, looks like the problem is libc++ , compiling with
> "-stdlib=libstdc++” solve the problem.
>
> Any reason why? Is libc++ missing something?
>
> Thanks.
> Simone
>
> > On Feb 15, 2017, at 11:01, Simone Atzeni <simone.at at gmail.com> wrote:
> >
> > Hi,
> >
> > not sure if this is the right place, but I am experiencing a problem
> using clang++ (3.9.1) with Boost Filesystem.
> >
> > I have this simple program:
> >
> > ------------------------------------------------------------------------
> > #include <iostream>
> > #include <boost/filesystem.hpp>
> > using namespace boost::filesystem;
> >
> > int main(int argc, char* argv[])
> > {
> > if (argc < 2)
> >   {
> >     std::cout << "Usage: tut1 path\n";
> >     return 1;
> >   }
> > std::cout << argv[1] << " " << file_size(argv[1]) << '\n';
> > return 0;
> > }
> > ------------------------------------------------------------------------
> >
> > If I compile with g++ using "g++ -lboost_system -lboost_filesystem
> main.cpp” and run it I obtain the size of a file that I use as input.
> >
> > If I compile with clang++ using " clang++ -std=c++11 -stdlib=libc++
> -lboost_system -lboost_filesystem main.cpp” when I run the program I get
> the error:
> >
> > "boost::filesystem::file_size: Bad address”
> >
> > Any idea why?
> >
> > Thanks.
> > Simone
> >
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170215/0c8b4449/attachment.html>


More information about the llvm-dev mailing list