I had written a DLL to be used with SWIG and Perl. It worked fine on my laptop (with Visual Studio 8 installed). However, if I moved it to another laptop, perl would refuse to load the associated module file with an error that said something to the effect that "it could not load the module because the application was incorrectly configured". I should paste the exact text, but I don't have it with me right now.
To make a long story short, this means that either the main DLL is not there, or one of the linked DLLs is not there. I knew the main DLL was there, but it turned out that the problem was that I had used the DEBUG build, which uses the debug version of the CRT (C runtime) library. As a check, I copied the debug version of the MSCRT*D.DLL to the other laptop and it magically worked!
The long term solution here was to rebuild using the Release build. This means,
Properties->Configuration Properties->C/C++->Code Generation->Runtime Library = Multi-threaded DLL (/MD)
This option has to be set for ALL projects that end up in the final DLL. It is a compiler option, not a linker option, which doesn't make any sense to me. But it is.
Case closed.
So I thought.
Then I pressed onwards and installed on another (older) laptop. Same error message. But in this case, I realized that I was compiling with VS 2003, which is newer than WinXP. I realized that maybe the laptop does not have the latest service pack. So I copied the redistributable DLLs for the CRT (C:/Program Files/Microsoft Visual Studio 8/*/*/redist/*CRT*/*.DLL) and everything worked!
Case doubly closed!
Now the perl module loaded properly. But then when the perl script tried to launch another application (in the same directory), I got a new fault message! To make this long story short, yet again, I needed the MFC8 and MFCLOC8 libaries to get the application to run.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment