tags:

views:

49

answers:

1

I have a small project where I need just part of boost library, boost::regex in particular. This is what I've done so far:

/include
  /boost
    /regex
    /math
    .. 189 dirs, files, etc.
/lib
  /boost-regex
    c_regex_traits.cpp
    cpp_regex_traits.cpp
    .. ~20 .cpp files
myprog.cpp

In my Makefile I compile all boost-regex .cpp files one by one, producing .obj files. Next, I'm building my project by means of compiling myprog.cpp together with all that .obj files from /lib/boost/regex.

The question is whether I'm doing everything correct? The size of my output file is rather big (~3.5Mb), while my code is extremely small (10 lines).

ps. My compiler:

$ c++ —version
i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5659)
+2  A: 

Why not build regex library as a static lib and use it's features in your code by writing #include <boost/regex.hpp>?

This shouldn't affect the final size of your application, because compiler will take only those functions that are actually used in your app.

Also, precompiled boost libraries for different platforms can be found in the internet if you don't want to build them yourself. In that case what you have to do is just take the appropriate library and include the appropriate header.

Kotti