You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by stephenju <st...@ju-ju.com> on 2011/11/07 05:18:25 UTC

Re: Static link ActiveMQ-CPP on Mac OS X

stephenju wrote:
> 
> I am trying to add ActiveMQ-CPP to my Mac OS X project. The goal is to
> static link everything into the app bundle.
> 
> I first installed MacPort and built and installed required parts. Then I
> built and installed ActiveMQ-CPP 3.4.0 with --enable-shared=false.
> Finally, I added all necessary static library files (.a) to my project and
> it compiled and linked without any error.
> 
> However, when I examine the resulted binary with otool, it lists all added
> static libs as dylib. For example:
> 
> Load command 13
>           cmd LC_LOAD_DYLIB
>       cmdsize 56
>          name /opt/local/lib/libapr-1.0.dylib (offset 24)
>    time stamp 2 Wed Dec 31 19:00:02 1969
>       current version 5.5.0
> compatibility version 5.0.0
> 
> That library was added to the project as libapr-1.a. Why is it still
> linked as dynamic lib? How do I get it to use static one?
> 
> Thanks.
> 
> BTW. This is on Mac OS 10.6 and Xcode 4.2.
> 

Funny. My post is shown as pending in the account and doesn't seems to be
synced to the mail list.

Anyway. I figure out the problem. All the dependent libraries actually come
with OS X 10.6. Also Xcode has this nasty habit of always using dynamic libs
if it finds one, even when a static .a file is specified. So uninstalling
all MacPort parts and rebuilding ActiveMQ-CPP with --enable-shared=false
created a static lib that references only system libs.

Unfortunately, this is not the end of my problem. The static lib links OK. I
tested with some sample code in my project and it also works. However, when
building with Xcode Release mode, it ends with linker error complaining bad
codegen and wrong offsets. I have to turn code optimization completely off
(-O0) to make it link.

This is beyond frustrating...

--
View this message in context: http://activemq.2283324.n4.nabble.com/Static-link-ActiveMQ-CPP-on-Mac-OS-X-tp3986182p3997445.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Static link ActiveMQ-CPP on Mac OS X

Posted by stephenju <st...@ju-ju.com>.
tabish121@gmail.com wrote:
> 
> Can you give the ActiveMQ-CPP 3.4.x branch in SVN a try, I have
> back-ported some fixes that may resolve this issue.
> 
> https://svn.apache.org/repos/asf/activemq/activemq-cpp/branches/activemq-cpp-3.4.x
> 
> Thanks.
> 
Thanks for the help. I ended up using dynamic libraries so I don't have to
deal with the compile options differences. But that's still not the end of
my problems. :(

My goal is the add CMS client functions to my existing project which is a
32-bit application bundle that needs to be able to deploy to OS X 10.5,
without installing anything to the users system. This means the application
must come with everything it needs.

The first issue is the build ActiveMQ-CPP library in 32-bit (i386). That's
not too hard since setting appropriate environment variables (CXXFLAGS &
friends) solves it. I'd like to have universal binaries (x86_64 and i386)
but it's not required yet. So I am fine.

Next I find out libapr-1 and libaprutil-1 that come with OS X 10.5 are not
compatible with ActiveMQ-CPP. The 10.6 ones are fine, but not the 10.5 ones.
So I had to build them from sources. And rebuild ActiveMQ-CPP to use my
copies of them. That is actually not too painful once I figured out where to
put everything. The point is, don't install them to the system. Not even
ActiveMQ-CPP. Use --prefix with all of them. Or Xcode will still link the
system provided ones.

Then the built libraries turn out to be using LC_DYLD_INFO command which is
not available in OS X 10.5. That rendered my app un-deployable. I finally
figured out the solution by adding "-isysroot /Xcode3/SDKs/MacOSX10.5.sdk
-mmacosx-version-min=10.5" to the various FLAGS variables. Again, rebuild
everything from scratch.

Finally, the 3 dylibs copied into my app bundle need to be changed with
install_name_tool so they can be loaded from within the bundle instead of my
development locations.

And it works!!! Well. The example code works. We'll see how it actually
works in the real code.

I may try static linking with the SVN branch later. After I recover from
this trauma... :)

--
View this message in context: http://activemq.2283324.n4.nabble.com/Static-link-ActiveMQ-CPP-on-Mac-OS-X-tp3986182p4016462.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Static link ActiveMQ-CPP on Mac OS X

Posted by "tabish121@gmail.com" <ta...@gmail.com>.
Can you give the ActiveMQ-CPP 3.4.x branch in SVN a try, I have back-ported
some fixes that may resolve this issue.

https://svn.apache.org/repos/asf/activemq/activemq-cpp/branches/activemq-cpp-3.4.x

Thanks.

--
View this message in context: http://activemq.2283324.n4.nabble.com/Static-link-ActiveMQ-CPP-on-Mac-OS-X-tp3986182p4016377.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.