3

I am trying to build this program:

#include "stdafx.h"
#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/file_mapping.hpp>
#include <boost/interprocess/mapped_region.hpp>

using namespace std;

int main()
{
    using boost::interprocess;

    // Create the file mapping
    file_mapping fm("input.dat", read_only);
    // Map the file in memory
    mapped_region region(fm, read_only);
    // Get the address where the file has been mapped
    float * addr = (float *)region.get_address();
    std::size_t elements = region.get_size() / sizeof(float);
}

But I am having two problems, for the main I am getting:

1>tasker.cpp(98): error C2873: 'boost::interprocess' : symbol cannot be used in a using-declaration
1>tasker.cpp(101): error C2065: 'file_mapping' : undeclared identifier
1>tasker.cpp(101): error C2146: syntax error : missing ';' before identifier 'fm'
1>tasker.cpp(101): error C2065: 'read_only' : undeclared identifier
1>tasker.cpp(101): error C3861: 'fm': identifier not found
1>tasker.cpp(103): error C2065: 'mapped_region' : undeclared identifier
1>tasker.cpp(103): error C2146: syntax error : missing ';' before identifier 'region'
1>tasker.cpp(103): error C2065: 'fm' : undeclared identifier
1>tasker.cpp(103): error C2065: 'read_only' : undeclared identifier
1>tasker.cpp(103): error C3861: 'region': identifier not found
1>tasker.cpp(105): error C2065: 'region' : undeclared identifier
1>tasker.cpp(105): error C2228: left of '.get_address' must have class/struct/union
1>          type is 'unknown-type'
1>tasker.cpp(106): error C2065: 'region' : undeclared identifier
1>tasker.cpp(106): error C2228: left of '.get_size' must have class/struct/union
1>          type is 'unknown-type'

and for the #include <boost/interprocess/mapped_region.hpp> I am getting

1>C:\Users\Mike\Documents\boost_1_55_0\boost/intrusive/detail/has_member_function_callable_with.hpp(200): error C2228: left of '.select_on_container_copy_construction' must have class/struct/union
1>          type is 'boost::move_detail::add_rvalue_reference<U>::type'
1>          C:\Users\Mike\Documents\boost_1_55_0\boost/intrusive/detail/has_member_function_callable_with.hpp(276) : see reference to class template instantiation 'boost::container::container_detail::has_member_function_callable_with_select_on_container_copy_construction_impl<Fun,true,>' being compiled
1>          with
1>          [
1>              Fun=std::allocator<std::pair<const boost::interprocess::ipcdetail::sync_id *const ,boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<std::pair<const boost::interprocess::ipcdetail::sync_id,void *>>>>>
1>          ]
1>          C:\Users\Mike\Documents\boost_1_55_0\boost/container/allocator_traits.hpp(262) : see reference to class template instantiation 'boost::container::container_detail::has_member_function_callable_with_select_on_container_copy_construction<const Alloc,>' being compiled
1>          with
1>          [
1>              Alloc=std::allocator<std::pair<const boost::interprocess::ipcdetail::sync_id *const ,boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<std::pair<const boost::interprocess::ipcdetail::sync_id,void *>>>>>
1>          ]
1>          C:\Users\Mike\Documents\boost_1_55_0\boost/container/detail/tree.hpp(217) : see reference to class template instantiation 'boost::container::allocator_traits<A>' being compiled
1>          with
1>          [
1>              A=std::allocator<std::pair<const boost::interprocess::ipcdetail::sync_id *const ,boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<std::pair<const boost::interprocess::ipcdetail::sync_id,void *>>>>>
1>          ]
1>          C:\Users\Mike\Documents\boost_1_55_0\boost/container/detail/tree.hpp(246) : see reference to class template instantiation 'boost::container::container_detail::intrusive_rbtree_type<A,boost::container::container_detail::tree_value_compare<Key,std::pair<const Key,T>,Compare,boost::container::container_detail::select1st<std::pair<const Key,T>>>>' being compiled
1>          with
1>          [
1>              A=std::allocator<std::pair<const boost::interprocess::ipcdetail::sync_id *const ,boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<std::pair<const boost::interprocess::ipcdetail::sync_id,void *>>>>>
1>  ,            Key=const boost::interprocess::ipcdetail::sync_id *
1>  ,            T=boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<std::pair<const boost::interprocess::ipcdetail::sync_id,void *>>>
1>  ,            Compare=boost::interprocess::ipcdetail::sync_handles::address_less
1>          ]
1>          C:\Users\Mike\Documents\boost_1_55_0\boost/container/map.hpp(83) : see reference to class template instantiation 'boost::container::container_detail::rbtree<Key,std::pair<const Key,T>,boost::container::container_detail::select1st<std::pair<const Key,T>>,Compare,Allocator>' being compiled
1>          with
1>          [
1>              Key=const boost::interprocess::ipcdetail::sync_id *
1>  ,            T=boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<std::pair<const boost::interprocess::ipcdetail::sync_id,void *>>>
1>  ,            Compare=boost::interprocess::ipcdetail::sync_handles::address_less
1>  ,            Allocator=std::allocator<std::pair<const boost::interprocess::ipcdetail::sync_id *const ,boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<std::pair<const boost::interprocess::ipcdetail::sync_id,void *>>>>>
1>          ]
1>          C:\Users\Mike\Documents\boost_1_55_0\boost/interprocess/sync/windows/sync_utils.hpp(226) : see reference to class template instantiation 'boost::container::map<const boost::interprocess::ipcdetail::sync_id *,boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<T>>,boost::interprocess::ipcdetail::sync_handles::address_less,std::allocator<std::pair<const Key,boost::unordered::iterator_detail::iterator<boost::unordered::detail::ptr_node<T>>>>>' being compiled
1>          with
1>          [
1>              T=std::pair<const boost::interprocess::ipcdetail::sync_id,void *>
1>  ,            Key=const boost::interprocess::ipcdetail::sync_id *
1>          ]

