|
Thanks to suggestions offered here on searching the archives I found
the information I needed on accessing SQL databases using ODBC. I am still stumped by what I believe is a simple problem with a linker error. I am using MinGW on a 32-bit Windows XP machine. I stripped down a sample program I found to the following code so I could get a single error to tackle. ========== #include <windows.h> #include <sql.h> #include <sqlext.h> #include <stdio.h> SQLHANDLE environment_handle; SQLRETURN return_code; int main() { return_code = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &environment_handle); return(return_code); } ========== My command line is as follows: gcc -o tim_odbc.exe -lodbc32 tim_odbc.c I receive a compiler/linker error that indicates: "undefined reference to SQLAllocHandle@12" The library file is in C:\MinGW\lib\libodbc32.a as I believe it should be. (I used the installer program from Sourceforge.) I've seen many, many references to similar link problems with these reference errors with ODBC but have not yet found any place that offers an idea on what's being done incorrectly. I'm primarily an embedded systems programmer and I imagine this is obvious to someone familiar with MinGW and Windows but that is not me for the past two days. Any pointers on what I have done wrong will be greatly appreciated. Thank you in advance for your patience. Tim ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ MinGW-users mailing list [hidden email] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users |
|
On 2010-01-26 23:15Z, Tim McDonough wrote:
> > I am using MinGW on a 32-bit Windows XP machine. I stripped down a > sample program I found to the following code so I could get a single > error to tackle. Thank you for taking the trouble to post a simple test case. > gcc -o tim_odbc.exe -lodbc32 tim_odbc.c > > I receive a compiler/linker error that indicates: > > "undefined reference to SQLAllocHandle@12" gcc -o tim_odbc.exe tim_odbc.c -lodbc32 http://gcc.gnu.org/ml/gcc-help/2007-02/msg00050.html | | The order that you specify things here matters. The linker examines | objects from left to right, and hence if something later in the command | uses a symbol from something that preceded it, the link will fail | because the linker didn't know that it needed that symbol when it first | saw the object. In other words, put things in their dependancy order. | This usually means "-lfoo" comes last, after all source files. | | A lot of people trip this up without ever knowing it, because on ELF | platforms like Linux there is lazy binding, meaning that symbols can be | left unresolved at link-time and they will be resolved at runtime by | ld.so. This is not the case with PE, where all symbols must be resolved | at link time, and thus you can't get away with specifying things to the | linker in the wrong order. ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ MinGW-users mailing list [hidden email] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users |
|
On Tuesday, January 26, 2010 6:06 PM [GMT+1=CET],
Greg Chicares wrote: > On 2010-01-26 23:15Z, Tim McDonough wrote: >> >> I am using MinGW on a 32-bit Windows XP machine. I stripped >> down a sample program I found to the following code so I >> could get a single error to tackle. > > Thank you for taking the trouble to post a simple test case. I figure if people are using their time to help me out the least I can do is give them the details of my environment and something to easily reproduce my problem with as little effort as possible. Hopefully it will help someone else out by having a complete solution found in some future search. Thank you, Tim ------------------------------------------------------------------------------ The Planet: dedicated and managed hosting, cloud storage, colocation Stay online with enterprise data centers and the best network in the business Choose flexible plans and management services without long-term contracts Personal 24x7 support from experience hosting pros just a phone call away. http://p.sf.net/sfu/theplanet-com _______________________________________________ MinGW-users mailing list [hidden email] This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users |
| Powered by Nabble | Edit this page |
