Boost logo

Boost Users :

Subject: Re: [Boost-users] NEWBIE: Undefined references: How do I find the library that resolves an undefined reference - Expanded with log example and hope for a general solution
From: Michael Chisholm (chisholm_at_[hidden])
Date: 2017-01-25 21:32:39


On 1/25/2017 12:45 PM, JENNINGS, LYNN M NH-03 USAF AFMC 517 SMXS/MXDPB
wrote:
> Thanks Richard and Andy for the timely response! Andy's answers provides the perfect example of my dilemma. When Andy said to check the MSDN documentation for ms742213, I quickly found that I needed the Ws2_32.lib library, which I was able to solve my issue. However, I also have the following:
>
> 1. boost::log::add_log_file(...) with a sinks::file::rotation_at_time_point(...)
> 2. boost::random::random_device range;
>
> I made a guess with the log and added boost_log_setup_mgw48-mt-d-1_61 and boost_log_ mgw48-mt-d-1_61, but these libraries didn't resolve my issue. When I check the boost documentation (I realize that many of the boost additions just require header files, which the examples are careful to specify. I figure this must require a library because I am getting an undefined error.), there were many mentions of a library, but I couldn't find where the name of the library was specified!
>
> So I hope there is a general way to determine the name of the boost library so I do not need to keeping asking about particular undefined errors. In the past, I have been able to google the undefined error and find the library reference, but
>
> Thanks again for all of your help!
>

I see you're using MinGW-built libraries. MinGW comes with some tools
that might help you. So this isn't boost-specific advice, but more general.

Have you tried some of the relevant MinGW tools? I found some old
MinGW-built boost libs lying around, and the following worked to show me
exports. From a MinGW shell:

   $ nm -Cg ./libboost_log-mgw48-mt-1_54.dll

that dumped a ton of info to the console. You can filter using 'grep'
to search for things:

   $ nm -Cg ./libboost_log-mgw48-mt-1_54.dll | grep rotation_at_time_point

One of the entries I got was:

00000000653d4f00 T
boost::log::v2_mt_nt5::sinks::file::rotation_at_time_point::rotation_at_time_point(unsigned
char, unsigned char, unsigned char)

(it's one of several overloads.) If someone suggests an easier way of
matching up boost symbols to DLLs, great, but if you have nothing else,
this can help. (There some other similar tools too, but hopefully 'nm'
will work.)

Additionally, with gcc, order of libraries given on the commandline
matters. If you get it wrong, then even if the symbol you need is in
the DLL, and the DLL is on your commandline, you'll get the linker
error. Dependent libraries should always come before their dependencies.

Hope this helps,
Andy


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net