Remove the prefix Lib for scons to build a dynamic library

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.