views:

88

answers:

2

Well, I am Developing a program in C++ in an Ubuntu 10.04.1 (Intel Core2Quad) LTS, but the releases are running in a Debian 5.0.5 (Intel(R) Xeon(R) CPU). Some libraries such as crypto++ or mysqlclient have different versions in both OS. So I decided to compile the binary statically with all the libraries statically compiled in the Ubuntu and then upload the completed binary to the Debian.

I am not sure if this method is correct, because the static libs maybe are architecture-dependent and maybe can get in conflict in the Debian Machine. If I want to use the new library version of Ubuntu in the Debian, should I compile them in the Debian?

Thanks in advance

+2  A: 

No, it is not machine independent. The only difference is that all libraries are bundled with the executable, so there is no risk for the program to fail on load with a "library not found" message. In summary, it will works for all linux distributions, but it will not work for Windows, for example.

Baltasarq
Of course, but maybe the library bundled has been optimized for different architectures and distributions. So maybe can crash if I compile all the executable in Ubuntu and then be runned in Debian. I usually use .a libraries stored in /usr/lib,/lib so I am not sure about the compilers flags that have been used for those libraries downloaded by apt.
JoniPichoni
Check the .deb file for the package that contains that .a file ? Ubuntu .debs are usually i386,i586,i686 .deb files, optimized for the respective architectures.
nos
Ok, Thanks a lot
JoniPichoni
Yes, you're right. But choosing the correct packages is up to you. If you want to be sure that your package will work in all architectures, them, as @nos points out, you should choose the i386 flavor of the package. About distro-dependant packages in the field of development, I can't think of an example (this does not mean that it does not exist).
Baltasarq
+2  A: 

They're architecture dependant. Usually though, library gets compiled to a common architecture on x86 machines, such as i686 which will run fine on both an Intel Xenon and a Intel Core2Quad (But not on e.g. an old Pentium processor)

nos