Menu

How to link with Dev-C++ to MySQL *.lib

2003-12-11
2012-09-26
  • Nobody/Anonymous

    I have tried in many ways how to link a project that I made with Dev-C++. With Visual C++ I have no problems, but...
    It says something like mysql_init@4.
    I don't know what is it...
    Help me

     
    • Kip

      Kip - 2003-12-11

      -lmysql =)

      Kip

       
      • Nobody/Anonymous

        .c app
        dev-cpp version:
        Dev-C++ 5.0 beta 9 (4.9.9.0) with Mingw/GCC

        downloaded and installed MySQL Dev-PAK

        hedder code:
        #include <time.h>
        #include <stdio.h>
        #include <winsock.h>
        #include <MySQL/mysql.h>

        Compile Log:

        Compiler: Default compiler
        Building Makefile: "C:\Dev-Cpp\projects\mysql1\Makefile.win"
        Executing  make clean
        rm -f mysql1.o  mysql1.exe

        gcc.exe -c mysql1.c -o mysql1.o -I"C:/Dev-Cpp/include"    -ansi

        gcc.exe mysql1.o  -o "mysql1.exe" -L"C:/Dev-Cpp/lib" -L"C:/Dev-Cpp/lib/MySQL" -mwindows 

        mysql1.o(.text+0x9b):mysql1.c: undefined reference to `mysql_init@4'
        mysql1.o(.text+0xe4):mysql1.c: undefined reference to `mysql_real_connect@32'
        mysql1.o(.text+0xfe):mysql1.c: undefined reference to `mysql_error@4'
        mysql1.o(.text+0x12b):mysql1.c: undefined reference to `mysql_query@8'
        mysql1.o(.text+0x148):mysql1.c: undefined reference to `mysql_error@4'
        mysql1.o(.text+0x16d):mysql1.c: undefined reference to `mysql_store_result@4'
        mysql1.o(.text+0x17e):mysql1.c: undefined reference to `mysql_num_rows@4'
        mysql1.o(.text+0x1a0):mysql1.c: undefined reference to `mysql_fetch_row@4'
        mysql1.o(.text+0x21b):mysql1.c: undefined reference to `mysql_free_result@4'

        mysql1.o(.text+0x229):mysql1.c: undefined reference to `mysql_close@4'

        make.exe: *** [mysql1.exe] Error 1

        Execution terminated

        Read your link so included the mysql lib folder to the Lib directories through compiler options.

        Was hoping for a bit more direction
        Thanks AL

         
    • Wayne Keen

      Wayne Keen - 2004-08-24

      "Read your link so included the mysql lib folder to the Lib directories through compiler options"

      That is not the right way to do it if your are using a project, and you are.  The project options for linking over-write the compiler options, which is why there is no link command to be seen in your log, i.e no:

      -lmysql

      Wayne

       
    • Wayne Keen

      Wayne Keen - 2004-08-24

      At the rsik of stating what may be obvious to you, note that:

      -L"C:/Dev-Cpp/lib/MySQL"

      Is not a link command, it simply adds a directory to the library search path...

      Wayne

       
    • Nobody/Anonymous

      Yea ok remember the difference now ... thank you.

      Is it (and how is it) possible to link the library to the project in Dev-Cpp so that it will be compiled& built with one click

       
    • Wayne Keen

      Wayne Keen - 2004-08-24

      I wrote a section in the thread titled "The Forum FAQ - Please Read First" on the compile log, headers and linking libraries which I think gives you what you are looking for...

      Wayne

       
    • Nobody/Anonymous

      Hi again.
      Ok, I'v now linked the -lmysql

      compiles fine (or so it seems)

      compile Log:
      Compiler: Default compiler
      Building Makefile: "C:\Dev-Cpp\projects\mysql1\Makefile.win"
      Executing  make clean
      rm -f mysql1.o  mysql1.exe

      gcc.exe -c mysql1.c -o mysql1.o -I"C:/Dev-Cpp/include"    -ansi

      gcc.exe mysql1.o  -o "mysql1.exe" -L"C:/Dev-Cpp/lib" -L"C:/mysql/lib" -mwindows -lmysql ../../lib/libmySQL.a 

      Execution terminated
      Compilation successful
      ..........................
      when I run the app I get a error "Unable to Locate Component"
      fialed to start because libmySQL.dll was not found.

      I've moved the file around to various dirs but no joy!!

      When I placed the Dll in the project dir the prog runs but does nothing not even a printf statement (towards the start of the code).

      Any suggestions?

      From the compile log you can see I have liked the Lib both methods suggested. I've tried each method seperatly and then at the end both together.

       
      • Wayne Keen

        Wayne Keen - 2004-08-25

        Generally, you dll's should be in either your Dev bin directory or your windows system32 directory.  Think of them as being where an executable or a binary would be.

        Wayne

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.