i'm a little back wards with my c++ knowledge. I kinda got thrown into a maintenance project on an existing project so I know how most of the software works, but I find myself lost on some simple entry level things sometimes.

That was my disclaimer for not feeling foolish for asking this. I've been adding MySQL++ to a project and to say i've been wrestling with understanding how to use an external library is an understatement. I actually have it working right now. The final problem I had with it was getting a MYSQLPP.DLL not found error. I pasted the files in the local folder the app was running from and it didn't fix it. I placed them in system32 and it works fine.

For reasons I wont bother to go into this is very undesired. How do I get my software to compile so it checks the local directory for the DLL files also? I've attempted googling it, but I guess I'm failing to word it correctly cause it seems like something easily answered but I guess I suck at 'google speak'

The local directory needs to be dynamic, not a static location as other users will be pasting the software into random directories.

A quick search on google "C++ searching local directory for dll" and I found this on the first link. Hope it helps.

alright, the file i'm working with is a DLL, it doesnt have a main, but i'm assuming I can add one. I'm not 100% clear on what is making the DLL calls, here is a pretty basic example of the dll i'm working with. We'll call it example.dll.

#include "mysqlpp.h"

void example() {
    WriteFunction("this is my write function, hello!");
}

So... the main exe loads example dll up when you tell it too, so now the main has access to run example(). The problem I had was i would get mysqlpp.dll and libmysql.dll not found errors till I put them in system32, local directory of the main exe wouldn't work for whatever reason.

I'm assuming that when the include for mysqlpp.h goes off, that that file is what references the two DLL files. I looked at the site you linked, and concluded something like this would work:

#include "mysqlpp.h"
#include <iostream>

int main(int argc, char* argv[])
{
SetDllDirectory(argv[0]);
}

void example() 
{
    WriteFunction("this is my write function, hello!");
}

I found from a google search that the first arg passed to a loading file is the folder path it was loaded from.... thats what the arg[0] crap is. I don't really know if its correct or not.

Anyway... wouldn't the include mysqlpp.h go off, and hence fire off to load the 2 "missing" dll files before execution ever got to SetDLLDirectory()?

Not vary good with windows dll programming (as I'm using linux), but argv[0] is the first argument passed, meaning argv[0] would hold the command used to call the program. For example:

C:\ >myprogram.exe --help

argv[0] would be "myprogram.exe"
and argv[1] would be "--help".
To get the current path you might find GetEnvironmentVariable() usefull (although I never use it.) I'm not sure if this will work on windows, but the directory ".\" or "." should be the directory you are currently in.
Good luck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.