Re: Boost-users Digest, Vol 5315, Issue 1

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Boost-users Digest, Vol 5315, Issue 1

Boost - Users mailing list
@Gavin @Edward: 

Success! The program is now executing as expected, thanks to all of your helpful suggestions.

Here's what I did:
1. added --with-chrono to my b2 command, which placed .a and .dylib files for chrono in stage/lib.
2. after invoking the following compiler command:

g++ -v -Wall -L ${BOOST_ROOT}/stage/lib -lboost_chrono -lboost_date_time -lboost_system -lboost_system -I${BOOST_ROOT} -o main main.cpp

I added to my RPATH using install_name_tool:

sudo install_name_tool -add_rpath ${BOOST_ROOT}/stage/lib main


This command appends to the RPATH (@rpath), which is used by LC_LOAD_DYLIB to locate shared library dependencies for the executable. 

After executing these two commands, my program runs successfully! Thank you. However, the learning never ends. That said, I have a bit of an unrelated follow-up question if that is okay. If not, feel free to shun me and I will look elsewhere for an answer.

Running these two commands from my terminal is painful and tedious. For troubleshooting, I don't mind, but I want to move toward automation.

1. I tried putting these two commands into a simple script. When I ran the script, main could not be found. How would I ensure that the main executable from the g++ invocation is outputted into the cwd before the install_name_tool command is executed?

The script I wrote here is just for the sake of experimentation and learning. Ideally, I would use a build tool (i.e. make) for this sort of thing, which I am actually reading about right now.

It should be okay to close this issue after my last question is answered/shunned.

Thanks again for all of your helpful suggestions, I am starting to like this community already.

- AJ


On Fri, Jan 31, 2020 at 4:01 AM <[hidden email]> wrote:
Send Boost-users mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.boost.org/mailman/listinfo.cgi/boost-users
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Boost-users digest..."


Today's Topics:

   1. [Newbie][Interprocess] Placing a boost interprocess vector in
      an existing (not managed) shared memory (Gaier, Bjoern)
   2. Re: [Boost.Asio] tutorial #1 code does not compile (g++)
      (Andrew McFarlane)
   3. Re: [Boost.Asio] tutorial #1 code does not compile (g++)
      (Edward Diener)
   4. Re: [Boost.Asio] tutorial #1 code does not compile (g++)
      (Gavin Lambert)


----------------------------------------------------------------------

Message: 1
Date: Thu, 30 Jan 2020 08:19:02 +0000
From: "Gaier, Bjoern" <[hidden email]>
To: "[hidden email]" <[hidden email]>
Subject: [Boost-users] [Newbie][Interprocess] Placing a boost
        interprocess vector in an existing (not managed) shared memory
Message-ID:
        <[hidden email]>

Content-Type: text/plain; charset="iso-8859-1"

Hello Boost-Mailing-List,

I have a question about the boost interprocess library - and I hope I can explain it correctly.

I looked at the "Quick guide for the impatient" about the interprocess library - but I'm not sure if I can use this for our purpose.
The main goal is to insert a STL vector (or different container) in a predefined portion of an already existing shared memory. The main problem is, that we cannot use the managed_shared_memory code from boost, because we rely on a different API to allocate the shared memory between Windows and other devices. Also the container should be placed at a fixed offset inside the created shared memory.

I'm a complete newbie with boost and the interprocess library, that is why I'm not sure which interface I have to provide for the interprocess vector to be setup correctly. I hoped I could do something like:

new (srh_mem_base + offset) boost::interprocess::vector<allocator>;

I tried looking into the headers of the library to get an idea of that, but I honestly got lost.

I'm really sorry if this a stupid or obvious question - and I thank for any help in advance!

Kind greetings
Bj?rn
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Gesch?ftsf?hrer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Takashi Nagano, Takeshi Fukushima. Junichi Tajika
-------------- next part --------------
HTML attachment scrubbed and removed

------------------------------

Message: 2
Date: Thu, 30 Jan 2020 14:35:34 -0800
From: Andrew McFarlane <[hidden email]>
To: Boost users list <[hidden email]>
Cc: Richard Hodges <[hidden email]>, [hidden email]
Subject: Re: [Boost-users] [Boost.Asio] tutorial #1 code does not
        compile (g++)
Message-ID:
        <CAG90r9Q5y=Wz1hKPfX9MYpRCobLX0k=[hidden email]>
Content-Type: text/plain; charset="utf-8"

Okay, so I have made a bit of progress. After building Boost.Asio with:

b2 --with-system --with-thread --with-date_time --with-regex
--with-serialization stage

, and building Boost.Chrono with (replacing bjam with b2):

