Thread: Linker Error???

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    193

    Linker Error???

    [Linker error] undefined reference to `mysql_init@4'

    I got a lot of these errors depending on what mysql function I'm calling. Is there any way to fix this? I'm calling the right header file and I'm using Dec-C++. Any help is apprecaited.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    You need to link to the mysql library. I'm not sure how to do this with dev-cpp, but someone here can probably tell you.

  3. #3
    Registered User
    Join Date
    Aug 2004
    Posts
    193
    Wouldn't I have linked the MySQL library since that's the only type of error I get. I have about 20 Linker Errors saying undefined reference to 'mysql_"function"@x'. I also have:

    MYSQL *myDatabase = NULL;

    and it doesn't return an error. MYSQL is like int or char I believe.

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    MYSQL *myDatabase = NULL;

    That wont give you a link error, because it's probably defined in the header. You will get an error trying to call a function though, because you have to link to the library. Someone needs to tell you how to link to libraries in dev-cpp.

  5. #5
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Here, read this:

    http://www.dvrsol.com/programming.html#mymingw

    scroll down to the part that reads:
    MySQL and MinGW (developing MySQL clients in C with Dev-C++)

  6. #6
    Registered User
    Join Date
    Aug 2004
    Posts
    193
    Quote Originally Posted by bithub
    MYSQL *myDatabase = NULL;

    That wont give you a link error, because it's probably defined in the header. You will get an error trying to call a function though, because you have to link to the library. Someone needs to tell you how to link to libraries in dev-cpp.
    Oh ok. I understand. I don't know how to link to libraries.

  7. #7
    Registered User
    Join Date
    Aug 2004
    Posts
    193
    I found out how and it works. I just get an error when I run the program and thats the part connecting to my database.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  2. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 05:27 AM