Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 410931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:56:12+00:00 2026-05-12T17:56:12+00:00

I want to build a shared library using waf as it looks much easier

  • 0

I want to build a shared library using waf as it looks much easier and less cluttered than GNU autotools.

I actually have several questions so far related to the wscript I’ve started to write:

VERSION='0.0.1'
APPNAME='libmylib'

srcdir = '.'
blddir = 'build'

def set_options(opt):
 opt.tool_options('compiler_cc')
 pass

def configure(conf):
 conf.check_tool('compiler_cc')
 conf.env.append_value('CCFLAGS', '-std=gnu99 -Wall -pedantic -ggdb')

def build(bld):
 bld.new_task_gen(
  features = 'cc cshlib',
  source = '*.c',
  target='libmylib')

The line containing source = '*.c' does not work. Must I specify each and every .c file instead of using a wildcard?

How can I enable a debug build for example (currently the wscript is using the debug builds CFLAGS, but I want to make this optional for the end user).

It is planned for the library sources to be within a sub directory, and programs that use the lib each in their own sub directories.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T17:56:13+00:00Added an answer on May 12, 2026 at 5:56 pm

    Assuming you are using the latest version of waf (1.5.9 at the time of writing), wild cards can be specified via the glob() method on the build context. So you can write the following:

    bld.new_task_gen(
        features = 'cc cshlib',
        source = bld.glob('*.c'),
        target='mylib')
    

    If you were using an older version of waf that doesn’t have glob, then there is a method find_sources_in_dirs that you can use:

    lib = bld.new_task_gen(
        features = 'cc cshlib',
        target = 'mylib')
    lib.find_sources_in_dirs('.')
    

    This method is still in Waf but is slated for deprecation and may eventually disappear.

    The srcdir and blddir variables are optional now so you don’t need them – they default to “.” and “build” anyway. You shouldn’t prepend “lib” to the target name, this is done automatically in a platform specific way (on Windows no lib is added and shared libraries use .dll). Debug vs Release build is a surprisingly thorny issue. Originally Waf included this feature, but it was dropped at some point and never re-added. It’s a common request on the mailing list so may resurface in the future. Meanwhile you could do a lot worse than use gjc’s cflags module. Just add it to your project directory. The final wscript would then be:

    VERSION='0.0.1'
    APPNAME='mylib'
    
    def set_options(opt):
        opt.tool_options('compiler_cc')
        opt.tool_options('cflags', tooldir='.')
    
    def configure(conf):
        conf.check_tool('compiler_cc')
        conf.check_tool('cflags', tooldir='.')
    
    def build(bld):
        bld.new_task_gen(
            features = 'cc cshlib',
            source = bld.glob('*.c'),
            target=APPNAME)
    

    And to set up a debug build you would run the following:

    ./waf configure -d debug
    

    If you are using libraries in their own sub-directories, then you should probably have a top level wscript and use the bld.add_subdirs() technique to add library/program directories. Each sub-directory would have its own wscript_build file. You can then use the export_incdirs and uselib_local properties to specify the correct include directories between library and program “modules”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We want to build a library of c# snips for .NET. We are looking
I'm facing a problem where I build a shared library and a unit-test executable
If I build a shared library (shared object) I can use it in two
I want to build a lightweight linux configuration to use for development. The first
I want to build a bot that asks someone a few simple questions and
I want to build my own custom log4j (network) adapter to solve my problem
I want to build an executable to distribute to people without python installed on
I want to build a site where the user can enter text and format
I want to build two-dimentional array of strings where length of one dimention is
I want to build a web based front-end to manage/administer my Linux box. E.g.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.