boost shared memory vector objetc

Hello, Please can somebody help me on this code (from boost site). I try to run it but I still get the following error: */cygdrive/C/Program Files/NetBeans 7.1.2/ide/bin/nativeexecution/dorun.sh: line 33: 12900 Segmentation fault (core dumped) sh "${SHFILE}" Press [Enter] to close the terminal ...* This is the code for creating vector in shared memory: #include <boost/interprocess/managed_shared_memory.hpp> #include <boost/interprocess/containers/vector.hpp> #include <boost/interprocess/allocators/allocator.hpp> #include <string> #include <cstdlib> //std::system using namespace boost::interprocess; //Define an STL compatible allocator of ints that allocates from the managed_shared_memory. //This allocator will allow placing containers in the segment typedef allocator<int, managed_shared_memory::segment_manager> ShmemAllocator; //Alias a vector that uses the previous STL-like allocator so that allocates //its values from the segment typedef vector<int, ShmemAllocator> MyVector; //Main function. For parent process argc == 1, for child process argc == 2 int main(int argc, char *argv[]) { if(argc == 1){ //Parent process //Remove shared memory on construction and destruction struct shm_remove { shm_remove() { shared_memory_object::remove("MySharedMemory"); } ~shm_remove(){ shared_memory_object::remove("MySharedMemory"); } } remover; //Create a new segment with given name and size managed_shared_memory segment(create_only, "MySharedMemory", 65536); //Initialize shared memory STL-compatible allocator const ShmemAllocator alloc_inst (segment.get_segment_manager()); //Construct a vector named "MyVector" in shared memory with argument alloc_inst *MyVector *myvector = segment.construct<MyVector>("MyVector")(alloc_inst);* * ;* } else{ // some code } return 0; }; I got an error for this instruction: *MyVector *myvector = segment.construct<MyVector>("MyVector")(alloc_inst); *This addition information about the environnment: NetBeans 7.1.2 with Cygwin_4.x, gcc-core 3.4.4-999, gcc-g++ 3.4.4-999,gcc-mingw-core 20050522-3,gcc-mingw-g++ 20050522-3 ,gcc4-core 4.5.3-3 , gcc4-g++ 4.5.3-3 , gdb 7.5.50-1. I am using Windows XP SP3. Many thanks. -- Regards Austina

El 02/12/2012 8:20, Olivier Austina escribió:
I got an error for this instruction: *MyVector *myvector = segment.construct<MyVector>("MyVector")(alloc_inst); *This addition information about the environnment: NetBeans 7.1.2 with Cygwin_4.x, gcc-core 3.4.4-999, gcc-g++ 3.4.4-999,gcc-mingw-core 20050522-3,gcc-mingw-g++ 20050522-3 ,gcc4-core 4.5.3-3 , gcc4-g++ 4.5.3-3 , gdb 7.5.50-1. I am using Windows XP SP3.
Which Boost version? Which compiler are you using, gcc 3 or gcc4? It might be a cygwin related issue. Ion

Hello, I am using gcc 4.5.3 and boost 1.48 ( Netbeans with Cygwin 4.x on Windows XP SP3). Thank you. Regards Austina 2012/12/2 Ion Gaztañaga <igaztanaga@gmail.com>
El 02/12/2012 8:20, Olivier Austina escribió:
I got an error for this instruction: *MyVector *myvector =
segment.construct<MyVector>("**MyVector")(alloc_inst); *This addition information about the environnment: NetBeans 7.1.2 with
Cygwin_4.x, gcc-core 3.4.4-999, gcc-g++ 3.4.4-999,gcc-mingw-core 20050522-3,gcc-mingw-g++ 20050522-3 ,gcc4-core 4.5.3-3 , gcc4-g++ 4.5.3-3 , gdb 7.5.50-1. I am using Windows XP SP3.
Which Boost version? Which compiler are you using, gcc 3 or gcc4?
It might be a cygwin related issue.
Ion ______________________________**_________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/**mailman/listinfo.cgi/boost-**users<http://lists.boost.org/mailman/listinfo.cgi/boost-users>
-- Regards Austina
participants (2)
-
Ion Gaztañaga
-
Olivier Austina