[CXX-127] OID::init and mongo::jsTime unresolved in shared client (.so) Created: 09/Mar/14  Updated: 10/Apr/14  Resolved: 11/Mar/14

Status: Closed
Project: C++ Driver
Component/s: None
Affects Version/s: legacy-0.0-26compat-2.6.0-rc1
Fix Version/s: legacy-0.0-26compat-2.6.0-rc2

Type: Bug Priority: Blocker - P1
Reporter: Pieter Willem Jordaan Assignee: Andrew Morrow (Inactive)
Resolution: Done Votes: 0
Labels: legacy-cxx
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux 3.11.0-17-generic #31-Ubuntu SMP Mon Feb 3 21:52:43 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

sudo scons -j 4 --ssl --sharedclient --use-system-boost --extrapath=/usr/local --full


Issue Links:
Related

 Description   

Building an application with the shared client leaves all the symbols from OID.cpp unresolved. Not sure where mongo::jsTime() is defined, but that is also unresolved for my build. I am using the git tag for legacy-0.0=26compat-2.6.0-rc1, but the same also happens for the legacy branch.

When linking with the static library, I do not see this behaviour.



 Comments   
Comment by Mira Carey [ 12/Mar/14 ]

Found some evidence for a long time bug with MSVC (you can't have multiple static variables declared in a single statement in a class with dllimport or dllexport)

http://support.microsoft.com/kb/127900

Comment by Githook User [ 12/Mar/14 ]

Author:

{u'username': u'acmorrow', u'name': u'Andrew Morrow', u'email': u'acm@mongodb.com'}

Message: CXX-127 Work around C2487 error with MSVC
Branch: legacy
https://github.com/mongodb/mongo-cxx-driver/commit/014bb985eec5b7e8b5826f7cc54237502bb268b3

Comment by Andrew Morrow (Inactive) [ 10/Mar/14 ]

https://github.com/mongodb/mongo-cxx-driver/pull/18

Comment by Andrew Morrow (Inactive) [ 10/Mar/14 ]

Thanks, we will be sure to pick up the OID stream operator when we apply export macros in oid.h.

Comment by Pieter Willem Jordaan [ 10/Mar/14 ]

Thank you, I am looking forward to the fix. I have one more symbol: undefined reference to `mongo::operator<<(std::ostream&, mongo::OID const&)'. This will fix it for me, but as you mentioned, there may be others as well which could cause unresolved symbols.

Thanks

Comment by Andrew Morrow (Inactive) [ 10/Mar/14 ]

Hi Pieter-

Yes, the object files contain the symbols, but the symbols have not had _attribute_((visibility("default"))) (or the windows equivalent) applied to them as they should, so they cannot be used by consumers of the shared library which is built so that symbols default to being hidden (-fvisibility=hidden).

We will add the necessary MONGO_CLIENT_API macros to the symbols you identified for rc2 which will make them available. It works in the static library because symbol visibility is not in play.

There are likely to be other instances of this same problem, so if you encounter any please do not hesitate to file tickets.

Comment by Pieter Willem Jordaan [ 10/Mar/14 ]

mongo::OID packet_oid;
packet_oid.init();

This snippet brings the OID::init symbol problem. The jsTime symbol comes from the usage of the label. The symbol is defined in time_support.cpp

mongo::DATENOW

What strikes me baffled is that the object files after the build contain the symbols. The static library (.a) contains them as well (as it is the archive of all the object files). The .so, however, does not contain those symbols.

I am willing to help with debugging and testing

Generated at Wed Feb 07 21:58:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.