cpp code and Boost.Interprocess compile error
Hello All, I was looking for using stl maps in shared memory, when i came across Boost library. I have downloaded boost_1_36_0 version. In the examples directory, there is a cpp file for sharing stl maps named doc_map.cpp. When i compile the same with the following command: c++ -I $BOOST_ROOT doc_map.cpp -o shmmap I got the following errors: /tmp/ccEYJnov.o: In function `boost::interprocess::shared_memory_object::priv_open_or_create(boost::interprocess::detail::create_enum_t, char const*, boost::interprocess::mode_t)': doc_map.cpp:(.text._ZN5boost12interprocess20shared_memory_object19priv_open_or_createENS0_6detail13create_enum_tEPKcNS0_6mode_tE[boost::interprocess::shared_memory_object::priv_open_or_create(boost::interprocess::detail::create_enum_t, char const*, boost::interprocess::mode_t)]+0x163): undefined reference to `shm_open' /tmp/ccEYJnov.o: In function `boost::interprocess::detail::mutexattr_wrapper::mutexattr_wrapper(bool)': doc_map.cpp:(.text._ZN5boost12interprocess6detail17mutexattr_wrapperC1Eb[boost::interprocess::detail::mutexattr_wrapper::mutexattr_wrapper(bool)]+0x14): undefined reference to `pthread_mutexattr_init' doc_map.cpp:(.text._ZN5boost12interprocess6detail17mutexattr_wrapperC1Eb[boost::interprocess::detail::mutexattr_wrapper::mutexattr_wrapper(bool)]+0x2b): undefined reference to `pthread_mutexattr_setpshared' doc_map.cpp:(.text._ZN5boost12interprocess6detail17mutexattr_wrapperC1Eb[boost::interprocess::detail::mutexattr_wrapper::mutexattr_wrapper(bool)]+0x4d): undefined reference to `pthread_mutexattr_settype' /tmp/ccEYJnov.o: In function `boost::interprocess::detail::mutexattr_wrapper::~mutexattr_wrapper()': doc_map.cpp:(.text._ZN5boost12interprocess6detail17mutexattr_wrapperD1Ev[boost::interprocess::detail::mutexattr_wrapper::~mutexattr_wrapper()]+0xd): undefined reference to `pthread_mutexattr_destroy' /tmp/ccEYJnov.o: In function `boost::interprocess::shared_memory_object::remove(char const*)': doc_map.cpp:(.text._ZN5boost12interprocess20shared_memory_object6removeEPKc[boost::interprocess::shared_memory_object::remove(char const*)]+0x33): undefined reference to `shm_unlink' collect2: ld returned 1 exit status Can anyone please tell me what i'm missing in the compilation. Thank you. -- View this message in context: http://www.nabble.com/cpp-code-and-Boost.Interprocess-compile-error-tp200120... Sent from the Boost - Users mailing list archive at Nabble.com.
hamsinv wrote:
Hello All,
I was looking for using stl maps in shared memory, when i came across Boost library. I have downloaded boost_1_36_0 version. In the examples directory, there is a cpp file for sharing stl maps named doc_map.cpp.
When i compile the same with the following command: c++ -I $BOOST_ROOT doc_map.cpp -o shmmap
I got the following errors: /tmp/ccEYJnov.o: In function `boost::interprocess::shared_memory_object::priv_open_or_create(boost::interprocess::detail::create_enum_t, char const*, boost::interprocess::mode_t)': doc_map.cpp:(.text._ZN5boost12interprocess20shared_memory_object19priv_open_or_createENS0_6detail13create_enum_tEPKcNS0_6mode_tE[boost::interprocess::shared_memory_object::priv_open_or_create(boost::interprocess::detail::create_enum_t, char const*, boost::interprocess::mode_t)]+0x163): undefined reference to `shm_open' /tmp/ccEYJnov.o: In function `boost::interprocess::detail::mutexattr_wrapper::mutexattr_wrapper(bool)': doc_map.cpp:(.text._ZN5boost12interprocess6detail17mutexattr_wrapperC1Eb[boost::interprocess::detail::mutexattr_wrapper::mutexattr_wrapper(bool)]+0x14): undefined reference to `pthread_mutexattr_init' doc_map.cpp:(.text._ZN5boost12interprocess6detail17mutexattr_wrapperC1Eb[boost::interprocess::detail::mutexattr_wrapper::mutexattr_wrapper(bool)]+0x2b): undefined reference to `pthread_mutexattr_setpshared' doc_map.cpp:(.text._ZN5boost12interprocess6detail17mutexattr_wrapperC1Eb[boost::interprocess::detail::mutexattr_wrapper::mutexattr_wrapper(bool)]+0x4d): undefined reference to `pthread_mutexattr_settype' /tmp/ccEYJnov.o: In function `boost::interprocess::detail::mutexattr_wrapper::~mutexattr_wrapper()': doc_map.cpp:(.text._ZN5boost12interprocess6detail17mutexattr_wrapperD1Ev[boost::interprocess::detail::mutexattr_wrapper::~mutexattr_wrapper()]+0xd): undefined reference to `pthread_mutexattr_destroy' /tmp/ccEYJnov.o: In function `boost::interprocess::shared_memory_object::remove(char const*)': doc_map.cpp:(.text._ZN5boost12interprocess20shared_memory_object6removeEPKc[boost::interprocess::shared_memory_object::remove(char const*)]+0x33): undefined reference to `shm_unlink' collect2: ld returned 1 exit status
Can anyone please tell me what i'm missing in the compilation.
Thank you.
You need to link your system's shared memory and pthread library(eg: -lrt in linux). Regards, Ion
Hello Ion Gaztanaga, Thank you for the suggestion. I would do that. Ion Gaztañaga wrote:
hamsinv wrote:
Hello All,
I was looking for using stl maps in shared memory, when i came across Boost library. I have downloaded boost_1_36_0 version. In the examples directory, there is a cpp file for sharing stl maps named doc_map.cpp.
When i compile the same with the following command: c++ -I $BOOST_ROOT doc_map.cpp -o shmmap
I got the following errors: /tmp/ccEYJnov.o: In function `boost::interprocess::shared_memory_object::priv_open_or_create(boost::interprocess::detail::create_enum_t, char const*, boost::interprocess::mode_t)': doc_map.cpp:(.text._ZN5boost12interprocess20shared_memory_object19priv_open_or_createENS0_6detail13create_enum_tEPKcNS0_6mode_tE[boost::interprocess::shared_memory_object::priv_open_or_create(boost::interprocess::detail::create_enum_t, char const*, boost::interprocess::mode_t)]+0x163): undefined reference to `shm_open' /tmp/ccEYJnov.o: In function `boost::interprocess::detail::mutexattr_wrapper::mutexattr_wrapper(bool)': doc_map.cpp:(.text._ZN5boost12interprocess6detail17mutexattr_wrapperC1Eb[boost::interprocess::detail::mutexattr_wrapper::mutexattr_wrapper(bool)]+0x14): undefined reference to `pthread_mutexattr_init' doc_map.cpp:(.text._ZN5boost12interprocess6detail17mutexattr_wrapperC1Eb[boost::interprocess::detail::mutexattr_wrapper::mutexattr_wrapper(bool)]+0x2b): undefined reference to `pthread_mutexattr_setpshared' doc_map.cpp:(.text._ZN5boost12interprocess6detail17mutexattr_wrapperC1Eb[boost::interprocess::detail::mutexattr_wrapper::mutexattr_wrapper(bool)]+0x4d): undefined reference to `pthread_mutexattr_settype' /tmp/ccEYJnov.o: In function `boost::interprocess::detail::mutexattr_wrapper::~mutexattr_wrapper()': doc_map.cpp:(.text._ZN5boost12interprocess6detail17mutexattr_wrapperD1Ev[boost::interprocess::detail::mutexattr_wrapper::~mutexattr_wrapper()]+0xd): undefined reference to `pthread_mutexattr_destroy' /tmp/ccEYJnov.o: In function `boost::interprocess::shared_memory_object::remove(char const*)': doc_map.cpp:(.text._ZN5boost12interprocess20shared_memory_object6removeEPKc[boost::interprocess::shared_memory_object::remove(char const*)]+0x33): undefined reference to `shm_unlink' collect2: ld returned 1 exit status
Can anyone please tell me what i'm missing in the compilation.
Thank you.
You need to link your system's shared memory and pthread library(eg: -lrt in linux).
Regards,
Ion
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- View this message in context: http://www.nabble.com/cpp-code-and-Boost.Interprocess-compile-error-tp200120... Sent from the Boost - Users mailing list archive at Nabble.com.
Hello All, How do i check its the same memory location accessed in two processes. hamsinv wrote:
Hello Ion Gaztanaga,
Thank you for the suggestion. I would do that.
Ion Gaztañaga wrote:
hamsinv wrote:
Hello All,
I was looking for using stl maps in shared memory, when i came across Boost library. I have downloaded boost_1_36_0 version. In the examples directory, there is a cpp file for sharing stl maps named doc_map.cpp.
When i compile the same with the following command: c++ -I $BOOST_ROOT doc_map.cpp -o shmmap
I got the following errors: /tmp/ccEYJnov.o: In function `boost::interprocess::shared_memory_object::priv_open_or_create(boost::interprocess::detail::create_enum_t, char const*, boost::interprocess::mode_t)': doc_map.cpp:(.text._ZN5boost12interprocess20shared_memory_object19priv_open_or_createENS0_6detail13create_enum_tEPKcNS0_6mode_tE[boost::interprocess::shared_memory_object::priv_open_or_create(boost::interprocess::detail::create_enum_t, char const*, boost::interprocess::mode_t)]+0x163): undefined reference to `shm_open' /tmp/ccEYJnov.o: In function `boost::interprocess::detail::mutexattr_wrapper::mutexattr_wrapper(bool)': doc_map.cpp:(.text._ZN5boost12interprocess6detail17mutexattr_wrapperC1Eb[boost::interprocess::detail::mutexattr_wrapper::mutexattr_wrapper(bool)]+0x14): undefined reference to `pthread_mutexattr_init' doc_map.cpp:(.text._ZN5boost12interprocess6detail17mutexattr_wrapperC1Eb[boost::interprocess::detail::mutexattr_wrapper::mutexattr_wrapper(bool)]+0x2b): undefined reference to `pthread_mutexattr_setpshared' doc_map.cpp:(.text._ZN5boost12interprocess6detail17mutexattr_wrapperC1Eb[boost::interprocess::detail::mutexattr_wrapper::mutexattr_wrapper(bool)]+0x4d): undefined reference to `pthread_mutexattr_settype' /tmp/ccEYJnov.o: In function `boost::interprocess::detail::mutexattr_wrapper::~mutexattr_wrapper()': doc_map.cpp:(.text._ZN5boost12interprocess6detail17mutexattr_wrapperD1Ev[boost::interprocess::detail::mutexattr_wrapper::~mutexattr_wrapper()]+0xd): undefined reference to `pthread_mutexattr_destroy' /tmp/ccEYJnov.o: In function `boost::interprocess::shared_memory_object::remove(char const*)': doc_map.cpp:(.text._ZN5boost12interprocess20shared_memory_object6removeEPKc[boost::interprocess::shared_memory_object::remove(char const*)]+0x33): undefined reference to `shm_unlink' collect2: ld returned 1 exit status
Can anyone please tell me what i'm missing in the compilation.
Thank you.
You need to link your system's shared memory and pthread library(eg: -lrt in linux).
Regards,
Ion
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- View this message in context: http://www.nabble.com/cpp-code-and-Boost.Interprocess-compile-error-tp200120... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (2)
-
hamsinv
-
Ion Gaztañaga