Click to See Complete Forum and Search --> : g++ Cross-compatible, is this possilble?


Dice
07-31-2003, 09:28 AM
I've written a program in c++ to run on webservers. Basically, it handles traffic on web sites. Since many hosts use different OS's, like redhat, trustix, debian, slackware, suse, mandrake, etc, etc. right now I have to compile my script on every of those OSs so it can run.
This is very time consuming, when you consider compiling it takes about 2 hours / OS.

Now, all these OS's are linux. And I've seen several other programs online where's
simply one linux package, that will run on any linux distro.
The only specification on those scripts were
"Linux Version - glibc 2.1 and higher"

My question is, how do I do this?
What commands do I give to g++ so it's entirely cross-compatible?
I just want to be able to compile it on my redhat 7.2 copy for example, put that online as a generic linux version, that will run on any other linux distro.

The things that keep bugging me are errors such as
"error in loading shared libraries: libstdc++-libc6.2-2.so.3:
cannot open shared object file: No such file or directory"
I figured that if I can compile it so it doesn't use libstdc++-libc6.2-2.so.3, but simply uses libstdc++-libc.so (version-less), it should do the trick...

Thank you for any help

Stuka
07-31-2003, 09:55 AM
The best way to do what you want is to link your executable statically - I haven't done that in g++, but I'm certain it's possible. This would remove all .so dependencies (though it will also make your executable larger).

Dice
07-31-2003, 10:04 AM
Originally posted by Stuka
The best way to do what you want is to link your executable statically - I haven't done that in g++, but I'm certain it's possible. This would remove all .so dependencies (though it will also make your executable larger).

Hey, thanks Stuka for the advice, now I need to know how to link my executable statically, and I'm set. I'm hoping someone here can give me a head's up on how to do this, but I'll also refine my search through some websites to see if I can get the answer myself. Thanks again.

Stuka
07-31-2003, 10:11 AM
It appears that all you need to do is pass the '-static' option to gcc.