There was a problem with compiling python so today--linking the other C libraries to the same so--and trying to find the method in the morning, has been updated to the second section of this series.
Organized a list of projects, planning to use SCons management.
SCons, after all, is a new build tool, certainly a lot more progress than makefile, at least more clearly studious, less dizzy trick. But compared to other advanced tools such as CMake, it is not clear that the pros and cons.
This example is too simple to write, the normal use of env, you can unify parameters, simplified writing.
Example:
Obj = Object ("test.c", cpppath=["xxx"], cflags=["-G"]) Obj2 = Object ("main.cc", cpppath=["xxx"], cflags=["-G", "-std=c++ "]) Program (" Out_exe ", [obj, Obj2], libs=[" DL "], linkflags=["-pthread "])
Note that this example mixed with C source and CPP source code, SCons will use GCC and g++ respectively processing.
It is worth saying that the code part of the pure C language needs to be completely wrapped up with the following code.
#ifdef __cplusplus
extern "C" {
#endif
C code
#ifdef __cplusplus
}
#endif
mixed with C and CPP to write the reason is: with DLFCN library operation so, obviously C language will be more convenient, C language void* type, with a certain dynamic language characteristics, very easy to use, conversion is also basic will not be reported warning. The same code with g++ difficult to compile the past, to rewrite the law.
Python's source code is also written in C, with C calls relatively easy.
However, it is intended that the network library with Raknet,raknet is a large library written using the CPP feature.
So it's hard to use C and CPP, the code for Python and so is C-style, and most of the underlying logic and network parts are in C + +.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Meme Game server Development Diary (iv) scons compilation tools, C and C + + mixed use