[Scons-users] SCons Errors and build approach
Gary Oberbrunner
garyo at oberbrunner.com
Sun Jun 29 09:58:19 EDT 2014
Once you have a Node object for the static lib, just set
staticlib.attributes.shared=True. Then it can be used in a shared lib. By
doing this you're overriding SCons's safety mechanism so you're responsible
for compiling the objects with appropriate cflags.
Something like this:
staticlib = env.Library(...)[0] # note the [0] here, Library returns a
list of Nodes.
staticlib.attributes.shared = True
On Sat, Jun 28, 2014 at 11:11 PM, Ronex Dicapriyo <ronex_89 at yahoo.in> wrote:
> Hello,
>
> Even if on linux also it generated the error when I tried to build shared
> library from static libraries:
>
> libxyz.a is static and is not compatible with shared target libpqr.dll
>
>
>
> On Sunday, 29 June 2014 12:20 AM, Bill Deegan <bill at baddogconsulting.com>
> wrote:
>
>
> Ronex,
>
> -fPIC is for gcc and not for MSVC.
> Do you understand the difference between dll's .lib's and linux .so's and
> .a's? They are not the same animal.
>
> As far as MSVC flags, you should check their documentation. I don't
> remember off the top of my head.
>
> Likely you should build your objects using SharedObject() and then use
> those to build your Libraries and thence your shared libraries.
>
> -Bill
>
>
>
> On Fri, Jun 27, 2014 at 9:17 PM, Ronex Dicapriyo <ronex_89 at yahoo.in>
> wrote:
>
> Hello Bill,
>
> Thanks for reply.
> On windows, I am using msvc compiler(cl.exe) and for linux I am using (gcc
> ).
>
> After referring the link:
> http://scons.org/doc/production/HTML/scons-user.html#chap-hierarchica
> <http://scons.org/doc/production/HTML/scons-user.html#chap-hierarchical>l
> <http://scons.org/doc/production/HTML/scons-user.html#chap-hierarchical>
> my first and third queries are cleared.
>
> But still I couldn't find any solution for query(2). If I set the flag
> 'STATIC_AND_SHARED_OBJECTS_ARE_SAME', I could build library properly, But I
> think this flag disables the check for '-fPIC' and it might not be the
> correct approach, Any idea ?
>
> Any specific flags that needs to be used for 'cl' compiler on windows
> platform?
>
>
>
>
>
> On Saturday, 28 June 2014 3:37 AM, Bill Deegan <
> bill at baddogconsulting.com> wrote:
>
>
> Ronex,
>
> I think you need to go read the users guide and man page
> http://scons.org/doc/production/HTML/scons-user.html
> http://scons.org/doc/production/HTML/scons-man.html
>
> Specifically:
> http://scons.org/doc/production/HTML/scons-user.html#chap-hierarchical
>
> Also pastebin your SConstruct and SConscripts and/or point us at a public
> repository would help.
> You also need to let us know which compilers and platform you are using.
>
> For Question 1 - All you need to do is specify the library name and path
> to it and SCons will figure out the proper order. There is no need to pass
> Node objects around to specify the dependencies.
>
> -Bill
>
>
> On Fri, Jun 27, 2014 at 1:04 PM, Ronex Dicapriyo <ronex_89 at yahoo.in>
> wrote:
>
> Hello,
>
> Please help me with the following queries:
>
> 1)
> Is it possible to call SConscript from another SConscript ?
> I noticed that it raises an error message as below when I tried to do
> this:
> scons: *** Invalid SConscript usage - no parameters
>
> Suppose I have following directory structure:
> root_dir
> |_ SConstruct
> |_ module_1
> |_ SConscript
> |_ module_2
> |_ SConscript
>
> Here module_1's library is dependent on module_2's library. So when
> SConstruct calls the SConscript of module_1 from module_1, I first want to
> calls the SConscript of module_2 with library target.
>
> What is scons way to handle such interdependency ?
>
> My SConstrcut accepts the command line argumetn of the module to e
> build say if scons -Q --module=module_1 then it calls SConscript of
> module_1. For this depency I have used python's subprocess in module_1 to
> execute scons -Q --module=module_2 and then build module_1's library.
> Rather then subprocess it could me much better if I can use SConscript
> function so that I can also export environment specif to one module to
> other dependent module.
>
> But I am not sure whether is the right way to handle such depencies ?
> I have tried to depict the scenario in brief,m there are 30 to 40 modules
> having some inetrdependencies on one or more then one modules.
>
> 2)
> On windows when I tried to build shared library from static libraries
> it generated following error message:
>
> libxyz.a is static and is not compatible with shared target libpqr.dll
>
> I have used -fPIC option in CPPFLAGS variable, But it still raises the same error.
>
>
> I tried following two approaches:
> 2.a)
>
> env.Append(CPPFLAGS=['-fPIC'])
> env.SharedLibrary(target = 'pqr', source=src_files, LIBS=['libxyz.a', 'libabc.a'] LIBPATH=[<path_of_xyz>, <path_of_abc>])
>
>
> This results in error message mentioned above.
>
> 2.b)
>
> env.Append(CPPFLAGS=['-fPIC']) src_file = Glob('*.cpp')
>
> obj_files =
> [os.path.splitext(file) for file in src_list]
> env.SharedObject(target=obj_files, source=src_files, CPPPATH='include')
> env.SharedLibrary(target='pqr', source=obj_files)
>
>
> But this generates an error message: AttributeError: 'File' object has no attribute 'rfind'
>
> So on windows what all flags and options are required to build shared library properly. How above erros can be fixed ?
>
> 3)
> How to export multiple environmet variables or other spcefic variables from SConscript ?
>
> Alternatiely What are all possible different syntax to export variables ?
>
> i.e,
> env = Environment()
> envDbg = env.Clone(CPPFLAGS = ['-g', '-O0'])
>
> lib_list = [lib1.a, lib2.a, lib3.a]
>
> SConscript(name ..., export = {env='env', 'envDbg', lib_list}) ---> what is proper way to export ?
>
>
>
> Regards,
> Ronex
>
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> http://four.pairlist.net/mailman/listinfo/scons-users
>
>
>
>
>
>
>
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> http://four.pairlist.net/mailman/listinfo/scons-users
>
>
--
Gary
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://four.pairlist.net/pipermail/scons-users/attachments/20140629/f000fb94/attachment-0001.html>
More information about the Scons-users
mailing list