@@ -14,29 +14,7 @@ By Default g++ uses clang compiler which comes with Xcode which is not a genuine
14
14
4 . sudo port select --set gcc mp-gcc46
15
15
5 . Now check again gcc --version it should Say (gcc (MacPorts gcc46 4.6.4_11) 4.6.4) ...
16
16
17
+ ..................
17
18
18
- Installing and running mysql
19
- 1 . brew install mysql
20
- 2 . g++ -o demo1 -I/usr/local/include -I/usr/local/include/mysql -W -lmysqlclient -L/usr/local/lib demo1.cpp
21
- 3 . Run ./demo1
22
19
23
- ### Using Mysql Connector CPP
24
- STEP 1 - Connector
25
- 1 . Download Mysql C++ Connector for Mac OS from here https://dev.mysql.com/downloads/connector/cpp/
26
- 1 . Extract cppconn direcotry and mysql_connection.h, mysql_driver.h, mysql_error.h file to the root direcotry of your application
27
-
28
- STEP 2 - CREATE DYLIB file from cpp connector using the same compiler we are using to compile our code
29
- git clone https://github.com/mysql/mysql-connector-cpp .
30
- git checkout 1.1
31
- git tag
32
- git checkout tags/1.1.9
33
- which g++
34
- which gcc
35
- cmake -DCMAKE_C_COMPILER=/opt/local/bin/gcc -DCMAKE_CXX_COMPILER=/opt/local/bin/g++ .
36
- make
37
- make install
38
- You should find dylib files in driver director and copy those files to the same directory where your code exists
39
-
40
- STEP 3 - RUNNING CODE
41
- g++ -o demo -I/usr/local/include -I/Volumes/D/www/c++ -L. -lmysqlcppconn demo.cpp
42
- ./demo
20
+ Read full article here https://medium.com/@khanakia/how-to-connect-to-mysql-using-c-in-mac-osx-17e1ada42ccd
0 commit comments