0

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

doqtor
  • 8,414
  • 2
  • 20
  • 36
Peizheng Ma
  • 155
  • 1
  • 2
  • 8
  • You have a typo in `-plthread`. Also `-I/usr/include` is redundant. – Paul R Jul 31 '15 at 13:37
  • You did not specify boost library. – Elvis Oric Jul 31 '15 at 13:58
  • @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 Jul 31 '15 at 14:01
  • @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 Jul 31 '15 at 14:06
  • Please don't post approximate versions of your commands/error messages/code - it just compounds the problem when you introduce further errors. Please fix the typos in the title and question (hit [edit]) and then we can try and fix the real errors. – Paul R Jul 31 '15 at 14:11
  • @Paul R Sorry about that. I already edited the question. I am pretty new to stackoverflow. Apologize for troubling you. – Peizheng Ma Jul 31 '15 at 14:16
  • No problem - welcome to StackOverflow BTW - you'll find that in general the better the quality of the question you ask the better the quality (and quantity) of answers that you are likely to receive. Good luck! – Paul R Jul 31 '15 at 14:18
  • 1
    `-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 Jul 31 '15 at 14:27
  • @artlessnoise Thank you for you help. Just make sure I understand what you saying. The IDE offers some cross compile settings, like: Prefix: arm-angstrom-linux-gnueabi- Path:/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/bin/armv5te-angstrom-linux-gnueabi. The reason why I add -I/usr/include is otherwise it will told me shared_memory_object.hpp: No such file or directory. And /usr/include is where the boost fold located in my system. – Peizheng Ma Jul 31 '15 at 14:40
  • Yes, it is wrong to use `/usr/include`. Either you have installed some ARM based headers in your `/usr/include` (and PC programs won't compile) or you have the wrong headers. As boost **can** be pure header files, this may work for that library/package. However, this is definitely the wrong way to do things. The ARM file system should have a separate development *usr/include* with a prefix like `/opt/angstromsdk-linux` or something like that. – artless noise Aug 04 '15 at 14:46

1 Answers1

0

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.

doqtor
  • 8,414
  • 2
  • 20
  • 36