linker problem with mysql

This is a discussion on linker problem with mysql within the C++ Programming forums, part of the General Programming Boards category; Hi, I am trying my hands on compiling a C program using the API from mysql. The below is my ...

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    1

    linker problem with mysql

    Hi,

    I am trying my hands on compiling a C program using the API from mysql. The below is my simple program:
    Code:
    #include <stdio.h>
    #include <mysql.h>
    
    MYSQL	*conn;
    
    int main(int argc, char *argv[])
    {
    	printf("Hello, world and Goodbye\n");
    }
    I manage to compile using the below:

    C:\project\code>cl -c -I "C:\Program Files\MySQL\MySQL Server 4.1\include" clien
    t1.c
    Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
    Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

    client1.c


    However when linking I got the following error:

    C:\project\code>cl client1.obj -link
    Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
    Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

    Microsoft (R) Incremental Linker Version 7.10.3077
    Copyright (C) Microsoft Corporation. All rights reserved.

    /out:client1.exe
    client1.obj
    client1.obj : error LNK2019: unresolved external symbol _mysql_close@4 reference
    d in function _main
    client1.obj : error LNK2019: unresolved external symbol _mysql_real_connect@32 r
    eferenced in function _main
    client1.obj : error LNK2019: unresolved external symbol _mysql_init@4 referenced
    in function _main
    client1.exe : fatal error LNK1120: 3 unresolved externals

    Thanks in advance

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,673
    I'm guessing there is an actual mysql library you are forgetting to link in for that last step there.
    I used to be an adventurer like you... then I took an arrow to the knee.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linker problem... no idea
    By cyreon in forum C Programming
    Replies: 2
    Last Post: 04-03-2009, 02:53 PM
  2. Linker problem with template traits/policy on MSVS 2005
    By MarkZWEERS in forum C++ Programming
    Replies: 3
    Last Post: 10-24-2008, 04:01 AM
  3. Nasty linker problem; multiply defined
    By ahluka in forum C++ Programming
    Replies: 4
    Last Post: 09-02-2005, 03:06 PM
  4. Problem with MYSQL
    By maxorator in forum C++ Programming
    Replies: 9
    Last Post: 08-25-2005, 02:33 AM
  5. Dev C++/mySQL linker errors
    By WDT in forum C Programming
    Replies: 2
    Last Post: 03-30-2004, 02:40 PM

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