Static compiling

Hello everyone,

please allow me one stupid question. Most recently I nearly finished a bigger project using OCC 5.0, including its Browser etc. Now when I do dynamic linking, it needs a lot of libraries (.so files) being included calling make.
How about makeing a static compilat ? The point is, that my software shall be installed on another computer, where most of the libraries simply just do not exist. But my softweare should run on it.

Does anyone know if static compiling is the solution therefore (I know static compiling is dumb !), any good and quick alternative ?

How to do staic compiling...just put --static before every gcc call in my makefile ?

Best regards and thanks in advance.

Chris

marc's picture

Wow, that is quite a good question. When it comes to commercial projects, this is an interesting question in a world of Microsoft.

So it is much easier to make a static compiling to avoid the customer moving desperately to additional workaround seeking for all missing libraries, that your software needs !
Right.

Any ideas ?

marc's picture

Wow, that is quite a good question. When it comes to commercial projects, this is an interesting question in a world of Microsoft.

So it is much easier to make a static compiling to avoid the customer moving desperately to additional workaround seeking for all missing libraries, that your software needs !
Right.

Any ideas ?

Ernest's picture

I've managed to compile (the neded part of) OCC statically, but had to change the source. There might be a simplier solution. Here is what i've done (WINDOWS!!!): I've created a new project and merged all the used projects into this single project (by hand using a simple text editor :) . Also a new define was introduced: STATIC_DLL. All over the code i had to do some minor modification like:

#ifndef __math_API
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# if defined(WNT) && !defined(STATIC_DLL)
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# ifdef __math_DLL
# define __math_API __declspec( dllexport )
# else
# define __math_API __declspec( dllimport )
# endif /* __math_DLL */
# else
# define __math_API
# endif /* WNT */
#endif /* __math_API */

It took me quite a long time since all the warnings came during the linking phase, and of course i had to compile the whole project again and again.
(Note:
1.in VC++ projects many preprocessor directives are set by files
2. #undefine WNT (or similar things) could not be used b/c there are other system dependent parts depending on this directive (ex. HWND))

On Unix it might be easier since there's no __declspec( dllexport/import ) but i've never tried it beafor.

There might be some magic preprocessor directives that makes the OCC complie static but i could not figure them out.

(Note: Finally we had no use for the static libraries because some of our plugins had to include them independently and as a result the whole OCC was duplicated in the final DLL's. - Creating a single dll from (the used parts of) OCC would be the solution but it does not make too much deferencie to the current solution.)

Good Luck.