MySQL in C

This is a discussion on MySQL in C within the C Programming forums, part of the General Programming Boards category; I'm having trouble in general trying to get anything MySQL to work in C on Windows. My Code is as ...

  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    4

    MySQL in C

    I'm having trouble in general trying to get anything MySQL to work in C on Windows.

    My Code is as simple as this and it won't compile:

    Code:
    #include <mysql.h>
    #include <stdio.h>
    
    int main()
    {
    
    return 0;
    }
    My error list consists has been posted at the end. I haven't even included all of it since there is way too much. These however, are the errors in ascending order.

    This was compiled using Dev C++, but I have also tried using MinGW and Visual C with very similar if not identical errors.

    I've searched through MySQL documentation to no avail. I've installed MySQL Connector/C (libmysql) at this link: MySQL :: Download Connector/C 6.0

    I'm not exactly sure if I have placed the header files in the correct directories or not, but my program seems to at least find the mysql.h.

    Maybe I need to include some libraries when I compile but I'm so dead stuck I have no idea.

    Any help or basic guides from scratch would be extremly helpful

    Thanks, Chad.

    Code:
    Compiler: Default compiler
    Executing  gcc.exe...
    gcc.exe "C:\Documents and Settings\Chad1\Desktop\src\sql2.c" -o "C:\Documents and Settings\Chad1\Desktop\src\sql2.exe"   -fexceptions -g3  -I"C:\Dev-Cpp\include"   -L"C:\Dev-Cpp\lib"
    C:/Documents and Settings/Chad1/Desktop/ssrc/sql2.c:6:23: arpa/inet.h: No such file or directory
    C:/Documents and Settings/Chad1/Desktop/src/sql2.c:8:24: sys/socket.h: No such file or directory
    C:/Documents and Settings/Chad1/Desktop/src/sql2.c:9:25: netinet/tcp.h: No such file or directory
    C:/Documents and Settings/Chad1/Deskto/src/sql2.c:10:24: netinet/ip.h: No such file or directory
    C:/Documents and Settings/Chad1/Desktop/src/sql2.c:11:24: netinet/in.h: No such file or directory
    C:/Documents and Settings/Chad1/Desktop/src/sql2.c:12:19: netdb.h: No such file or directory
    In file included from C:/Dev-Cpp/include/mysql.h:71,
    
                     from C:/Documents and Settings/Chad1/Desktop/src/sql2.c:14:
    C:/Dev-Cpp/include/mysql_com.h:268: parse error before "SOCKET"
    C:/Dev-Cpp/include/mysql_com.h:268: warning: no semicolon at end of struct or union
    C:/Dev-Cpp/include/mysql_com.h:304: parse error before '}' token
    C:/Dev-Cpp/include/mysql_com.h:304: warning: data definition has no type or storage class
    C:/Dev-Cpp/include/mysql_com.h:418: parse error before '*' token
    C:/Dev-Cpp/include/mysql_com.h:419: parse error before '*' token
    C:/Dev-Cpp/include/mysql_com.h:420: parse error before '*' token
    C:/Dev-Cpp/include/mysql_com.h:421: parse error before '*' token
    C:/Dev-Cpp/include/mysql_com.h:422: parse error before '*' token
    C:/Dev-Cpp/include/mysql_com.h:423: parse error before '*' token
    C:/Dev-Cpp/include/mysql_com.h:424: parse error before '*' token
    C:/Dev-Cpp/include/mysql_com.h:425: parse error before '*' token
    C:/Dev-Cpp/include/mysql_com.h:428: parse error before '*' token
    C:/Dev-Cpp/include/mysql_com.h:429: parse error before '*' token
    C:/Dev-Cpp/include/mysql_com.h:437: parse error before "s"
    
    In file included from C:/Documents and Settings/Chad1/Desktop/src/sql2.c:14:
    C:/Dev-Cpp/include/mysql.h:237: parse error before "NET"
    
    C:/Dev-Cpp/include/mysql.h:237: warning: no semicolon at end of struct or union
    C:/Dev-Cpp/include/mysql.h:262: `scramble' redeclared as different kind of symbol
    C:/Dev-Cpp/include/mysql_com.h:511: previous declaration of `scramble'
    C:/Dev-Cpp/include/mysql.h:264: conflicting types for `unused2'
    C:/Dev-Cpp/include/mysql_com.h:283: previous declaration of `unused2'
    C:/Dev-Cpp/include/mysql.h:264: conflicting types for `unused3'
    C:/Dev-Cpp/include/mysql_com.h:285: previous declaration of `unused3'

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,158
    It looks like your MySQL installation is confused, and thinks it's on a UNIX system. Those are UNIX system headers being referred to...
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    4
    Is there a way to correct this or do I have to re-install MySQL?

  4. #4
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,158
    Quote Originally Posted by eXist View Post
    Is there a way to correct this or do I have to re-install MySQL?
    I've never tried installing MySQL dev on a Windows box. Did you follow the Windows-specific installation instructions?
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    4
    All I want to do is use the C API as seen here: MySQL :: MySQL 5.0 Reference Manual :: 20.9.2 C API Function Overview

    in order to use C to connect to an online database. I don't see why I would have to install a MySQL server on my computer in order to do that.

    Better yet, it doesn't even have to be through a database. I just want to be able to take information that the program generates from a computer, and export it online either to a database, file, or where ever I can get it.
    Last edited by eXist; 05-13-2009 at 10:26 AM.

  6. #6
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,158
    Quote Originally Posted by eXist View Post
    All I want to do is use the C API as seen here: MySQL :: MySQL 5.0 Reference Manual :: 20.9.2 C API Function Overview

    in order to use C to connect to an online database. I don't see why I would have to install a MySQL server on my computer in order to do that.
    You don't have to install the SERVER, you need to install the CLIENT LIBRARY. And this library must be configured for Windows. Right now, it looks like what you did is unpack the archive and try to start using it. You need to follow the installation instructions.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Change detection in MySQL.
    By amitbora27 in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 05-13-2009, 10:34 AM
  2. MySQL libraries
    By csonx_p in forum C++ Programming
    Replies: 6
    Last Post: 10-02-2008, 02:23 AM
  3. About C++ and MySQL or oether free database
    By xxxrugby in forum C++ Programming
    Replies: 18
    Last Post: 12-30-2005, 05:28 AM
  4. Get data from mysql and use in a system.
    By smaakage in forum Tech Board
    Replies: 3
    Last Post: 10-04-2005, 12:03 PM
  5. Get data from mysql and use in a system.
    By smaakage in forum C++ Programming
    Replies: 5
    Last Post: 10-02-2005, 01:25 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21