"User lib not found" -- WinXP vs. Win98

Archives Forums/Win32 Discussion/"User lib not found" -- WinXP vs. Win98

soja(Posted 2005) [#1]
I'm got a conundrum here. Here's my situation. I have:

a) a small and simple DLL that I wrote in Visual C++ .NET (linking to standard libs, no MFC or ATL)
b) a test program that I wrote in BlitzPlus

When I run the test program (with the DLL in the same folder), it works perfectly. The problem? If I then copy the exact same executable and DLL to a Win98 box, it fails with "User lib not found" as soon as the program tries to call one of the functions in my DLL. What gives?

Before I try fiddling with linker settings, pragma directives, and different C compilers, I thought I try here. Questions:

1) What does Blitz do when an external function is called. LoadLibrary? What else?
2) What would be the difference between the Win98 and WinXP environments that would cause it to work in one and not the other? Remember, the executables are identical.

If any more info is needed (declarations, def file, linker options, etc), I'll be glad to provide. Thanks for any input.


Perturbatio(Posted 2005) [#2]
does the 98 machine have .net installed?


soja(Posted 2005) [#3]
No. However, I don't think that's it, because I'm not using anything in .NET (at least that I know of (??))...

I actually used the New Project wizard to create a "Visual C++ Project -> General -> Extended Stored Procedure DLL", and then just modified that. Nothing fancy (i.e. .NET, ATL, MFC, etc).

I've had similar issues, though, ("user lib not found") even when using other compilers, link ming (I think) via Bloodshed, so it really makes me wonder what's going on under the hood.


Azathoth(Posted 2005) [#4]
Are you linking with MSVCR71.DLL with the /MD option? If so does the Win98 have it?


soja(Posted 2005) [#5]
Yes, I am compiling with the /MD option, and YES, it needed msvcr71.dll! Thank you very much!

In retrospect, I suppose I should have looked at the import table for my DLL. It needs kernel32.dll, user32.dll, and... msvcr71.dll. I just thought the "user lib not found" error was for the functions in _my_ DLL, which was thoroughly confusing.

More info from MSDN:
Applications compiled with [the /MD] option are statically linked to MSVCRT.lib. This library provides a layer of code that allows the linker to resolve external references. The actual working code is contained in MSVCR71.DLL, which must be available at run time to applications linked with MSVCRT.lib.

...and...
An application should use and redistribute msvcr71.dll, and it should avoid placing a copy or using an existing copy of msvcr71.dll in the system directory. Instead, the application should keep a copy of msvcr71.dll in its application directory with the program executable. Any application built with Visual C++ .NET using the /MD switch will necessarily use msvcr71.dll.


Incidentally, can you suggest any other options I might have besides using msvcr71.dll? I'm trying to make (a) the smallest DLL with (b) the most compatibility that I can. I imagine I could try out older and/or different compilers with different C libraries, but I'd value an experienced opinion at the moment.

Thanks again.


Azathoth(Posted 2005) [#6]
You can statically link with /ML for single-threaded or /MT for multi-threaded, your DLL will be bigger since it contains some msvcr71.dll code but you won't need to copy msvcr71.dll to machines that don't have it. There are also problems if the program running your DLL also links to msvcr71.dll.


soja(Posted 2005) [#7]
Yes, actually, I did try that, and noticed that it imported a bunch more functions from kernel32 instead, and was slightly bigger. Unfortunately, when I tried it, I got "user lib not found" again. <shrug> Wondering if it used some functions that weren't in the Win98 version of kernel32, I copied the kernel32.dll over from my XP box, but it didn't make any difference either.


Azathoth(Posted 2005) [#8]
Um. Have you written a DllMain function? Does it at all get called before you get the error message?


Sarge(Posted 2005) [#9]
Hi the only tips i can give are the following

1: Try the dll in another programming language see if it works

2: Post the dll here so we can test it


soja(Posted 2005) [#10]
aeiou, yes, I have written a DLLMain function. (Even if I didn't though, the linker would have put a stub in.) I'm not sure if it gets called before I get the error message -- I suppose I can put some debug code in there and test that. Good idea.

Sarge, good ideas too.

If all else fails, it can still be distributed with msvcr71.dll and it should work, but I appreciate your input all the same.