Subject: Help! Problems linking against Win32 API...
From: [email-masked] (Skip Montanaro)

25 Apr 1998 00:48:10 -0700
Message-ID: <[email-masked]>
Reply-To: [email-masked]
To: [email-masked]

I'm struggling trying to figure out how to link an application that
makes calls to the Win32 API, specifically, ODBC.  In the FAQ, it
implies that I should just be able to compile and link my application
with no "glue".  The following is extracted from the Programming
Questions section of the FAQ:

    For example, to use graphics functions (GDI) you must link with
    gdi32 like this:  

    gcc -o foo.exe foo.o bar.o -lgdi32 

    or (compiling and linking in one step): 

    gcc -o foo.exe foo.c bar.c -lgdi32 

However, when I link I get all sorts of undefined symbol errors:

    g++  -o odbc_test odbc_test.o \
	    -L../gen_code/obj -lgen_code \
	    -L../../dom_util/obj -ldom_util \
	    -L../../db_findr/obj -ldb_findr \
	    -L../../findr_util/obj -lfindr_util \
	    -L../../../../util/obj -lutil \
	    -lodbc32 \
	    -L//c/Cygnus/B19/H-i386-cygwin32/lib -lstdc++
    ../../db_findr/obj/libdb_findr.a(odbc.o): In function `_4odbcPcP5query':
    //h/.../obj/../src/odbc.cxx:9: undefined reference to `SQLAllocEnv'
    //h/.../obj/../src/odbc.cxx:10: undefined reference to `SQLAllocConnect'
    //h/.../obj/../src/odbc.cxx:11: undefined reference to `SQLConnect'
    ...

When I examine the symbol table of the object file that makes the ODBC
calls, I see:

    U _SQLAllocConnect
    U _SQLAllocEnv
    U _SQLAllocStmt
    U _SQLColumns
    U _SQLConnect
    U _SQLDisconnect
    U _SQLFetch
    U _SQLFreeConnect
    U _SQLFreeEnv
    U _SQLFreeStmt
    U _SQLGetData
    U _SQLSetConnectOption
    U _SQLTables

On the other hand, when I examine the libodbc32.a file that comes with
the GNU-WIN32 package I see:

    00000000 T _SQLTransact@12
    00000000 T _SQLTables@36
    00000000 T _SQLTablePrivileges@28
    00000000 T _SQLStatistics@36
    00000000 T _SQLSpecialColumns@40
    00000000 T _SQLSetStmtOption@12
    ...

There is obviously a mismatch between the symbols the compiler
generates and those available at link time.  How do I bridge this gap?
It seems that somewhere there must be another jump table of some sort
that maps (for example) "_SQLTables" to "_SQLTables@36".

(If the answer requires using non-GNU tools, go easy on me.  I'm
fairly unfamiliar with the Windows environment.)

Thanks,

-- 
Skip Montanaro
([email-masked], 518 387 6792)
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".