This period of time used to SCons, summed up here, but also convenient for me to consult later.
I. Installation of SCons
Linux Environment (take CentOS as an example)
1, yum Installation
Yum Install SCons
2, the source code installation
Download Scons:http://http://jaist.dl.sourceforge.net/project/scons/scons/2.3.0/scons-2.3.0.zip
Install Scons:python setup.py Install
Second, scons Common command
Scons-c: You can clear the generated temporary and destination files, which is equivalent to making clean.
SCONS-Q: Less output information will be generated.
Three, SCons use example
1. Compiling executable files
Use the program function to compile an executable file.
1.1 Single File Mode
1.1.1 Write program code
Establish the document TEST.C, which reads as follows:
Copy Code code as follows:
#include <stdio.h>
int main ()
{
printf ("Just a test!\n");
return 0;
}
1.1.2 Write Sconstruct Code
The contents are as follows:
Copy Code code as follows:
1.1.3 Compile Program
Execute the scons command to compile with the following effect:
1.2 Multiple file modes
1.2.1 Write program code
Test1.h file:
Copy Code code as follows:
#include <stdio.h>
void Fun11 ();
test1.c file:
Copy Code code as follows:
#include "Test1.h"
void Fun11 ()
{
printf ("fun11\n");
}
TEST2.C file:
Copy Code code as follows:
#include "Test1.h"
int main ()
{
Fun11 ();
return 0;
}
1.2.2 Write sconstruct Code
The contents are as follows:
Copy Code code as follows:
Program (' Test ', [' test1.c ', ' test2.c '])
Or:
Copy Code code as follows:
Program (' Test ', Glob (' *.c '))
1.2.3 Compile Program
Executes the scons command to compile.
1.3 Dependence
1.3.1 Link Library
The syntax example is as follows:
Copy Code code as follows:
Program (' Test ', [' test1.cpp '],libs=[' boost_system ', ' boost_thread-mt '], libpath= '/usr/lib64 ')
1.3.2 contains libraries
The syntax example is as follows:
Copy Code code as follows:
Program (' Program ', Glob (' *.c '), cpppath= '/home/admin/inc ')
2. Compile the static library
The syntax example is as follows:
Copy Code code as follows:
Library (' Libtest1 ', [' test1.c '])
3. Compile Dynamic Library
The syntax example is as follows:
Copy Code code as follows:
Sharedlibrary (' Libtest1 ', [' test1.c '])
Third, other
Resources
(1) scons homepage: http://www.scons.org/
(2) SCons document: http://www.scons.org/documentation.php