gnucobol-users
[Top][All Lists]
Advanced

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

Re: [open-cobol-list] dynamic linking issues


From: Marty Heyman
Subject: Re: [open-cobol-list] dynamic linking issues
Date: Mon, 15 Sep 2014 11:09:51 -0400

I notice that there are two libcob instances. One is in /usr/local/lib and is 
very recent. The other is in /usr/lib and is dated November 2013. I tried 
moving the older copy out of the LD paths and recompiling but get the same 
behavior (subroutines not found).

—
Marty Heyman
510-290-6484 (Mobile)



On Sep 15, 2014, at 10:40 AM, address@hidden wrote:

> Send open-cobol-list mailing list submissions to
>       address@hidden
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>       https://lists.sourceforge.net/lists/listinfo/open-cobol-list
> or, via email, send a message with subject or body 'help' to
>       address@hidden
> 
> You can reach the person managing the list at
>       address@hidden
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of open-cobol-list digest..."
> 
> 
> Today's Topics:
> 
>   1. Re: linking stuff (statically linked same code) (Marty Heyman)
>   2. Re: Open COBOL Build 426 Not Finding Modules (Patrick)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Mon, 15 Sep 2014 09:54:20 -0400
> From: Marty Heyman <address@hidden>
> Subject: Re: [open-cobol-list] linking stuff (statically linked same
>       code)
> To: address@hidden
> Message-ID: <address@hidden>
> Content-Type: text/plain; charset="windows-1252"
> 
> Different compile behavior
> 
> ? START SESSION CLIP ?
> address@hidden:~/Projects/PlanBTest/mhWork$ cobc -L/usr/lib -lpq -std=mvs 
> -static -x -w ../cobol_source/PGTest.cbl 
> /tmp/cob42052_0.c: In function ?pgcob_?:
> /tmp/cob42052_0.c:102:3: warning: implicit declaration of function 
> ?PQconnectdb? [-Wimplicit-function-declaration]
>   (*(unsigned char **) (b_5)) = (void *)PQconnectdb ((cob_u8_ptr)"dbname = 
> postgres\000");
>   ^
> /tmp/cob42052_0.c:102:33: warning: cast to pointer from integer of different 
> size [-Wint-to-pointer-cast]
>   (*(unsigned char **) (b_5)) = (void *)PQconnectdb ((cob_u8_ptr)"dbname = 
> postgres\000");
>                                 ^
> /tmp/cob42052_0.c:110:3: warning: implicit declaration of function ?PQstatus? 
> [-Wimplicit-function-declaration]
>   b_1 = PQstatus ((*(unsigned char **) (b_5)));
>   ^
> /tmp/cob42052_0.c:119:3: warning: implicit declaration of function ?PQuser? 
> [-Wimplicit-function-declaration]
>   (*(unsigned char **) (b_7)) = (void *)PQuser ((*(unsigned char **) (b_5)));
>   ^
> /tmp/cob42052_0.c:119:33: warning: cast to pointer from integer of different 
> size [-Wint-to-pointer-cast]
>   (*(unsigned char **) (b_7)) = (void *)PQuser ((*(unsigned char **) (b_5)));
>                                 ^
> /tmp/cob42052_0.c:140:3: warning: implicit declaration of function ?PQexec? 
> [-Wimplicit-function-declaration]
>   (*(unsigned char **) (b_6)) = (void *)PQexec ((*(unsigned char **) (b_5)), 
> (cob_u8_ptr)"select version();\000");
>   ^
> /tmp/cob42052_0.c:140:33: warning: cast to pointer from integer of different 
> size [-Wint-to-pointer-cast]
>   (*(unsigned char **) (b_6)) = (void *)PQexec ((*(unsigned char **) (b_5)), 
> (cob_u8_ptr)"select version();\000");
>                                 ^
> /tmp/cob42052_0.c:150:3: warning: implicit declaration of function 
> ?PQgetvalue? [-Wimplicit-function-declaration]
>   (*(unsigned char **) (b_7)) = (void *)PQgetvalue ((*(unsigned char **) 
> (b_6)), (cob_s32_t)0LL, (cob_s32_t)0LL);
>   ^
> /tmp/cob42052_0.c:150:33: warning: cast to pointer from integer of different 
> size [-Wint-to-pointer-cast]
>   (*(unsigned char **) (b_7)) = (void *)PQgetvalue ((*(unsigned char **) 
> (b_6)), (cob_s32_t)0LL, (cob_s32_t)0LL);
>                                 ^
> /tmp/cob42052_0.c:167:3: warning: implicit declaration of function ?PQfinish? 
> [-Wimplicit-function-declaration]
>   PQfinish ((*(unsigned char **) (b_5)));
>   ^
> /tmp/cob42052_0.c:185:33: warning: cast to pointer from integer of different 
> size [-Wint-to-pointer-cast]
>   (*(unsigned char **) (b_7)) = (void *)PQuser ((*(unsigned char **) (b_5)));
>                                 ^
> address@hidden:~/Projects/PlanBTest/mhWork$ ./PGTest
> Before connect:0x0000000000000000
> After connect: 0x0000000000f13590
> Status:        +0000000001
> User:          marty
> call PQexec
> 0x0000000000000000
> 
> Attempt to reference unallocated memory (Signal SIGSEGV)
> Abnormal termination - File contents may be incorrect
> address@hidden:~/Projects/PlanBTest/mhWork$ 
> ? END SESSION CLIP ??
> 
> ?
> Marty Heyman
> 510-290-6484 (Mobile)
> 
> 
> 
> On Sep 15, 2014, at 9:10 AM, Marty Heyman <address@hidden> wrote:
> 
>> Patrick,
>> The code is copied below. It is Brian?s example from the FAQ section 5.4.6. 
>> I get similar results without -x and running cobcrun (which then can?t find 
>> PGTest.so).
>> I haven?t statically linked stuff yet ? will try in a bit. Have a customer 
>> on the phone at the moment. 
>> ?? START CODE ??
>> OCOBOL*> ***************************************************************
>>      *> Author:    Brian Tiffin
>>      *> Date:      20091129
>>      *> Purpose:   PostgreSQL connection test
>>      *> Tectonics: cobc -x -lpq pgcob.cob
>>      *> ***************************************************************
>>       identification division.
>>       program-id. pgcob.
>> 
>>       data division.
>>       working-storage section.
>>       01 pgconn usage pointer.
>>       01 pgres  usage pointer.
>>       01 resptr usage pointer.
>>       01 resstr pic x(80) based.
>>       01 result usage binary-long.
>>       01 answer pic x(80).
>> 
>>      *> ***************************************************************
>>       procedure division.
>>       display "Before connect:" pgconn end-display
>> 
>>       call "PQconnectdb" using
>>           by reference "dbname = postgres" & x"00"
>>           returning pgconn
>>       end-call
>>       display "After connect: " pgconn end-display
>> 
>>       call "PQstatus" using by value pgconn returning result end-call
>>       display "Status:        " result end-display
>> 
>>       call "PQuser" using by value pgconn returning resptr end-call
>> 
>>       set address of resstr to resptr
>>       string resstr delimited by x"00" into answer end-string
>>       display "User:          " function trim(answer) end-display
>> 
>>       display "call PQexec" end-display
>>       call "PQexec" using
>>           by value pgconn
>>           by reference "select version();" & x"00"
>>           returning pgres
>>       end-call
>>       display pgres end-display
>> 
>>      *> Pull out a result. row 0, field 0 <*
>>       call "PQgetvalue" using
>>           by value pgres
>>           by value 0
>>           by value 0
>>           returning resptr
>>       end-call
>>       set address of resstr to resptr
>>       string resstr delimited by x"00" into answer end-string
>>       display "Version:       " answer end-display
>> 
>>       call "PQfinish" using by value pgconn returning null end-call
>>       display "After finish:  " pgconn end-display
>> 
>>       call "PQstatus" using by value pgconn returning result end-call
>>       display "Status:        " result end-display
>> 
>>      *> this will now return garbage  <*
>>       call "PQuser" using by value pgconn returning resptr end-call
>>       set address of resstr to resptr
>>       string resstr delimited by x"00" into answer end-string
>>       display "User after:    " function trim(answer) end-display
>> 
>>       goback.
>>       end program pgcob.  
>> ? END CODE ? start cobc -v output ???
>> address@hidden:~/Projects/PlanBTest/mhWork$ cobc -L/usr/lib -lpq -std=mvs -v 
>> ../cobol_source/PGTest.cbl 
>> Command line:        cobc -L/usr/lib -lpq -std=mvs -v 
>> ../cobol_source/PGTest.cbl 
>> Preprocessing:       ../cobol_source/PGTest.cbl -> /tmp/cob41797_0.cob
>> Return status:       0
>> Parsing:     /tmp/cob41797_0.cob (../cobol_source/PGTest.cbl)
>> Return status:       0
>> Translating: /tmp/cob41797_0.cob -> /tmp/cob41797_0.c 
>> (../cobol_source/PGTest.cbl)
>> Executing:   gcc -std=gnu99 -I/usr/local/include -pipe -Wno-unused
>>              -fsigned-char -Wno-pointer-sign -shared -fPIC -DPIC
>>              -Wl,--export-dynamic -o "PGTest.so" "/tmp/cob41797_0.c"
>>              -L/usr/local/lib -lcob -lm -lgmp -lncurses -ldb -ldl -l"pq"
>>              -L"/usr/lib"
>> Return status:       0
>> address@hidden:~/Projects/PlanBTest/mhWork$
>> ??? END cobc -v output ???
>>> Patrick wrote
>>> Hi Marty
>> 
>>> Do you have a little snippet of test code you could share ?
>> 
>>> I am on Debian Stable. I don't seem to be having trouble but maybe I am 
>>> missing something and have the bug too.
>> 
>>> Is it possible to statically link to see if the problem goes away?
>> 
>>> Could you compile in verbose mode and share?
>> 
>> Thanks
>> 
>> ?
>> Marty Heyman
>> 510-290-6484 (Mobile)
> 
> -------------- next part --------------
> An HTML attachment was scrubbed...
> 
> ------------------------------
> 
> Message: 2
> Date: Mon, 15 Sep 2014 10:39:49 -0400
> From: Patrick <address@hidden>
> Subject: Re: [open-cobol-list] Open COBOL Build 426 Not Finding
>       Modules
> To: Marty Heyman <address@hidden>,
>       address@hidden
> Message-ID: <address@hidden>
> Content-Type: text/plain; charset="iso-8859-1"
> 
> Hi Marty
> 
> I am not much help to you , turns out I need help.
> 
> I copied Brian's example from the site, (I don't know why but your email 
> took out the newlines)
> 
> I downloaded and installed 426.
> 
> Why does this show it's version 1.1 ? Aren't we into the 2.* series ?
> 
> cobc -V
> cobc (GNU Cobol) 1.1.0
> Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Keisuke Nishida
> Copyright (C) 2006-2012 Roger While
> This is free software; see the source for copying conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> Built     Sep 15 2014 10:24:16
> Packaged  Jan 20 2014 07:40:53 UTC
> C version "4.7.2"
> 
> I had this error:
> 
> cobc -x -lpq pgcob.cob
> pgcob.cob:58: Error: syntax error, unexpected NULL, expecting Identifier
> 
> I haven't used null personally so I just created an variable null and 
> tried this:
> cobc -x -lpq pgcob.cob
> pgcob.cob:18: Error: syntax error, unexpected NULL, expecting EXTERNAL 
> or GLOBAL
> 
> So it does have knowledge of null but doesn't expect it in this position.
> 
> I am not much help yet but maybe you should post your version of gcc. 
> You could also compile it cobc -C and then use gcc in verbose mode so 
> that others would have more info.
> 
> I have to work right now but I will try to figure out where I am stuck 
> and maybe I will be able to help after, but probably not :(
> 
> Thanks
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> On 15/09/14 09:10 AM, Marty Heyman wrote:
>> Patrick,
>> The code is copied below. It is Brian's example from the FAQ section 5.4.6. 
>> I get similar results without -x and running cobcrun (which then can't find 
>> PGTest.so).
>> I haven't statically linked stuff yet ... will try in a bit. Have a customer 
>> on the phone at the moment.
>> ------ START CODE ------
>> OCOBOL*> 
>> *************************************************************** *> 
>> Author: Brian Tiffin *> Date: 20091129 *> Purpose: PostgreSQL 
>> connection test *> Tectonics: cobc -x -lpq pgcob.cob *> 
>> *************************************************************** 
>> identification division. program-id. pgcob. data division. 
>> working-storage section. 01 pgconn usage pointer. 01 pgres usage 
>> pointer. 01 resptr usage pointer. 01 resstr pic x(80) based. 01 result 
>> usage binary-long. 01 answer pic x(80). *> 
>> *************************************************************** 
>> procedure division. display "Before connect:" pgconn end-display call 
>> "PQconnectdb" using by reference "dbname = postgres" & x"00" returning 
>> pgconn end-call display "After connect: " pgconn end-display call 
>> "PQstatus" using by value pgconn returning result end-call display 
>> "Status: " result end-display call "PQuser" using by value pgconn 
>> returning resptr end-call set address of resstr to resptr string 
>> resstr delimited by x"00" into answer end-string display "User: " 
>> function trim(answer) end-display display "call PQexec" end-display 
>> call "PQexec" using by value pgconn by reference "select version();" & 
>> x"00" returning pgres end-call display pgres end-display *> Pull out a 
>> result. row 0, field 0 <* call "PQgetvalue" using by value pgres by 
>> value 0 by value 0 returning resptr end-call set address of resstr to 
>> resptr string resstr delimited by x"00" into answer end-string display 
>> "Version: " answer end-display call "PQfinish" using by value pgconn 
>> returning null end-call display "After finish: " pgconn end-display 
>> call "PQstatus" using by value pgconn returning result end-call 
>> display "Status: " result end-display *> this will now return garbage 
>> <* call "PQuser" using by value pgconn returning resptr end-call set 
>> address of resstr to resptr string resstr delimited by x"00" into 
>> answer end-string display "User after: " function trim(answer) 
>> end-display goback. end program pgcob.
>> --- END CODE --- start cobc -v output ---------
>> address@hidden:~/Projects/PlanBTest/mhWork$ cobc -L/usr/lib -lpq -std=mvs -v 
>> ../cobol_source/PGTest.cbl
>> Command line:        cobc -L/usr/lib -lpq -std=mvs -v 
>> ../cobol_source/PGTest.cbl
>> Preprocessing:       ../cobol_source/PGTest.cbl -> /tmp/cob41797_0.cob
>> Return status:       0
>> Parsing:     /tmp/cob41797_0.cob (../cobol_source/PGTest.cbl)
>> Return status:       0
>> Translating: /tmp/cob41797_0.cob -> /tmp/cob41797_0.c 
>> (../cobol_source/PGTest.cbl)
>> Executing:   gcc -std=gnu99 -I/usr/local/include -pipe -Wno-unused
>>              -fsigned-char -Wno-pointer-sign -shared -fPIC -DPIC
>>              -Wl,--export-dynamic -o "PGTest.so" "/tmp/cob41797_0.c"
>>              -L/usr/local/lib -lcob -lm -lgmp -lncurses -ldb -ldl -l"pq"
>>              -L"/usr/lib"
>> Return status:       0
>> address@hidden:~/Projects/PlanBTest/mhWork$
>> --------- END cobc -v output ---------
>>> Patrick wrote
>>> Hi Marty
>> 
>>> Do you have a little snippet of test code you could share ?
>> 
>>> I am on Debian Stable. I don't seem to be having trouble but maybe I am
>>> missing something and have the bug too.
>> 
>>> Is it possible to statically link to see if the problem goes away?
>> 
>>> Could you compile in verbose mode and share?
>> 
>> Thanks
>> 
>> ---
>> Marty Heyman
>> 510-290-6484 (Mobile)
>> 
>> 
>> 
>> 
>> 
>> ------------------------------------------------------------------------------
>> Want excitement?
>> Manually upgrade your production database.
>> When you want reliability, choose Perforce
>> Perforce version control. Predictably reliable.
>> http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
>> 
>> 
>> _______________________________________________
>> open-cobol-list mailing list
>> address@hidden
>> https://lists.sourceforge.net/lists/listinfo/open-cobol-list
> 
> -------------- next part --------------
> An HTML attachment was scrubbed...
> 
> ------------------------------
> 
> ------------------------------------------------------------------------------
> Want excitement?
> Manually upgrade your production database.
> When you want reliability, choose Perforce
> Perforce version control. Predictably reliable.
> http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
> 
> ------------------------------
> 
> _______________________________________________
> open-cobol-list mailing list
> address@hidden
> https://lists.sourceforge.net/lists/listinfo/open-cobol-list
> 
> 
> End of open-cobol-list Digest, Vol 83, Issue 7
> **********************************************



reply via email to

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