Bug #99024 cannot compile c program using <mysql/jdbc.h>
Submitted: 22 Mar 2020 14:46 Modified: 18 May 2020 6:19
Reporter: Terry Warren Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / C++ Severity:S3 (Non-critical)
Version:8.0.19 OS:MacOS (10.15.3)
Assigned to: MySQL Verification Team CPU Architecture:Any
Tags: legacy mysql c

[22 Mar 2020 14:46] Terry Warren
Description:
cannot compile c program using the c headers from the /mysql-connector-c++-8.0.19 package. When I compile the program it produces an error message that the reference to <map> cannot be resolved.

The documentation indicates that the 8.0 CPP connector includes headers/libraries for execute legacy c mysql programs but does not explain how to do so.

How to repeat:
create command line  c project in Xcode 11

add header search path for the installed cpp 8.0 connector (eg /usr/local/mysql-connector-c++-8.0.19/include)

add include statement in sample program .c file for:

#include <mysql/jdbc.h>

attempt to build program

program build fails with error: 'map' file not found connection.h

The referenced connection.h files includes the line:

#include <map>
[12 May 2020 5:59] MySQL Verification Team
Hi,

I doubt this is a bug, but can you please share your problematic sample with us so we can help you build it

best regards
Bogdan
[12 May 2020 19:11] Terry Warren
regarding sample program - the steps to reproduce the error message are given in the original bug report:

create command line c program in Xcode 11

add header search path for the installed cpp 8.0 connector (eg /usr/local/mysql-connector-c++-8.0.19/include) recursive

add include statement in sample program .c file for:

#include <mysql/jdbc.h>

attempt to build program

program build fails with error: 'map' file not found connection.h
[12 May 2020 20:01] Terry Warren
NOTE: if you can't use Xcode to replicate problem then just create sample c program, for example, test1.c:

#include <stdio.h>
#include <mysql/jdbc.h>

int main(int argc, const char* argv[]) {
  printf("Hello");
}

compile using command line:

gcc -I /usr/local/mysql-connector-c++-8.0/include test1.c

Get compiler error:

In file included from test1.c:2:
In file included from /usr/local/mysql-connector-c++-8.0/include/mysql/jdbc.h:31:
In file included from /usr/local/mysql-connector-c++-8.0/include/mysql/../jdbc/mysql_connection.h:36:
/usr/local/mysql-connector-c++-8.0/include/mysql/../jdbc/cppconn/connection.h:36:10: fatal error: 
      'map' file not found
#include <map>
         ^~~~~
1 error generated.
[18 May 2020 6:19] MySQL Verification Team
Hi,

> gcc -I /usr/local/mysql-connector-c++-8.0/include test1.c

You cannot build C++ connector with gcc, you need g++

g++ -I /usr/local/mysql-connector-c++-8.0/include test1.c

is the way to go

Note you will also need to have boost libraries installed!

e.g.

BOGDANMBPRO:tmp bk$ g++ -I/usr/local/mysql-connector-c++-8.0.20/include/ -I/usr/local/boost_1_73_0/ bug99024.cpp -o bug99024
BOGDANMBPRO:tmp bk$ cat bug99024.cpp 
#include <stdio.h>
#include <mysql/jdbc.h>

int main(int argc, const char* argv[]) {
  printf("Hello");
}
BOGDANMBPRO:tmp bk$ 

I have not tried with XCode but I guess it's the same issue.

in good health
Bogdan