views:

1983

answers:

6

I have a project I'm working on (for school) that I'm digging into the Boost libraries for the solutions. I need some way to distribute the required Boost source code with my application so that it can be compiled without the libraries being installed on the system doing the compiling. (School computers lack just about anything you can mention. The school just installed CVS last year. But they do have VS2005)

Note: I'm using Visual Studio 2005 on Vista. I have Boost 1.34.1 on my system I used the automatic installer. The documentation I've come across says something about using BCP command but that command doesn't seem to copy anything. (I'm using absolute path to call BCP so I don't end up calling the wrong command.)

Edit: I am trying to use the RegEx libraries.

Edit: The command I'm using for BCP is: "c:\Program Files\boost\boost_1_34_1\bin\bcp.exe" boost/regex.hpp regex\

And it returns: no errors detected

+5  A: 

It depends on the library you're using. If you're using a header-only library (most of the boost libraries are, some notable exceptions are signals, serialisation and date/time) you can just copy those header files. Otherwise you'll need to copy the cpp files, too. My suggestion is to just include them into your project.

So, here's what you do: you remove the boost include path from your project settings (tool->options->projects and solutions->vc++ directories->include files). Try to compile. Look at which include fails. Copy that file from your boost directory to your project directory. Lather, rinse, repeat until your project compiles.

If you're using a library that requires .cpp files, you'll get an error at link time. Copy all .cpp files of the library you use to your project directory and add them all to your solution. Rebuild and cross fingers.

For a more detailed answer, please post which libraries you're using.

Roel
I am using the RegEx library.
epochwolf
A: 

I've come across this before, embedding boost into my projects. Each individual boost library comes with various project files for building with different make systems (Jam, make, Visual Studio 6...) but they're never so great with the newer versions of VS.

I always prefer to create a new project file and embed boost directly into my project. It's pretty simple, you just need to add all of the source files and set the project options properly. There is one caveat, however, and that is you must name the library output file the as boost does, because their include files depend on that.

Once you've done this, you can distribute the boost libraries just like any other files in your project.

Douglas Mayle
+1  A: 

This seems a bit odd to me. If you are distributing source code, then the people you are distributing to should be able to install boost. Then if they already have boost, there is no duplication and confusion, or if they do not and you need a built library, they will build the correct library for their system. If the people you are distributing are not up to installing boost, then I would suggest distributing binaries in an install package to make it as easy as possible for them.

ravenspoint
He's saying it's for a school project. People who grade assignments aren't going to install libraries for projects, they'd spend days fiddling with these libraries for all the different students. Assignments are usually required to be self-contained.
Roel
Roel has that correct. I need to embed the library with the rest of the source code.
epochwolf
+1  A: 

Try calling bcp with this command:

"c:\Program Files\boost\boost_1_34_1\bin\bcp.exe" --boost="c:\Program Files\boost\boost_1_34_1" regex regex

--boost tells bcp where boost is installed, the first regex is the name of the modules, the second is the destination directory.

Oh, and if you haven't already noticed, there are Visual C++ makefiles in libs\regex\build\.

Daniel James
Thanks, will try. If it makes any difference, I'm using standard C++, not Microsoft's extension to it.
epochwolf
+2  A: 

Based on your comment that you're using regex, here's what you do: download the 'normal' boost distribution zip file. Unzip it somewhere. Go to libs/regex/src. Copy and paste all the .cpp files in that directory to your project directory. Add them to your Visual Studio project (right-click, 'add' -> 'existing item'). Then go to boost/regex and copy everything in there (the header files) to your project directory (including the subdirectories). Change all the includes in your own .cpp and .h files from #include to "regex.hpp" so that it includes the headers from your local directory and not those that were installed system-wide. Make sure to remove the system-wide include path from your project settings like I said in my last post.

Then, compile your code. You'll get a number of 'missing include file' errors because regex depends on other boost libraries. Repeat the whole process: go to boost/xxx where xxx is the library that regex is looking for. You can deduce the library from the error message. Copy everything that the compiler asks for to your own project directory. You may need to fiddle a bit with your directory layout before it works. It's really a step by step approach, where every step is the same: identify the missing file, copy it over, see if that include is found and fixed, and continue with the next step. This is boring work I'm afraid.

You could automate this all with bcp but for a one-off project like a school project I wouldn't bother; only if you think you'll have future projects that will require you to deliver a self-contained zipfile.

Roel
I will probably be using Boost in future projects. The professor doesn't mind.
epochwolf
A: 

It is such a PITA to compile boost; only the motivated students are going to be able to do it. Have you considered bundling the installer?

Dustin Getz
I actually just dumped the pre-compiled debug libraries into the proper relative folder.
epochwolf
I've got a set of them on my website: http://boost.teeks99.com
teeks99