views:

597

answers:

2

I'm on a Windows machine. This seems like it should be unnecessary, but when I do it, everything suddenly works. Is there something wrong with my path? Do I need to add something to it to avoid having to copy DLLs?

+1  A: 

I donot know the internals of MySQL and apache.

My thought is this. Internal of your application is using libmysql.dll. And it seems that path is not proper so it searches in PATH environmental variable. apache/bin will be there in PATH directory. So it is taking the dll from this path. If the dll is not present in that path I think it fails to load and hence fails.

EDIT: Added the solutions which were added in comments

  1. Try rebooting your machine. I had the same issue with mysqlpp library. Path was pointing to mysql bin dir but it still couldnt find libmysql.dll – Daniel (Jan 26 at 6:55)

  2. Apache might be running with credentials different from your own (almost certainly so if you're running it as a service.) Try placing the dirs in the SYSTEM path, not the USER path. – moocha (18 hours ago)

Vinay
Bingo, that's it.
Mihai Limbășan
But my PATH actually has the PHP directory and doesn't have the Apache/bin directory. Maybe there is something I'm not understanding, but I thought since the PHP directory is in the PATH, everything should be fine.
Bialecki
Okay, actually when I look at the phpinfo(), the PATH that Apache is using is not what I would expect. It's different than looking at the PATH from the DOS prompt. Any idea why that would be?
Bialecki
Try rebooting your machine. I had the same issue with mysqlpp library. Path was pointing to mysql bin dir but it still couldnt find libmysql.dll
Daniel
Apache might be running with credentials different from your own (almost certainly so if you're running it as a service.) Try placing the dirs in the *SYSTEM* path, not the *USER* path.
Mihai Limbășan
+1  A: 

Apache like any application will assume that the file is located in the same directory as the Current Directory path (check out http://en.wikipedia.org/wiki/Working_directory). If it's not there. The current working directory is USUALLY the same directory that httpd.exe (main executable) is in but it can actually be different if you do something like C:\Apache2>bin\httpd.exe

In this case the Current Working directory is C:\Apache2 rather than C:\Apache2\bin.

If if the file isn't found there the application will naturally traverse the PATH environment variable. The PATH environment variable is a semi-colon or comma separate list of paths) to find the file.

Start -> Run -> Type "cmd.exe" and then in the Command Prompt type "echo %PATH%" to see the current path you have.

Finally, if the file wasn't found it will just error out.

As a tip you can actually track what files an application is trying to load and where they load them from by using Process Monitor. http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx

I've used this tool to solve load DLL problems in Apache before and other applications as well. Just simply add a filter for the app you are running and have it only sniff out file reads.

Jeremy Edwards