Bug #9774 SQLConnect fails on beta Mac OS 10.4 (Tiger)
Submitted: 8 Apr 2005 19:40 Modified: 13 Feb 2007 21:18
Reporter: Brooks Brown Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:3.51.11 OS:MacOS (Mac OS 10.4 (Tiger))
Assigned to: Jim Winstead CPU Architecture:Any

[8 Apr 2005 19:40] Brooks Brown
Description:
When I statically link to libiodbc on Mac OS 10.4, calls to SQLConnect or SQLDriverConnect fail when referencing the MyODBC driver.  iODBC reports:

[iODBC][Driver Manager]dlopen(/usr/lib/libmyodbc3.bundle, 6): Symbol not found: _GetPrivateProfileString

Also, when I install the driver, the configuration app fails to run.  If you run it from the command line, you can see a similar complaint about GetPrivateProfileString.

How to repeat:
Here is a sample test program that illustrates the problem.  This should compile with g++ on Mac OS 10.4 (g++ <source filename> -liodbc)  You'll need to modify the connection information used in SQLDriverConnect or SQLConnect.

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sql.h>
#include <sqlext.h>
#include <exception>
#include <iodbcinst.h>

using namespace std;

void showError(SQLRETURN err, const char * desc, SQLSMALLINT hType, SQLHANDLE h, int recNum = 1);
void showError(SQLRETURN err, const char * desc, SQLSMALLINT hType, SQLHANDLE h, int recNum)
{
        printf("%s: %d\n", desc, err);
        if (err == SQL_SUCCESS)
                return;
        SQLCHAR sqlState[10];
        SQLINTEGER nativeError;
        SQLCHAR msg[1024];
        SQLSMALLINT msgLen;
        SQLRETURN errErr = SQLGetDiagRec(hType, h, recNum, sqlState, &nativeError, msg, 1024, &msgLen);
        if (errErr == SQL_SUCCESS) {
                sqlState[5] = 0;
                msg[msgLen] = 0;
                printf("state: %s, native error: %d, message: %s\n", sqlState, nativeError, msg);
        }
        else
                printf("couldn't get diagnostic info - SQLGetDiagRec: %d\n", errErr);
}

int main(int argc, char ** argv)
{
        SQLHANDLE hEnv = NULL;
        SQLHANDLE hConn = NULL;
        SQLHANDLE hStmt = NULL;
        SQLRETURN err = SQL_SUCCESS;
        bool connected = false;
        err = SQLAllocHandle(SQL_HANDLE_ENV, NULL, &hEnv);
        printf("Alloc Env: %d\n", err);
        if (err == SQL_SUCCESS)
                err = SQLSetEnvAttr (hEnv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) SQL_OV_ODBC3, 0);
        if (err == SQL_SUCCESS)
        {
                err = SQLAllocHandle(SQL_HANDLE_DBC, hEnv, &hConn);
                printf("Alloc connect: %d\n", err);
        }
        if (err == SQL_SUCCESS) {
                SQLSMALLINT outLen = 0;
                SQLCHAR outString[1024];
                err = SQLDriverConnect(hConn, 0, (SQLCHAR*)"driver=/usr/lib/libmyodbc3.bundle;server=localhost;database=mysql;user=root", SQL_NTS, outString, 1024, &outLen, SQL_DRIVER_NOPROMPT);
//              err = SQLConnect(hConn, (SQLCHAR*)"mysql", SQL_NTS, NULL, 0, NULL, 0);
                showError(err, "SQLConnect", SQL_HANDLE_DBC, hConn);
        }
        if (err == SQL_SUCCESS)
                SQLDisconnect(hConn);
        if (hConn != NULL)
                SQLFreeHandle(SQL_HANDLE_DBC, hConn);
        if (hEnv != NULL)
                SQLFreeHandle(SQL_HANDLE_ENV, hEnv);
        return 0;
}
[9 Apr 2005 17:10] Jorge del Conde
Thanks for your bug report.
[27 Apr 2005 19:30] Brooks Brown
This has the bulk of the changes

Attachment: util.patch (text/plain), 6.81 KiB.

[27 Apr 2005 19:31] Brooks Brown
I think this just has a change to comments

Attachment: myodbcinst.patch (text/plain), 610 bytes.

[18 Jul 2005 21:43] david mathers
why is this taking so long?
[21 Feb 2006 17:30] Brooks Brown
Hmm... 10 months later.  I thought this was going to be addressed with 3.51.12. I am still hearing from Mac OS X users desperate for OS 10.4 support.  You have the patches - they are pretty simple changes.  What's up?
[13 Feb 2007 21:18] Jim Winstead
This workaround was disabled (and now removed) in the source tree, but I'm not sure if there has been a release with this fixed. It will be in the next release, at least.