0

I'm using the ASIO libraries to make a udp sending wrapper. The intent is for this to be used by another app to easily send 3 specific udp messages.

I've created a .lib file which is basically an exported utility class that wraps the ASIO functions.

To test my lib I also made a little command line app which links to my lib, creates the exported class and calls the send function.

However, the test application is requiring to link to libboost_system-vc100-mt-gd-1_55.lib but the lib file I created which actually contains the Boost code does not.

Why is this happening and how can I fix this?

TheZapper
  • 122
  • 2
  • 10

3 Answers3

2

A .lib file, static library, is just a grouping of object files, it's not an executable entity. It isn't linked thus it doesn't require it's unresolved symbols to be resolved. Only the executable or shared library (DLL) that link with it need the dependencies (in this case your test code).

So there's no problem, perhaps you meant to bundle your library as a shared library rather than a static library?

Motti
  • 110,860
  • 49
  • 189
  • 262
  • Yes, Thanks Motti. I changed it to a dll and ithe test app works as I expected. For some reason I was thinking that the lib file I created would compile/copy in the code used from the boost libraries and that would be passed on to the application using it. – TheZapper Feb 15 '16 at 19:02
0

Most of the boost libraries rely on boost::system because of the exception/error management is used.

boost::asio definitely uses that.

A test runner application needs to link everything as it's going to be a (statically or dynamically linked) executable, and all of the references need to be resolved.

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
0

The Boost::Asio library is available (from the same author) as a header-only standalone version.

See his think-async.com website for details, and comparison. The standalone version is useful when you do not need (or want) to have a link-time depedency on Boost. More details are on the AsioStandalone page.

FWIW I bundled this for use by R programmers as CRAN package AsioHeaders because the 'no linking' feature makes the cross-platform use particularly appealing.

You could similarly provide header-only solution for your application.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725