0

I'm trying to make a program to load MySQL database.

The code compiles fine, but when it comes time to execute is, I have .dll errors.

My Dev C++ project settings so far:

PARAMETERS

  • Linker: "-lmysql"

DIRECTORIES

  • Library Directories: C:\Program Files\MySQL\MySQL Server 8.0\lib Include Directories: C:\Program Files\MySQL\MySQL Server 8.0\include C:\Program Files\MySQL\MySQL Server 8.0\include\mysql C:\Program Files\MySQL\MySQL Server 8.0\include\openssl

COMPILING LOG

Compiling project changes...
--------
- Project Filename: C:\Users\domag\Desktop\Aplikacija\SQL\Project1.dev
- Compiler Name: TDM-GCC 4.9.2 64-bit Release

Building makefile...
--------
- Filename: C:\Users\domag\Desktop\Aplikacija\SQL\Makefile.win

Processing makefile...
--------
- Makefile Processor: C:\Program Files (x86)\Dev-Cpp\MinGW64\bin\mingw32-make.exe
- Command: mingw32-make.exe -f "C:\Users\domag\Desktop\Aplikacija\SQL\Makefile.win" all

mingw32-make.exe: Nothing to be done for 'all'.


Compilation results...
--------
- Errors: 0
- Warnings: 0
- Output Filename: C:\Users\domag\Desktop\Aplikacija\SQL\Project1.exe
- Output Size: 1,83359909057617 MiB
- Compilation Time: 0,11s

And finally the CODE:

#include <iostream>
#include <mysql.h>
#include <mysqld_error.h>

char HOST[] = "ip.ip.ip.ip";
char USER[] = "user";
char PASS[] = "pass";

using namespace std;

int main() 
{
    MYSQL* obj;
    
    if(!(obj = mysql_init(0)))
        {
            cout << "error" << endl;
        }
        else
        {
            if(!mysql_real_connect(obj, HOST, USER, PASS, USER, 3306, NULL, 0))
                {
                    cout << "error with info" << endl;
                    cout << mysql_error(obj) << endl;
                }
                else
                    {
                        cout << "success" << endl;
                    }
        }
    
    
    
    
    
    return 0;
}

`

Process exited after 36.17 seconds with return value 3221225781 Press any key to continue . . . `

Error 1/2 Error 2/2

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Pena
  • 1
  • 2
    Unrelated: GCC 4.9.2 is ancient. Use non-ancient compiler (like the one that ships with this modern [Dev-C++ fork](https://github.com/Embarcadero/Dev-Cpp)) – Botje Mar 22 '23 at 21:56
  • All we can really say is: your program cannot find these DLL files. Where are they on your system? Are they packaged somewhe under C:\Program files\mysql\...? – Botje Mar 22 '23 at 21:57
  • 1
    Possibly these dlls are not in the same place as your executable or they are not in a folder that is in your PATH environment variable so your OS can't find them when it goes to run your application. See here for how Windows searches for dlls: [https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#standard-search-order-for-unpackaged-apps](https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#standard-search-order-for-unpackaged-apps) – drescherjm Mar 22 '23 at 22:23
  • 1
    Note that neither linker nor include settings have anything at all to do with the location of the dll and how your OS looks for the dll. – drescherjm Mar 22 '23 at 22:35

0 Answers0