How to link libpmemobj-cpp-dev library to an application program in eclipse IDE

12 views
Skip to first unread message

Supriya Mishra SVNIT

unread,
Dec 28, 2022, 8:40:25 AM12/28/22
to pmem
Hi all,

I am trying to create a persistent queue using pmemobj++ library (which is c++ binding for libpmemobj). I have already installed this in from pre-built packages on my linux environment. I am including the necessary header files like <libpmemobj++/make_persistent.hpp> and so on.

I have added pmemobj to the linker option but don't know how to add pmemobj++ library in linker option.

Please help me resolve.

Thanks

Igor

unread,
Dec 28, 2022, 11:35:00 AM12/28/22
to Supriya Mishra SVNIT, pmem
Hi,

You don't need to add anything extra for libpmemobj++. It's a header-only library. Linking with pmemobj should be enough.

Best regards,
Igor

--
You received this message because you are subscribed to the Google Groups "pmem" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pmem+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pmem/f20ba964-aef2-488a-a709-2294949d5fc8n%40googlegroups.com.

Supriya Mishra SVNIT

unread,
Dec 28, 2022, 3:17:47 PM12/28/22
to pmem
Hi Igor,

Thank you for your reply.

Best,
Supriya

Igor

unread,
Jan 9, 2023, 3:47:50 PM1/9/23
to Supriya Mishra SVNIT, pmem
Hi,

I'm sorry for not getting back to you sooner. I missed your email earlier.

The problem is this line:
proot->pqueue=new Persistentqueue();

You are creating a new instance of Peristentqueue on DRAM, but later, you call pmem::obj::pool_by_vptr  on that instance. This will not work since that function expects a pointer to an object that resides on PMEM. The solution to this problem is just to remove this line. You've already created an instance of Persistenqueue by calling make_persistent_atomic.

In fact, all make_persistent* functions do two things: allocate memory on PMEM and call the appropriate constructor (based on the template parameter). When you reopen the pool, you don't need to call the constructor for the second time - you use the same instance. You should be aware that this programming model does not fully adhere to the C++ standard. You can read about limitations here: https://github.com/pmem/libpmemobj-cpp/tree/master/include/libpmemobj%2B%2B#c-standard-notice and here: https://pmem.io/blog/2019/10/c-standard-limitations-and-persistent-memory/.

Best regards,
Igor  

Reply all
Reply to author
Forward
0 new messages