I am using Visual Studio Express 2013 for Windows Desktop, and boost 1.55.0.

I tried other boost libraries and work without any issue.... Also, I am using the x64 release build.

SkyRipper
  • 155
  • 5
  • 15

3 Answers3

3

Try changing this:

using boost::interprocess;

to this:

using namespace boost::interprocess;

(Ref: Example in http://www.boost.org/doc/libs/1_55_0/doc/html/interprocess/quick_guide.html )

Joe Z
  • 17,413
  • 3
  • 28
  • 39
3

Boost 1.55 does not fully supports Visual Studio 2013 compiler yet.

Either:

  • use Visual Studio 2012 toolchain
  • or try to get latest source from svn co http://svn.boost.org/svn/boost/trunk boost-trunk
  • or patch boost yourself (don't forget to upload your patch)
  • or wait until someone will patch it. You can speed it up by submitting bug report

Edit

Just checked boost-trunk, with boost/intrusive/detail/has_member_function_callable_with.hpp already patched and it compiles fine with both vs2013 and vs2013-nov-2013-ctp toolchains. So, try it. And, if you have multiple boost versions, don't forget to change include paths (in Makefile or VC project properties) as I did. ;)

Note, that, obviously, latest development code can be unstable. Do not use it for end-user production.

Community
  • 1
  • 1
Ivan Aksamentov - Drop
  • 12,860
  • 3
  • 34
  • 61
  • Thanks, do you know someone who patched boost to support visual studio 2013? – SkyRipper Dec 12 '13 at 06:34
  • Well, no. Boost development is a huge machine. Check [this](https://svn.boost.org/trac/boost) to figure it out. – Ivan Aksamentov - Drop Dec 12 '13 at 06:37
  • Ok, I've added a link to bug report form. Submit it! ;) – Ivan Aksamentov - Drop Dec 12 '13 at 06:42
  • I've just checked it with latest `boost-trunk`. Doesn't compiles. – Ivan Aksamentov - Drop Dec 12 '13 at 06:46
  • @SkyRipper I've checked one more time, and, actually, `boost-trunk` compiles fine. I've just forgot to change includes search path from `boost-release` to `boost-trunk`. Note, that I was unable to link and run it, because I didn't compiled `boost-trunk` libraries yet. So, it is up to you to check ;) Will add this to answer. – Ivan Aksamentov - Drop Dec 12 '13 at 07:15
  • You write that you got Boost to compile with the `vs2013-nov-2013-ctp` toolset. How did you do this? I've already tried to supply the Boost build system with the argument `toolset=msvc-12.0-ctp` and the like but it doesn't work. – Frederik Aalund Jan 21 '14 at 17:20
  • @FrederikAalund No, I did not compiled boost with vs2013-ctp. I've only be able to compile SkyRipper's code, but did not linked it with boost, as I stated in comment above. I've put additional info to [this](http://stackoverflow.com/questions/21267652/how-do-i-build-boost-1-55-with-visual-studio-2013-ctp-november-2013/21296863#21296863) answer to your question. – Ivan Aksamentov - Drop Jan 23 '14 at 00:16
1

Yeah. you need to say "using namespace boost::interprocess;" Fix that and you should be good.

apollonovich
  • 21
  • 1
  • 2