Opened 11 years ago

Closed 11 years ago

#38334 closed defect (fixed)

mongodb @2.2.3 unable to link with libmongoclient.a

Reported by: ralf@… Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone:
Component: ports Version: 2.1.3
Keywords: haspatch Cc: cawka (Alex Afanasyev)
Port: mongodb

Description

After updating to the current version of mongodb I'm unable to link my application with libmongodb.a

To make it reproducible I tried to compile the attached micro example (see x.cpp):

clang++ -I /opt/local/include/ -L /opt/local/lib -lboost_system-mt -l boost_filesystem-mt -lboost_thread-mt -lmongoclient x.cpp
Undefined symbols for architecture x86_64:
  "boost::filesystem2::detail::status_api(std::string const&, boost::system::error_code&)", referenced from:
...

When I compile the mongodb package I can see it compiles against an own version of boost - that is not compatible with the installed boost provided by macports. I copied this version and linked my example against this version - this worked but it is plain stupid. I read the comments about the incompatibility between mongodb and boost. So yes - I know there is a problem.

Anyway: Is there a supposed/supported way to actually use libmongoclient.a or is this file a mere placeholder currently? I could live with using an older version of boost for my application, I could even live with an older version of libmongodb - but a broken binary is way too hard to deal with.

Attachments (1)

x.cpp (344 bytes) - added by ralf@… 11 years ago.
micro example

Download all attachments as: .zip

Change History (11)

Changed 11 years ago by ralf@…

Attachment: x.cpp added

micro example

comment:1 Changed 11 years ago by ralf@…

all occurrences of "libmongodb.a" above are meant to be "libmongoclient.a" ;)

comment:2 Changed 11 years ago by mf2k (Frank Schima)

Owner: changed from macports-tickets@… to ryandesign@…

In the future, please Cc the port maintainer(s).

comment:3 in reply to:  2 Changed 11 years ago by ralf@…

Replying to macsforever2000@…:

In the future, please Cc the port maintainer(s).

Sorry for that.

comment:4 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

Apologies for this. I must admit I was unaware of the existence of libmongoclient.a or that using it required a copy of the same version of boost as was used to build mongodb.

Boost is one of those libraries that changes in major ways from version to version, and often in ways that break other software that uses it. So it seems common for developers to bundle a version of boost that works for them and to use that. In MacPorts we usually try not to use bundled libraries since usually it's a waste of time and disk space to build them when we already have working ports for those libraries, but boost seems to be an exception to the rule. I used to have the mongodb port using the MacPorts boost, but when boost was upgraded to version 1.50.0, mongodb no longer compiled, and I fixed it by using the bundled boost instead; see #35118 for more about that. In this specific case, the way that the boost upgrade broke mongodb is that mongodb uses the boost filesystem API version 2, and in version 1.50.0, after having been deprecated for several versions, filesystem v2 was finally removed, leaving only filesystem v3. Mongodb ticket 4314 tracks the need for the mongodb developers to port their code to boost filesystem v3. That ticket says it was fixed in October 2012 and will be included in mongodb 2.3.0.

So you could downgrade to boost 1.49.0 or older, or try a development version of mongodb, or encourage the developers to release version 2.3.0. Or we could see whether we can port that change back to mongodb 2.2.3 and include it in our port.

comment:5 Changed 11 years ago by ralf@…

I currently try to downgrade to boost 1.49.0 - this takes a minute as my internet connection currently is a bit bad. Thank you very much for the explanation.

comment:6 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

mongodb 2.4.0 was released, so updating the port to that version (#38445) should resolve this issue.

comment:7 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

Updated to 2.4.0 in r104216 but still using the bundled boost, which still seems to be version 1.49.0. Does it now work for you? It doesn't for me; your reproduction recipe above still fails for me, with the errors now referencing missing filesystem v3 symbols instead of missing filesystem v2 symbols. We could try to switch mongodb back to using MacPorts boost, now that mongodb is supposed to be compatible with boost filesystem v3. Presumably that would also speed up the mongodb build since it wouldn't have to build its own copy of boost.

comment:8 in reply to:  7 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: alexander.afanasyev@… added
Keywords: haspatch added

Replying to ryandesign@…:

We could try to switch mongodb back to using MacPorts boost, now that mongodb is supposed to be compatible with boost filesystem v3.

Duplicate #38900 has a patch to do this.

comment:9 Changed 11 years ago by cawka (Alex Afanasyev)

I see. I agree that it is possible that compilation can break again in the future (but hopefully API is getting more stable over time). At the same time, when mongodb is using internal boost libraries, there no point of installing the library, since it cannot be used. At least, I'm not sure how to make it work unless I manually get the source of mongodb, then extract the specific version of boost, then use this version to compile my custom code...

comment:10 Changed 11 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: fixed
Status: newclosed

Right, as I mentioned above, for your own code, you would have to use the same version of boost that mongodb uses, which was 1.49.0.

However, I have now made the change in r105531 along with updating mongodb to 2.4.3, so mongodb is now again using MacPorts boost and you should be able to use libmongoclient.a in your code using MacPorts boost. I tested the attached x.cpp and it now compiles.

Note: See TracTickets for help on using tickets.