I'm migrating some of our applications from Windows to our
Linux servers. The programs are in C++. They always get a
segmentation fault in SQLDriverConnect(). I've created a very
simple program in both C and C++ that exhibits the problem.
Save as both prg_c.c and prg_cpp.cpp and compiled with:
gcc -m32 -lodbc -o prg_c prg_c.c
g++ -m32 -lodbc -o prg_cpp prg_cpp.c
(-m32 because the server is running 64-bit Linux and PSQL
only comes with 32-bit drivers.)
-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----
#include <string.h>
#include <sql.h>
#include <sqlext.h>
int main(int argc, char **argv)
{
SQLHENV henv;
SQLHDBC hdbc;
SQLCHAR dsn[120];
short buflen;
char buffer[257];
int status;
strcpy((char*)dsn, "DSN=Paragon");
if (SQLAllocEnv (&henv) != SQL_SUCCESS)
return -1;
if (SQLAllocConnect (henv, &hdbc) != SQL_SUCCESS)
return -1;
status = SQLDriverConnect (hdbc, 0, dsn, SQL_NTS,
(SQLCHAR*)buffer, sizeof (buffer), &buflen,
SQL_DRIVER_COMPLETE);
if (status != SQL_SUCCESS && status != SQL_SUCCESS_WITH_INFO)
return -1;
SQLDisconnect (hdbc);
SQLFreeConnect (hdbc);
SQLFreeEnv (henv);
return 0;
}
-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----8<-----
The straight C program runs fine. The C++ program blows in
the SQLDriverConnect() call.
I've tried both -lodbc and -liodbc and both fail at the same
place.
John


|