Undefined reference to Boost copy_file

Problem

C++ code that uses Boost Filesystem was compiling fine with Boost 1.49. However, when I switched to Boost 1.55, the same code gave this error:

foobar.cpp.o: In function `do_something()':
foobar.cpp:(.text+0xb78): undefined reference to `boost::filesystem::detail::copy_file(boost::filesystem::path const&, boost::filesystem::path const&, boost::filesystem::copy_option, boost::system::error_code*)'

This was surprising since the declaration of the copy_file method was present in filesystem.hpp and libboost_filesystem.so was linked during compilation.

Solution

Turns out this is a known bug with Boost Filesystem as described here. Apparently, this happens only if the C++ code is compiled with the -std=c++11 option. I was indeed using that option.

The current fix for this bug is to temporarily disable the C++ scoped enums when the Boost Filesystem header file is included, like this:

#define BOOST_NO_CXX11_SCOPED_ENUMS
#include <boost/filesystem.hpp>
#undef BOOST_NO_CXX11_SCOPED_ENUMS

Tried with: Boost 1.55, GCC 4.8.4 and Ubuntu 14.04

Advertisements

How to configure USBMount

USBMount is a useful program and daemon that can be used to automount disk drives and flash drives plugged into USB ports. I use it with Raspbian for this purpose.

All the settings of USBMount can be changed from its configuration file /etc/usbmount/usbmount.conf

The parameters that can be modified from this file:

  • ENABLED: 1 to enable, 0 to disable USBMount.

  • MOUNTPOINTS: String of space-delimited mount points that should be used.

  • FILESYSTEMS: String of space-delimited filesystems that should be mounted.

  • MOUNTOPTIONS: String of comma-delimited mount options that will be used with the mount program to mount all the filesystems.

  • FS_MOUNTOPTIONS: Mount options that are specific to particular filesystem.

  • VERBOSE: no is brief logging to /var/syslog, yes is verbose logging. I like to change to yes so that it is easy to diagnose usbmount problems by looking at the syslog.

Tried with: USBMount 0.0.22 and Raspbian 7

MiniTool Partition Wizard

NTFS, ext4 and Linux swap partitions visible in MiniTool Partition Wizard
NTFS, ext4 and Linux swap partitions visible in MiniTool Partition Wizard

Windows has a partition manager called Disk Management that can be launched by typing diskmgmt.msc. However, this does not display any filesystem information for non-Windows partitions like ext4. And there is no chance of using it to create partitions with non-Windows partitions.

MiniTool Partition Wizard is a free Windows tool that can be used to view partition information for all types of filesystems. You can also create or edit partitions of those types. I find it useful when I occasionally have to use dual-boot Windows machines to quickly find out all about its partitions.

Tried with: MiniTool Partition Wizard Home Edition 8.1.1 and Windows 7 Professional 64-bit

How to label a partition in Ubuntu

A label makes it easy for users to identify a partition. This is especially necessary if you deal with a lot of partitions. Technically, not all partitions can be labeled. This is because a label is a feature of the filesystem and not all filesystems might support it.

I find that using GParted is the easiest way to label a partition. Open it, right-click the partition you want in the list and choose Label. Note that you may have to unmount the partition before you label.

Tried with: GParted 0.11.0 and Ubuntu 12.04 LTS