Problems w/ globals file
Posted in 1999
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
I've encountered a problem where I can't get variables defined in a globals file to compile. I get the following error message when I make the program: /ocs1/source/load.4gm/loaduc.4gc OCS>> make /ocs1/informix/lib/fglc loaduc.4gl /ocs1/informix/lib/fglc2 -4GL loaduc.ec cc -I/ocs1/informix/incl/tools -c loaduc.c rm -f loaduc.ec rm -f loaduc.c c4gl -o loaduc.4ge loaduc.o /ocs1/source/libttg/lib.a /usr/ccs/bin/ld: Unsatisfied symbols: tester (data) *** Error exit code 1 Stop. In the above example tester is a variable being defined in the globals file. Has anyone seen anything like this before? Any help you could give would be greatly appreciated!
It looks like you are asking for trouble. Why are you in the first place performing the compilation in a non-standard way... don't answer. Hopefully the globals file is being included in each of the other 4gl files that require it... otherwise the the globals variables will only be visible within the globals file it's self if compiled separately.... and the other files requiring it won't know anything about that... hopefully understand the rules of scope. You shouldn't have to compile the globals file, include globals file within the the files requiring the globals then it should compile within modules before being linked to the final target. Top Cat <cstefanick@ocsmgmt.com> wrote in message news:7gnjmg$d9g$1@nnrp02.primenet.com... > I've encountered a problem where I can't get variables defined in a globals > file to compile. I get the following error message when I make the program: > > /ocs1/source/load.4gm/loaduc.4gc OCS>> make > /ocs1/informix/lib/fglc loaduc.4gl > /ocs1/informix/lib/fglc2 -4GL loaduc.ec > cc -I/ocs1/informix/incl/tools -c loaduc.c > rm -f loaduc.ec > rm -f loaduc.c > c4gl -o loaduc.4ge loaduc.o /ocs1/source/libttg/lib.a > /usr/ccs/bin/ld: Unsatisfied symbols: > tester (data) > *** Error exit code 1 > > Stop. > > > In the above example tester is a variable being defined in the globals file. > Has anyone seen anything like this before? Any help you could give would be > greatly appreciated! > >
Neil Rutherford wrote: > It looks like you are asking for trouble. > Why are you in the first place performing the compilation in a > non-standard way... don't answer. I absolutely agree with this. Your method of compilation is error-prone, especially if you ever encountered a database which used a non-English locale. Use the c4gl script to do the compilation. > Hopefully the globals file is being included in each of the other > 4gl files that require it... It must be for those files to compile. > otherwise the the globals variables will only be visible within > the globals file it's self if compiled separately.... and the other > files requiring it won't know anything about that... hopefully > understand the rules of scope. That's a bit hard to understand. > You shouldn't have to compile the globals file Now Neil and I part company -- I'd say "you have to compile the globals file as a separate object file and link it into the program". It actually depends a bit on your compiler and linker, but on many systems, this is unavoidable, and it is the only portable way to build the program. When you write: GLOBALS "globals.4gl" The I4GL compiler (which isn't even called fglc any more; fglc is a script that runs the correct program for you, and is provided solely to prevent your makefile from breaking) converts the references to the variables defined in globals.4gl into C extern declarations (as opposed to C definitions): extern long i; For some C compilers and linkers, that generates a tentative definition which will be merged with any other such references and the linker will end up providing a definition for i. However, most compilers do not do that and you have to provide the actual variable definition somewhere. The only reliable way of doing that is to compile globals.4gl into globals.o. I'm not even going to explain the unreliable methods -- you can work them out for yourself if you wish to create a bigger maintenance nightmare for your colleagues. > include globals file within > the the files requiring the globals > then it should compile within modules before being linked to the final > target. > > Top Cat <cstefanick@ocsmgmt.com> wrote: > > I've encountered a problem where I can't get variables defined in > > a globals file to compile. I get the following error message when > > I make the program: > > > > /ocs1/source/load.4gm/loaduc.4gc OCS>> make > > /ocs1/informix/lib/fglc loaduc.4gl > > /ocs1/informix/lib/fglc2 -4GL loaduc.ec > > cc -I/ocs1/informix/incl/tools -c loaduc.c > > rm -f loaduc.ec > > rm -f loaduc.c > > c4gl -o loaduc.4ge loaduc.o /ocs1/source/libttg/lib.a > > /usr/ccs/bin/ld: Unsatisfied symbols: > > tester (data) > > *** Error exit code 1 > > > > Stop. > > > > In the above example tester is a variable being defined in the > > globals file. > > Has anyone seen anything like this before? Any help you could > > give would be greatly appreciated! Are you using Fourgen as a code generator? -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN #include <disclaimer.h>