I am trying to make a directory using Boost.Filesystem (the directory can be provided by the user, so it may be a path with nested directories; all, some, or none of the directories in that path may exist to start). When I run the program, a directory is created, but it is not what I asked for; the string containing the path appears to be getting mangled. I never get the same result twice, but the name of the directory always starts with a colon.
A minimal example:
#include <iostream>
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
int main(int argc, char* argv[]) {
fs::path path = "junk/morejunk";
if (!fs::create_directories(path)) {
std::cerr << "Failed to create directory " << path << ".\n";
}
return(0);
}
Running that, I get directories such as :@K%C5?
, :%C0)%E0?
, and :%C0%E9%93?
.
I had some trouble getting Boost to link correctly, but the above program compiles and runs now. In case it's necessary, some information:
-- I'm using a Mac (OSX 10.9.4)
-- GCC and Boost both installed with MacPorts (Boost with the +gcc49 option)
-- GCC version 4.9.2_1
-- Boost version 1.57.0_1
-- my Makefile looks like
CC = /opt/local/bin/g++
FLAGS = -I/opt/local/include -L/opt/local/lib -lboost_system-mt -lboost_filesystem-mt
driver : driver.cpp
$(CC) $(FLAGS) -o driver driver.cpp
Any suggestions welcome; it's been a while since I've used C++ much, and I'm not very experienced with Boost.