www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/04/25/00:48:10

From: montanaro AT crd DOT ge DOT com (Skip Montanaro)
Subject: Help! Problems linking against Win32 API...
25 Apr 1998 00:48:10 -0700 :
Message-ID: <199804241827.OAA15785.cygnus.gnu-win32@daisymae.crd.ge.com>
Reply-To: montanaro AT crd DOT ge DOT com
To: gnu-win32 AT cygnus DOT com

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 AT 12
    00000000 T _SQLTables AT 36
    00000000 T _SQLTablePrivileges AT 28
    00000000 T _SQLStatistics AT 36
    00000000 T _SQLSpecialColumns AT 40
    00000000 T _SQLSetStmtOption AT 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 AT 36".

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

Thanks,

-- 
Skip Montanaro
(montanaro AT crd DOT ge DOT com, 518 387 6792)
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019