0
votes

I just want to use the boost library to create a shared memory on an ARM system. It work fine if you want to compile it only under ubuntu. However, when I want to cross compile it with TI's CCSv6 and angstrom toolchain, it keep pushing errors.

Because I do not know how to write a makefile for cross compile, I think using TI their own IDE might be a good choice to avoid further problems.

Here is my code and print out of build console.

#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/mapped_region.hpp>
#include <iostream>

using namespace boost::interprocess;

int main()
{

  shared_memory_object shdmem{open_or_create, "Boost1", read_write};

  shdmem.truncate(1024);
  mapped_region region{shdmem, read_write};

}

g++ -std=c++0x -I/usr/include -O0 -g3 -Wall -c -fmessage-length=0 -L /lib -lrt -lpthread -fPIC

The IDE called Code Composer Studio has cross compile settings as below:

Prefix: arm-angstrom-linux-gnueabi-

Path: /usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/armv5te-angstrom-linux-gnueabi

Build Console:

/usr/include/boost/interprocess/shared_memory_object.hpp:309: undefined reference to shm_open' /usr/include/boost/interprocess/shared_memory_object.hpp:315: undefined reference toshm_open' /usr/include/boost/interprocess/shared_memory_object.hpp:327: undefined reference to shm_open' /usr/include/boost/interprocess/shared_memory_object.hpp:334: undefined reference toshm_open' collect2: ld returned 1 exit status make: *** [test] Error 1

1
You have a typo in -plthread. Also -I/usr/include is redundant.Paul R
You did not specify boost library.Elvis Oric
@Paul R sorry, It is a typing error. Even for -lpthread, it got the same error. If I do not include /usr/include, it will told me: shared_memory_object.hpp: No such file or directory. Thank you for your help :)Peizheng Ma
@Elvis Oric. Hi, I thought it might be this reason. Could you please help about how to specify it with more details? Thanks a lot:)Peizheng Ma
-I/usr/include is the probably the wrong headers. You are cross compiling and using the host headers (x86 ubuntu?). You need to locate the cross libraries and header for the ARM platform.artless noise

1 Answers

0
votes

undefined reference to shm_open' means it cannot find -lrt for ARM.

In your build command line you need to specify include and library paths to ARM built libraries, not to Ubuntu ones. So -I/usr/include and -L /lib is wrong.

Also you need boost built for ARM, although if you just want to use interprocess library then boost headers should be enough. But you need to copy them into different location because including them from /usr/include includes also other headers specific to Ubuntu.

You can use the cross compiler IDE you mentioned or arm g++ cross compiler which you can install by: sudo apt-get install g++-arm-linux-gnueabihf. Some headers and libraries for ARM will be installed too.