bjam libs/chrono/build

The code is now compiling with the following g++ command:

g++ -v -Wall -L ${BOOST_ROOT}/stage/lib -L
${BOOST_ROOT}/bin.v2/libs/chrono/build/clang-darwin-11.0/debug/threading-multi/visibility-hidden
-lboost_chrono -lboost_date_time -lboost_system -I. -I${BOOST_ROOT} -o main
main.cpp

However, when I go to run main, the program crashes with the following
message:

dyld: Library not loaded: @rpath/libboost_chrono.dylib

  Referenced from: /Users/ajm/Projects/boost-threads/ex1/./main

  Reason: image not found

Abort trap: 6

I suspect that there is something wrong with the Boost.Chrono dynamic
library file that was built (probably because of how I built it), but I am
not sure what it would be. Any suggestions?

Thanks,


*Andrew J. E. McFarlane*
-------------- next part --------------
HTML attachment scrubbed and removed

------------------------------

Message: 3
Date: Thu, 30 Jan 2020 18:33:15 -0500
From: Edward Diener <[hidden email]>
To: [hidden email]
Subject: Re: [Boost-users] [Boost.Asio] tutorial #1 code does not
        compile (g++)
Message-ID: <r0vp3r$23nj$[hidden email]>
Content-Type: text/plain; charset=utf-8; format=flowed

On 1/30/2020 5:35 PM, Andrew McFarlane via Boost-users wrote:
> Okay, so I have made a bit of progress. After building Boost.Asio with:
>
> b2 --with-system --with-thread --with-date_time --with-regex --with-serialization stage
>
> , and building Boost.Chrono with (replacing bjam with b2):
>
> bjam  libs/chrono/build
>
> The code is now compiling with the following?g++ command:
>
> g++ -v -Wall -L ${BOOST_ROOT}/stage/lib -L
> ${BOOST_ROOT}/bin.v2/libs/chrono/build/clang-darwin-11.0/debug/threading-multi/visibility-hidden
> -lboost_chrono -lboost_date_time -lboost_system -I. -I${BOOST_ROOT} -o
> main main.cpp
>
> /
> /
> However, when I go to run main, the program crashes with the following
> message:
>
> dyld: Library not loaded: @rpath/libboost_chrono.dylib
>
> Referenced from: /Users/ajm/Projects/boost-threads/ex1/./main
>
> Reason: image not found
>
> Abort trap: 6
>
> /
> /
> I suspect that there is something wrong with the Boost.Chrono dynamic
> library file that was built (probably because of how I built it), but I
> am not sure what it would be. Any suggestions?

Lookup RPATH for Linux.



------------------------------

Message: 4
Date: Fri, 31 Jan 2020 14:13:20 +1300
From: Gavin Lambert <[hidden email]>
To: [hidden email]
Subject: Re: [Boost-users] [Boost.Asio] tutorial #1 code does not
        compile (g++)
Message-ID: <[hidden email]>
Content-Type: text/plain; charset=utf-8; format=flowed

On 31/01/2020 11:35, Andrew McFarlane wrote:
> Okay, so I have made a bit of progress. After building Boost.Asio with:
>
> b2 --with-system --with-thread --with-date_time --with-regex --with-serialization stage
>
> , and building Boost.Chrono with (replacing bjam with b2):
>
> bjam  libs/chrono/build

You could have just added --with-chrono to the first command.

> The code is now compiling with the following?g++ command:
>
> g++ -v -Wall -L ${BOOST_ROOT}/stage/lib -L
> ${BOOST_ROOT}/bin.v2/libs/chrono/build/clang-darwin-11.0/debug/threading-multi/visibility-hidden
> -lboost_chrono -lboost_date_time -lboost_system -I. -I${BOOST_ROOT} -o
> main main.cpp

You should not link with libs directly in bin.v2; use the stage/lib
directory instead.

(They're not different, it's just that the bin.v2 path is fragile.)

> However, when I go to run main, the program crashes with the following message:
>
> dyld: Library not loaded: @rpath/libboost_chrono.dylib
>
>   Referenced from: /Users/ajm/Projects/boost-threads/ex1/./main
>
>   Reason: image not found
>
> Abort trap: 6

You either need to tell your compiler to use the static libraries (it
usually defaults to using dynamic libraries), or you need to set the
RPATH at compile time to the (absolute path of the) stage/lib folder, or
the LD_LIBRARY_PATH when you run the app (less preferred).

Or use the system-provided libraries instead, which will Just Work?
without any of this.


------------------------------

Subject: Digest Footer

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users


------------------------------

End of Boost-users Digest, Vol 5315, Issue 1
********************************************

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users