Reputation: 1
Gooday everyone
I'm fairly new to ubuntu C programing although I'm rather experienced in C programing in windows.
I have recently come accross a number of codes written in 2005 which I'm interested in learning how they work.
Those codes needs BOOST library to compile, however they won't compile on the newest BOOST version present on my ubuntu 12.04. I set the gcc compiler on lenient so that it ignores all those error messages. The code did compile and ran afterwards.
However, when I used GDB debugger to watch how the program flows I noticed that there are likely errors in the way the program runs due to using a different BOOST version rather than it's original. Hence I like to install the BOOST version corresponding to the code I downloaded.
To do that, I installed Ubuntu 5.04 and BOOST 1.33.0 which seemed to have been created in late 2005. I downloaded it but I didnt found any detailed instruction on how to install it. Only vague description on using BOOST jam, I played around with BOOST jam for quite awhile without success. And this old BOOST does not have installation commands like "sudo apt-install boost-dev" style option
Thus I like to ask if anyone can give a easy to understand step by step instruction on how to install the BOOST library downloaded from the above link. like.....
...and so on...
Big thanks for any useful info.
New Contents appended here in response to the comments given
Hi, I went through the info given by your link and managed to run the boost library examples given by your link. That is, I can compile a single cpp file with the command
g++ -I boost_1_33_0 test.cpp -o test
(I'm keeping the boost library and the cpp file to be compiled in the same folder)
However, the program package I'm interested in is build with make (not cmake). I have some experience writting cmake files but not make files. And I do not see any link to boost library command in the make file of the program package. The readme file only has one sentence that says I need to have boost installed without explaining what that meant.
I assume it means that either I have to build and do makeinstall the boost or I could add some lines in the makefile for a link. I thought maybe you can quickly point out whats missing in the makefile.
The readme file:
To compile, go into the moses directory and do 'make'. You'll need the latest boost libraries. If compilation still fails for weird reasons, you could try g++ with the -fpermissive (newer versions reject lots of code that was ok with older ones). If you are going to be making changes and recompiling frequently you'll probably want to disable -O3 in the makefile (I use templates liberally, so -O3 really speeds up the code, but really slows down compilation).
And the makefile:
CC = g++
PROJ_NAME = moses
LINK_FLAGS = -Wall -Iutils/ -Itrees/ -Irewrite -I./ -Imodeling/ -Ifitness/ \
-Ialignment/ -Isim/ -Ilocal/ -O3
COMP_FLAGS = -Wall -Wno-sign-compare -Iutils/ -Itrees/ -Irewrite -I./ \
-Imodeling/ -Ifitness/ -Ialignment/ -Isim/ -Ilocal/ -O3
src := $(wildcard *.cc) $(wildcard utils/*.cc) $(wildcard trees/*.cc) $(wildcard modeling/*.cc) $(wildcard fitness/*.cc) $(wildcard alignment/*.cc) $(wildcard main/*.cc) $(wildcard rewrite/*.cc) $(wildcard sim/*.cc) $(wildcard local/*.cc)
obj := $(patsubst %.cc,%.o,$(src))
all: $(PROJ_NAME)
%.o: %.cc
$(CC) $(COMP_FLAGS) $< -c -o $@
$(PROJ_NAME): $(obj)
$(CC) $(LINK_FLAGS) $^ -o $(PROJ_NAME)
run:
$(PROJ_NAME)
clean:
find -regex ".*~\|.*\.o"|xargs rm -f
rm -f $(PROJ_NAME)
rm -f $(PROJ_NAME).exe*
depend:
makedepend -Y -- $(COMP_FLAGS) -- $(src)
utils/exceptions.o: utils/exceptions.h utils/utils.h
utils/io_util.o: utils/io_util.h utils/tree.h utils/basic_types.h
# ......lots more lines like that.........
Upvotes: 0
Views: 280
Reputation: 70213
I have an old instruction flying around here for Boost 1.34.1, which reads like this (project-specific stuff cut away):
cd
into tools/jam/src
./build.sh
to build bjam
cd
into the main source directorytools/jam/src/bin.linux/bjam threading=multi --layout=system --toolset=gcc --without-python variant=release --prefix=/usr/local install
The --without-python
was necessary as the target system didn't have Python installed, which caused the build to fail messily.
Obviously you can / need to fiddle with the individual settings (like threading support, release vs. debug variant) to suit your needs, but it should be a good starting point.
If you need ICU support (for Boost.Regex and Boost.Locale), it gets more complicated...
Note that the build process has changed over the years; you shouldn't use the same procedure for more up-to-date boost versions. It's just what I used back then.
Edit:
As for the second part of your question, the Makefile doesn't need to refer to Boost explicitly if boost is installed in the standard system directories.
You do not have to state -I /usr/include
for compilation as that is searched automatically; the same goes for -L /usr/lib
during linkage.
The fact that the author of the Makefile copied the compiler flags into the linker flags verbatim doesn't really help intuitivity either... ;-)
If you have Boost in a custom directory (either the headers only, or by stating a custom directory in the --prefix
option of my build instructions), you need to make the following modifications (look for "boost"):
LINK_FLAGS = -Wall -Iutils/ -Itrees/ -Irewrite -I./ -Imodeling/ -Ifitness/ \
-Ialignment/ -Isim/ -Ilocal/ -L /path/to/boost/libs -O3
COMP_FLAGS = -Wall -Wno-sign-compare -Iutils/ -Itrees/ -Irewrite -I./ \
-Imodeling/ -Ifitness/ -Ialignment/ -Isim/ -Ilocal/ \
-I /path/to/boost/includes -O3
That should do the trick. As the Makefile does not link any of the Boost binaries (e.g. -l boost_program_options
or somesuch), it seems that it makes use of the Boost headers only, which would make the -L /path/to/boost/libs
part (and, actually, the whole compilation step detailed above) superfluous. You should be able to get away with simply unpacking the sources and giving the header directory as additional include directory using -I /path/to/boost/headers
.
Upvotes: 1