开发者

How to create a library from boost?

开发者 https://www.devze.com 2023-01-27 10:44 出处:网络
I am using part of boost for a project (only the message_queue). If I use native code, the hpp file is fine. But I need the message queue in a LLVM bitcode file (I\'m executing the bitcode in my progr

I am using part of boost for a project (only the message_queue). If I use native code, the hpp file is fine. But I need the message queue in a LLVM bitcode file (I'm executing the bitcode in my program) and get the following error:

LLVM ERROR: Program used external function 'shm_unlink' which could not be resolved!

I was told that building a library with the required part of boost is the best way to solve this problem.

What I did (in the boost directory):

gcc -I . -c boost/interprocess/ipc/message_queue.hpp -o ipc.o
ar -cvq libipc.a ipc.o
ranlib libipc.a

and then in my program directory:

llvm-g++ -Wall -O3 -static -L../../Release/lib -lipc -I../../include -I../../../boost_1_44_0 -fexceptions -emit-llvm tmp.cpp -o tmp.bc

Now, if I include the boost-header in my program, I get:

../../Release/lib/libipc.a: could not read symbols: Archive has no index开发者_运维技巧; run ranlib to add one

If I don't include them, I get a some of errors which are all related to message_queue being undeclared.

What am I doing wrong? And more important, how do I solve this problem?


shm_unlink, iirc, is provided in the realtime library librt. Add the link [gcc flag -lrt] to your build

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号