Question

I'm creating a wscript file capable of linking external libraries that are stored in the project directory, rather than installed to the system, but I am unsure of the best way of doing so.

Currently, I'm doing something along the lines of the following:

cfg.env.INCLUDES_A = [os.path.normpath('external/include')]
cfg.env.LIBPATH_A  = [os.path.normpath('external/win32/A/lib/x64')]
cfg.env.LIB_A      = ['A']
cfg.env.append_unique('COPY_LIBS', os.path.normpath('external/win32/A/lib/x64/A.dll'))

In this case, I link to the local copy of A.lib and then mark the A.dll to be copied to my install directory (a local 'dist' dir) later in the code. However, I know for libraries installed to your system you can do something more along the lines of:

cfg.check_cxx(uselib_store="GL", stlib="opengl32")

My question then, I suppose, is: is there a way to do something similar to this with locally stored external libraries? Possibly some check_cxx(libpath="external/blah", ...) or something of the sort?

Was it helpful?

Solution

There is read_shlib and read_stlib that you can use.

You could possibly use it like so:

bld.read_shlib('opengl32', paths='external/blah')

OTHER TIPS

The solution that I've found and am currently using is to do:

cfg.env.LIBPATH.append(os.path.join(os.getcwd(), "external_lib_dir")
cfg.env.INCLUDES.append(os.path.join(os.getcwd(), "external_includes_dir")

and then, searching for a library can be as simple as:

# OpenGL
if not cfg.check_cxx(uselib_store='GL', uselib='CORE TEST', mandatory=False, lib='GL'):
    cfg.check_cxx(uselib_store='GL', uselib='CORE TEST', mandatory=True, lib='opengl32')

The first line will do a check that works on most linux systems, set as non-mandatory so that it doesnt fail, and the second line will do a check that works on windows, set as mandatory so that both failing causes a configuration failure.

This way works pretty well for me, and can be made a bit more robust if necessary (adding detection for osx frameworks or something like that), but if anyone knows of an even better way, let me know!

EDIT: Obviously, you probably won't be keeping OpenGL in a directory local to your project, but changing it to work with other libraries isn't too bad.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top