For how to use scons to build a project, refer to quickly build C ++ project tool scons and build a development environment with editplus.
When the sharedlibrary project is compiled, Lib is automatically added when the so file is produced. For example:
env = Environment()env.SharedLibrary(‘hello‘, sources=[‘hello.c‘])
Save the above as build. py and execute the compilation command
scons -f build.py
The file name libhello. So of the dynamic library so is generated. The benefits of doing so are needless to say. This lib prefix is not suitable for all situations. Writing this essay is also caused by the absence of the Lib prefix.
According to the module rules, the entry function of the dynamic library must be "init + Module name ", the automatically generated dynamic library must also be consistent with the module name. The file name generated by the scons sharedlibrary build tool naturally has an additional "lib" prefix, for example: libhello. so. An error occurs when the import Hello syntax of the Python script file is used.
I have found a lot of articles for tutorials. I can only find the scons source code.$ ShlibprefixUse the dump method of env to view the scons environment variable.
env = Environment()print env.Dump()
[[email protected] xxx]# scons -f hello.py |grep LIBPREFIX ‘LDMODULEPREFIX‘: ‘$SHLIBPREFIX‘, ‘LIBPREFIX‘: ‘lib‘, ‘LIBPREFIXES‘: [‘$LIBPREFIX‘], ‘SHLIBPREFIX‘: ‘$LIBPREFIX‘, ‘_LIBFLAGS‘: ‘${_stripixes(LIBLINKPREFIX, LIBS, LIBLINKSUFFIX, LIBPREFIXES, LIBSUFFIXES, __env__)}‘,[[email protected] xxx]#
The blue font is the default settings in env, and the modification method is simple.
env = Environment(SHLIBPREFIX=‘‘)
So far, the default lib prefix of the dynamic library is removed.
Remove the prefix Lib for scons to build a dynamic library