|
Boost : |
From: Shibu Bera (shibu.ncst_at_[hidden])
Date: 2007-03-09 12:38:28
Thanks for the reply. I am sending the code and other details please view.
O/S :: linux fedora
filename : main.cpp
#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/detail/config_begin.hpp>
#include <boost/interprocess/detail/workaround.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>
int main()
{
boost::interprocess::fixed_managed_shared_memory segment
(
boost::interprocess::open_or_create,
"MySharedMemory", //segment name
1024 * 1024
);
return 0;
}
command # g++ -c main.cpp
command # g++ g++ -o exec main.o -Wall -pedantic -g -pthread
-DBOOST_DATE_TIME_NO_LIB -lstdc++ -lboost_thread
/*linking without comman c++ */
command # ./exec
command # cp /dev/shm/MySharedMemory shm_without_ccpp
/* copy of shared memoty created */
command # rm /dev/shm/MySharedMemory
/* remove created shared memoty using comman line */
command # g++ -o exec main.o -Wall -pedantic -g -pthread
-DBOOST_DATE_TIME_NO_LIB -lstdc++ -lboost_thread -lxml2 -lccext2 -lccgnu2
-ldl
/* linking with comman c ++ */
command # ./exec
command # cp /dev/shm/MySharedMemory shm_with_ccpp
/* copy of shared memory created */
command # diff shm_without_ccpp shm_with_ccpp
Binary files shm_without_ccpp and shm_with_ccpp differ
Here I am comparing the two shared memories created. It says these are
different. I am not getting just adding a library in link time, how shared
memory is changed. Can I get some clue now?
On 3/9/07, Peter Dimov <pdimov_at_[hidden]> wrote:
>
> Shibu Bera wrote:
> > yes u r right. Linking another library is not important to use
> > interprocess. But because there is requirment of the other part of
> > the application I am including the link library of comman c++ while
> > creating executable , If I woudn't link comman c++, still shared
> > memory would have beed created.
> >
> > But including comman c++ link library, the shared memory is created is
> > different from the shared memory which is created without comman c++
> > link library. And in the shared memory I am finding offset of some
> > bytes on the actual value stored in the shared memory.
>
> Please post the two complete command lines.
>
> You may first try to add -lrt to the program that doesn't use the "common
> C++ library".
>
> Also, remove the -DBOOST_INTERPROCESS_POSIX_PROCESS_SHARED as Ion stated.
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
-- Regards, CBu..., Tata Power, Mumbai.......
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk