[Scons-users] How to build a relocatable object file with Scons?

Bill Deegan bill at baddogconsulting.com
Wed Jan 31 10:52:29 EST 2018


Do you care about it being portable (working on other platforms)?

Take a look a env.LoadableModule() (
http://scons.org/doc/production/HTML/scons-man.html)

if that's not what you're looking for something like this

a=env.SharedObject('a.cpp')
b=env.SharedObject('b.cpp')
env.Command('final.o',[a,b],"ld -r $SOURCES -o $TARGET")

Should get you close.

-Bill

On Wed, Jan 31, 2018 at 2:53 AM, Yingshen Yu <yingshen.yu at gmail.com> wrote:

> Hi experts,
>
> How can I build a relocatable object file with scons?
>
> For example:
> I have two source files: a.cpp and b.cpp, here are the manual ways to
> build them into a relocatable object file.
>
> g++ -c -fPIC -fvisibility=hidden a.cpp -o a.o
> g++ -c -fPIC -fvisibility=hidden b.cpp -o a.o
> ld -r a.o b.o -o final.o
>
> I tried StaticLibrary, but it rans ar instead of ld,
> I tried SharedLibrary, but it generates a shared library. (.dylib) on my
> Mac.
>
> Thanks!
> -Jonny
>
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20180131/e55f5dcb/attachment.html>


More information about the Scons-users mailing list