OpenCobol & PostgreSQL on Windows with Visual Studio
<p>I'm currently facing a problem with this team of 4.</p>

<p>Using binaries I downloaded on <a href="http://www.kiska.net/opencobol/1.1/" rel="nofollow noreferrer">kiska</a>'s site. I'm able to compile cobol to C and run it with <code>cobcrun</code> or compile it to an executable. However I can 't get opencobol to find the postgres commands.</p>

<p>Here is the strat of my cobol script : </p>

<pre><code>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" &amp; x"00"
        by reference "host = 10.37.180.146" &amp; "00"
        returning pgconn
    end-call
</code></pre>

<p>...</p>

<p>the call <code>PQconnectdb</code> fail with <code>module ont found : PQconnectdb</code></p>

<p>I noticed that if i rename the libpq.dll the error message change to <code>can't find entry point</code>. So at least I'm sure it can get my dll.</p>

<p>After digging into the code of the call method of the <code>libcob</code> library. I found it it was possible to pre load some dll using an environment variable <em>COB_PRE_LOAD</em> but sitll no results.</p>

<p>Here is what look the script to compile the cobol : </p>

<pre><code>call "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\amd64\vcvarsamd64.bat"
set COB_CONFIG_DIR=C:\OpenCobol\config
set COB_COPY_DIR=C:\OpenCobol\Copy
set COB_LIBS=%COB_LIBS% c:\OpenCobol\libpq.lib
set COB_LIBRARY_PATH=C:\OpenCobol\bin
set COB_PRE_LOAD=C:\OpenCobol\libpq.dll
@echo on
cobc -info
cobc -free -o pgcob -L:"C:\OpenCobol" -llibpq.lib test_cobol\postgres.cob
call cobcrun pgcob
</code></pre>

<p>I don't see anything missing, I'm using the 64-bit binaries from kiska's site and use the 64-bit cl.exe from Visual Studio, Postgres is a 64 bit version too (checked with dependencyChecker).</p>

<p>I even tryed to compile the generated C from Visual Studio, same result, but I may miss something, I'm pretty rotten in C and never really had to manage DLL or use Visual Studio.</p>

<p>What am I missing ? </p>