Wrapping Boost with CppSharp

152 views
Skip to first unread message

Madwand99

unread,
Sep 18, 2015, 4:45:37 PM9/18/15
to CppSharp
I have been tasked with getting a C++ program communicating with a C# program. To that end, I had the idea of using wrapping Boost using CppSharp. I am using the following Setup function:

        public void Setup(Driver driver)
         
{
             
var options = driver.Options;
             options
.GeneratorKind = GeneratorKind.CSharp;
             options
.LibraryName = "BoostIPC";
 
             options
.addIncludeDirs("/usr/include/boost/compatibility/cpp_c_headers");
             options
.addIncludeDirs("/usr/lib/gcc/x86_64-linux-gnu/4.8/include");
             options
.addIncludeDirs("/usr/local/include");
             options
.addIncludeDirs("/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed");
             options
.addIncludeDirs("/usr/include/x86_64-linux-gnu");
             options
.addIncludeDirs("/usr/include");
             options
.addIncludeDirs("/usr/include/c++/4.8");
             options
.addIncludeDirs("/usr/include/x86_64-linux-gnu/c++/4.8");
 
             options
.Headers.Add("boost/interprocess/shared_memory_object.hpp");
             options
.Headers.Add("boost/interprocess/mapped_region.hpp");
         
}

I am getting the following output on my Linux system:

Test
Parsing libraries...
Indexing library symbols...
Parsing code...
Unhandled declaration kind: NamespaceAlias
  /usr/include/boost/interprocess/interprocess_fwd.hpp (line 35)
Unhandled type class 'DependentTemplateSpecialization'
Unhandled type class 'DependentTemplateSpecialization'
Parsed 'boost/interprocess/shared_memory_object.hpp'
/usr/include/boost/interprocess/errors.hpp(185,21): warning: inline function 'boost::interprocess::lookup_error' is not defined
/usr/include/boost/interprocess/errors.hpp(197,4): warning: inline function 'boost::interprocess::error_info::error_info' is not defined
/usr/include/boost/interprocess/exceptions.hpp(68,12): warning: inline function 'boost::interprocess::interprocess_exception::~interprocess_exception' is not defined
/usr/include/boost/interprocess/exceptions.hpp(51,4): warning: inline function 'boost::interprocess::interprocess_exception::interprocess_exception' is not defined
/usr/include/boost/interprocess/exceptions.hpp(36,4): warning: inline function 'boost::interprocess::interprocess_exception::interprocess_exception' is not defined
/usr/include/boost/interprocess/detail/os_file_functions.hpp(489,22): warning: inline function 'boost::interprocess::ipcdetail::invalid_file' is not defined
Unhandled declaration kind: NamespaceAlias
  /usr/include/boost/interprocess/interprocess_fwd.hpp (line 35)
Unhandled declaration kind: TemplateTemplateParm
   (line 1)
Unhandled type class 'DependentTemplateSpecialization'
Unhandled type class 'DependentTemplateSpecialization'
Unhandled declaration kind: TemplateTemplateParm
   (line 1)
Unhandled declaration kind: TemplateTemplateParm
  /usr/include/boost/intrusive/detail/memory_util.hpp (line 250)
Unhandled declaration kind: TemplateTemplateParm
   (line 1)
Unhandled declaration kind: TemplateTemplateParm
  /usr/include/boost/intrusive/detail/memory_util.hpp (line 257)
Parsed 'boost/interprocess/mapped_region.hpp'
/usr/include/boost/interprocess/errors.hpp(185,21): warning: inline function 'boost::interprocess::lookup_error' is not defined
/usr/include/boost/interprocess/errors.hpp(197,4): warning: inline function 'boost::interprocess::error_info::error_info' is not defined
/usr/include/boost/interprocess/exceptions.hpp(68,12): warning: inline function 'boost::interprocess::interprocess_exception::~interprocess_exception' is not defined
/usr/include/boost/interprocess/exceptions.hpp(51,4): warning: inline function 'boost::interprocess::interprocess_exception::interprocess_exception' is not defined
/usr/include/boost/interprocess/exceptions.hpp(36,4): warning: inline function 'boost::interprocess::interprocess_exception::interprocess_exception' is not defined
Processing code...
Generating code...

The process then hangs at the "Generating code..."  stage. I have no idea what I might need to do to include Boost and have it work. Has anyone ever done this?

João Matos

unread,
Sep 20, 2015, 11:01:32 PM9/20/15
to Madwand99, CppSharp
Hi,  tried it here on Windows and found a couple problems mostly related to templates which Boost sure abuses of.

The latest revision on Github has a couple of fixes and now generates bindings (~250 C# files to be exact) but they don't like very usable at all.

I would say you don't really want to go this route. Depending on the task itself I would create a very minimal API in C++ (which could use Boost internally) and then wrap that with C++# so you get a very clean API in C# with no sign of Boost anywhere. Another alternative would be to just use sockets or pipes and transfer data with a custom protocol or a data serialization library like MessagePack, Thrift or Protocol Buffers.

Feel free to open issues on our Github page in the future instead of using the mailing list.












--
You received this message because you are subscribed to the Google Groups "CppSharp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cppsharp-lis...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
João Matos
Reply all
Reply to author
Forward
0 new messages