Discussion:
[Scons-users] How to build a relocatable object file with Scons?
Yingshen Yu
2018-01-31 10:53:32 UTC
Permalink
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
Bill Deegan
2018-01-31 15:52:29 UTC
Permalink
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
Post by Yingshen Yu
Hi experts,
How can I build a relocatable object file with scons?
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
https://pairlist4.pair.net/mailman/listinfo/scons-users
Loading...