Frage

I am getting a compilation error when I am trying to compile the following code.

#include "my_global.h"
#include "mysql.h"

int main(void)
{
   MYSQL *conn;
   conn = mysql_init(NULL);
   if (conn == NULL) {
         printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
         exit(1);
   }

   if (mysql_real_connect(conn, "localhost", "zetcode",
          "passwd", NULL, 0, NULL, 0) == NULL) {
      printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
      exit(1);
  }

  if (mysql_query(conn, "create database testdb")) {
      printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
      exit(1);
  }


  mysql_close(conn);

  return 0;
}

I am using the Borland 32-bits compiler on Windows 7 to compile the following code. My command to compile looks like this

c:\Borland\BCC55>bcc32 -Ic:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2
-win32-vs2005\include -c creatingTESTDB.c

I am getting six compilation errors:

Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland creatingTESTDB.c:
Warning W8017 c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs20 05\include\config-win.h 111: Redefinition of 'S_IRWXU' is not identical

Error E2238 c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs2005 \include\config-win.h 114: Multiple declaration for 'mode_t'

Error E2344 c:\Borland\Bcc55\include\sys/types.h 35: Earlier declaration of 'mod e_t'

Error E2141 c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs2005 \include\config-win.h 265: Declaration syntax error in function double2ulonglong

Error E2378 c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs2005 \include\config-win.h 268: Return statement missing ; in function double2ulonglo ng

Error E2293 c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs2005 \include\my_global.h 1591: ) expected in function rint

Error E2293 c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs2005 \include\my_global.h 1595: ) expected in function rint

* 6 errors in Compile *

Any help would be greatly appreciated. I am getting a compilation error when I am trying to compile the following code.

#include "my_global.h"
#include "mysql.h"

int main(void)
{
   MYSQL *conn;
   conn = mysql_init(NULL);
   if (conn == NULL) {
         printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
         exit(1);
   }

   if (mysql_real_connect(conn, "localhost", "zetcode",
          "passwd", NULL, 0, NULL, 0) == NULL) {
      printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
      exit(1);
  }

  if (mysql_query(conn, "create database testdb")) {
      printf("Error %u: %s\n", mysql_errno(conn), mysql_error(conn));
      exit(1);
  }


  mysql_close(conn);

  return 0;
}

I am using the Borland 32-bits compiler on Windows 7 to compile the following code. My command to compile looks like this

c:\Borland\BCC55>bcc32 -Ic:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2
-win32-vs2005\include -c creatingTESTDB.c

I am getting six compilation errors:

Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
creatingTESTDB.c:<br> Warning W8017
c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs20
05\include\config-win.h 111: Redefinition of 'S_IRWXU' is not
identical<br><br> Error E2238
c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs2005
\include\config-win.h 114: Multiple declaration for 'mode_t'<br><br>
Error E2344 c:\Borland\Bcc55\include\sys/types.h 35: Earlier
declaration of 'mod e_t'<br><br> Error E2141
c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs2005
\include\config-win.h 265: Declaration syntax error in function
double2ulonglong<br><br> Error E2378
c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs2005
\include\config-win.h 268: Return statement missing ; in function
double2ulonglo ng<br><br> Error E2293
c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs2005
\include\my_global.h 1591: ) expected in function rint<br><br> Error
E2293
c:\Users\osho\Desktop\mysql-connector-c-noinstall-6.0.2-win32-vs2005
\include\my_global.h 1595: ) expected in function rint<br><br>
*** 6 errors in Compile ***

How can I fix this problem?

Keine korrekte Lösung

Andere Tipps

You did not give the version of MySQL you're using. Try adding the following header:

#include "my_sys.h"

Other sources to look at are:

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top