gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [open-cobol-list] Linking Question


From: Thomas Biehler
Subject: Re: [open-cobol-list] Linking Question
Date: Tue Apr 20 06:48:02 2004
User-agent: KMail/1.4.3

On Tuesday 20 April 2004 14:00, Michael Rauter wrote:
> Hi
>
> I'm trying to migrate our business application from MicroFocus Cobol to
> opencobol.
> This application contains about 2000 Cobol modules and some 100 C modules.

That is similar to my situation. I can give you some hints.

> Now I'm trying to link the modules together but I only have the options
> static and dynamic.
> If I choose static, I have to complile all modules as static, which is
> not what I want.
> If I choose dynamic, I can't call the C modules which are in some static
> libraries.

First, use a actuell cvs version (~ 0.29a  near 0.30 ) ! 
(static / dynamic sounds for me as you are
 using the latest open-cobol release version 0.23!  
Don't do that!  the cvs-version is easy to build :
checkout, configure, make, make check, make install ...)

Some more Micro-Focus compatible behavior is implemented 
(only) in the cvs version! (and many many bugfixes , other extensions!)
  (  -std=mf  choose the MF compatible behavior in the new version!)
Look in the NEWS / TODO file from cvs for the current status.

Link dynamic!  (Do not use -fstatic-call  ; dynamic is default!)

> Is there a method to link a static C function library in an
> "runtime-pool" which is "visible" for the dynamic linked Cobol modules ?

a question that you have to answer! : 
  are the archived objects in the static library
  prepared for a shared library ? 
  (CFLAGS: -shared / -fpic ... or similar? )

If you are unsure, recompile the C modules with the right options for shared!
(I think the easiest way! And save!)

> Do I have to build a dynamic C library ? And how can I register the C
> functions to the Cobol programs ?

Yes, its the best way! (Easy to maintain, small memory footprint!)
There is nothing to "register"!
Unresolved symbols (you c-programs / functions)
are resolved from dynamic loader!

My suggestions is:
   Build one  "libhelperlib.so" from all your C modules!
   (You can build more small libraries if you want split it!)

I don't know nothing about your platform. (OS ,  Intel  / PowerPC / Sparc)
  (Perhaps you have to give a 
       --shared / "-fpic" flag  ...  (gcc) 
   at compiling stage !? 
   You should know how to build a shared library on your platform!)

I assume now Linux / Intel for my hints.

After buildung and installing your shared library lib_c_modules.so  in
"/usr/local/lib"  (only a example!)
you can build and (dynamic-) link your cobol-programms with:

cobc  -v -std=mf -Wall -g -L /usr/local/lib -l helperlib  example.cob

If you compile a subprogram you have to add -m to build a .so version
from this subprogram.  (compile mainprograms without the -m!)
  CALL "SUB"  -->  SUB.cob  --> SUB.so   --> dlopen find this!
Then you have to install it a common path for your application 
and set the "COB_LIBRARY_PATH" to this path so that 
the cobol-programs can find the subprograms 
(dynamicly via "dlopen")!

You have to adapt my hints to your environment!

That should also work for you. It works for me!
Hope this helps. 

Post, if you have trouble.
Post also, if you have success!  ;-)

Thomas

P.S. You can mail to me privately in german if you prefer that :-)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]