[mongo-cxx-driver][legacy-0.0-26compat-2.6.2] Undefined reference to mongo::Date_t util

74 views
Skip to first unread message

Matthieu Corbeau

unread,
Jul 2, 2014, 9:19:07 AM7/2/14
to mongod...@googlegroups.com
Hi all,

this is possibly a duplicate as I don't know what happened with my previous version, so sorry if it is.

So, since I move to the late stable mongo c++ driver release (legacy-0.0-26compat-2.6.2), I have undefined references to 'mongo::Date_t::[...]() const' :
 undefined reference to `mongo::Date_t::toString() const'
 undefined reference to `mongo::Date_t::toTimeT() const'

Does any body had this linking issue ? Cannot quite manage to solve it at the moment.. 

Andrew Morrow

unread,
Jul 2, 2014, 10:30:25 AM7/2/14
to mongod...@googlegroups.com

Hi -

What driver version were you using previously where this worked? Also, can you provide additional information describing your platform, toolchain, driver build, etc? See this wiki link for details on what information to provide so we can best help you:


Thanks,
Andrew




--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/ce939262-bac0-4c06-8b72-94576e60608b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matthieu Corbeau

unread,
Jul 2, 2014, 11:20:53 AM7/2/14
to mongod...@googlegroups.com
Hi Andrew,

thanks, yeah sorry of course you need more info :
  • branch: 26compat
  • tag: legacy-0.0-26compat-2.6.2
  • host: ubuntu 12.04 LTS
  • c++ compiler: g++ (Ubuntu/Linaro 4.6.4-1ubuntu1~12.04) 4.6.4
  • boost: 1.55.0
  • scons invocation: sudo scons --prefix=/var/lib/backend --libpath=/var/lib/backend/lib --cpppath=/var/lib/backend/include --extrapath=/var/lib/backend --full --use-system-boost --sharedclient
There is no compilation error on the library as I said previously, I joined herewith the result of the configuration phase (scons.log).

So a little example (test_mongo_date.cc):
#include <mongo/bson/bson.h>

int main()
{
    mongo::Date_t date_l;
    date_l.toTimeT();

    return 0;
}

Compiled with:
g++ -I/var/lib/backend/include -L/var/lib/backend/lib -o test_mongo_date test_mongo_date.cc -lmongoclient -lboost_system

Results in a linking issue:
/tmp/ccjOTidh.o: In function `main':
test_mongo_date.cc:(.text+0x1c): undefined reference to `mongo::Date_t::toTimeT() const'
collect2: ld returned 1 exit status


Any clue from there ?
scons.log

Andrew Morrow

unread,
Jul 2, 2014, 11:38:09 AM7/2/14
to mongod...@googlegroups.com

Hi Matthieu -

Thanks for providing the additional info. The problem is that the Date_t type is not marked MONGO_CLIENT_API in the 26compat branch. When linking to a shared library version of mongoclient, only symbols tagged with MONGO_CLIENT_API are exported from the shared library. Since Date_t lacks such an annotation, the symbols are not externally visible, and your application can't link.

The easiest workaround would be to link to a static library version of the C++ driver if you must use these Date_t functions. Please note that if you chose to do this, you need to build your application with -DSTATIC_LIBMONGOCLIENT. Another possibility would be to avoid using Date_t.

On the legacy branch we have added the MONGO_CLIENT_API tag to Date_t and other functions in time_support.h as part of fixing https://jira.mongodb.org/browse/CXX-150 (see the pull request linked in the ticket).

We are very conservative about making changes to the 26compat branch since it is intended to be as close as possible to a 1:1 copy of the C++ driver as it would exist in the main mongodb 2.6 repository. If using the static library on 26compat is not an option for you though, do feel free to comment on CXX-150 and request that we backport the fix to the 26compat branch. As the change is simply to apply some missing annotations, it is a fairly safe backport.

This issue will be resolved in the upcoming stable legacy-1.0.0 release, which is currently slated for release later this summer.

Thanks,
Andrew








--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.

Matthieu Corbeau

unread,
Jul 2, 2014, 12:16:38 PM7/2/14
to mongod...@googlegroups.com
Han, ok thanks Andrew.

I have been looking at the pull request 42 and it effectively look like a very minor fix. Do you think I have any chance to see it accepted in a week or two or should I just start doing hacks in my integration process to handle the static library in case I am using 'mongo::Date_t::toTimeT() const' ?

Thanks for your quick reply !!

Andrew Morrow

unread,
Jul 2, 2014, 12:31:51 PM7/2/14
to mongod...@googlegroups.com

I agree, I think its fine to backport. I've filed https://jira.mongodb.org/browse/CXX-268 and slated it to be fixed for the upcoming 26compat-2.6.3 release. That release is currently listed as going out tomorrow, but Monday is more likely.



--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.

Matthieu Corbeau

unread,
Jul 2, 2014, 5:40:19 PM7/2/14
to mongod...@googlegroups.com
Awesome ! Lets see if it is shipped with 26compat-2.6.3 then !

Matthieu Corbeau

unread,
Jul 7, 2014, 4:03:07 AM7/7/14
to mongod...@googlegroups.com
Let me know if I can be of any help for the backport today ? Thanks

Andrew Morrow

unread,
Jul 7, 2014, 9:49:27 AM7/7/14
to mongod...@googlegroups.com

Hi Matthieu -

The PR with the proposed backport is up: https://github.com/mongodb/mongo-cxx-driver/pull/116/files

If you could test it and let us know if it resolves your issue with the shared library build we would appreciate it. We are hoping to release 26compat-2.6.3 today.

Thanks,
Andrew




On Mon, Jul 7, 2014 at 4:03 AM, Matthieu Corbeau <matthieu...@gmail.com> wrote:
Let me know if I can be of any help for the backport today ? Thanks

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.

Matthieu Corbeau

unread,
Jul 7, 2014, 10:05:31 AM7/7/14
to mongod...@googlegroups.com
Totally works for me ! Thank you very much !!!

Andrew Morrow

unread,
Jul 7, 2014, 8:14:45 PM7/7/14
to mongod...@googlegroups.com

Hi Matthieu -

We just released legacy-0.0-26compat-2.6.3 which contains the fix.

Thanks,
Andrew



On Mon, Jul 7, 2014 at 10:05 AM, Matthieu Corbeau <matthieu...@gmail.com> wrote:
Totally works for me ! Thank you very much !!!

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
Reply all
Reply to author
Forward
0 new messages