Thread: ODBC + MySQL - HOW TO???Q

  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    3

    ODBC + MySQL - HOW TO???Q

    Hi
    I have a problem with compiling a c++ with ODBC statements inside. Here is a sample:

    #include <iostream.h>
    #include <iomanip.h>
    #include <string.h>
    #include <windows.h>
    #include <sql.h>
    #include <sqlext.h>

    void main(){
    .../*some code here */...
    //SQL Connection Part
    SQLHENV henv1; //Environment handler
    SQLHDBC hdbc1; //Connection handler
    SQLHSTMT hstmt; //Statement handler

    //Create environment for SQL operations
    SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv1);

    //Select database driver
    SQLConnect(hdbc1, rhost, strlen(rhost), ruser, strlen(ruser), rpassword, strlen(rpassword));
    }

    The problem is that whenever i add any of SQL functions i get:
    Unresolved external 'SQLAllocHandle' referenced from my.obj
    Unresolved external 'SQLConnect' referenced from my.obj

    I already tried to import those two libraries into compilers lib dir
    implib myodbc3.lib c:\winnt\system32\myodbc3.dll and
    implib odbc32.lib c:\winnt\system32\odbc32.dll
    but the result is the same

    Can someone help??

    ps. (I'm using borland c++ compiler 5.5)

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well there's this, which you didn't read - http://cboard.cprogramming.com/showthread.php?t=13473
    And this, which you didn't read - http://faq.cprogramming.com/cgi-bin/...&id=1043284376

    With gcc, you would type
    Code:
    gcc prog.c -lodbc32
    I suggest "bcc32 /?" to get the help to show you the command line option for specifying additional search libraries.

    If that doesn't work, then paste the command line you did use to compile the code.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    3

    almost got it :)

    Thx
    I guess I almost have it.
    i used

    Code:
    bcc32 -c my.cpp
    and then an incremental linker:

    Code:
    ilink32 my.obj,,,odbc32.lib
    But there's still a problem the executable is to small 2KB - not a Win32 app. When linking I also try to include import32.lib and cw32.lib, and next myodbc3.lib - but with no effects. It's strange but the executable compiles without errors that I wrote in first post but it does not want to run.

  4. #4
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Its been a while since I've used Borland, but you could try explicitely telling it the name of the output file. I think it was ilink32 /o my.exe, but just do a ilink /? to make sure.

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    3
    nope same thing happens even if I type ilink32 with my.exe

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. MySQL libraries
    By csonx_p in forum C++ Programming
    Replies: 6
    Last Post: 10-02-2008, 02:23 AM
  2. Help With ODBC Code
    By zzman in forum C Programming
    Replies: 9
    Last Post: 08-22-2008, 03:18 PM
  3. Get data from mysql and use in a system.
    By smaakage in forum C++ Programming
    Replies: 5
    Last Post: 10-02-2005, 01:25 PM
  4. MySQL C API or ODBC?
    By serfurj in forum C Programming
    Replies: 3
    Last Post: 02-01-2005, 07:32 PM
  5. Linking error using ODBC with C and BCC32
    By D@nnus in forum C++ Programming
    Replies: 0
    Last Post: 11-17-2001, 05:11 AM