I am moving a C++ project from Windows to Linux and I now need to create a build/make file. I have never created a build/make file before. I also need to include Boost libraries to make it more complicated. It must also be a makefile and I need to learn how to create makefile anyway, so CMake and SCON are out. IDEs are also out because of the use of Boost and all my IDEs (Eclipse, VS, etc.) are only on windows. I must generate a makefile from scratch.
So what are the basics of creating a Linux c++ make file and how to incorporate the Boost libraries in it to have it properly link?
So far, my makefile looks like this. I think CFLAGS
and LDFLAGS
are compiler and optimization options, but not totally sure.
CC = g++
CFLAGS = -wall -o3 - c
LDFLAGS = -03 -mfp-rounding-mode=n
I am offering a bounty because I am still very lost. In case anyone is feeling adventurous, I need to compile the following in linux
- simple_ls.h
- simple_ls.cpp
- 2dquicksort.h
- rawr.h
- rawr.cpp
- converter.cpp
The headers in simple_ls.h:
#include "boost/filesystem/operations.hpp"
#include "boost/filesystem/path.hpp"
#include "boost/lexical_cast.hpp"
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
The headers in 2dquicksort.h:
#include <stdio.h>
#include <ctype.h>
#include <iostream>
The headers in rawr.h:
#include <iostream> // not required by most systems
#include <fstream>
#include <iomanip>
#include <cstdlib> // or (stdlib.h) for exit()
#include <cmath>
#include <vector>
#include <limits>
#include <string>
An acceptable answer would be a step-by-step explanation of how makefiles work and how to build them with Boost in Linux without an IDE.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…