CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2003
    Posts
    260

    Help: Statically linked MFC DLL not working

    Hi all,
    I have tried to build a MFC that is statically linked, I have been tracing the problem. I noticed that for my resource DLL it wasn't getting loaded by LoadLIbrary, the error code returned is 126, which is module not found.

    But I have also use the call to check if the path exists, and it returns fine. So the problem is not the path, plus, I was able to load the resource DLL when I have VS installed.

    This is really to my surprise, since I thought by linking statically I would not need the MFC71.DLL, however, I noticed if I had this file copied to the same directory, but the LoadLibrary does not fail.

    My question is of course how to solve this. I have tried changing LoadLibrary() to AfxLoadLibrary() but I was getting compiler error that this call can't be found with look-up, so I added the "_AFXDLL" to the project, well, the compile works, but I see the application calls to MFC.DLL with an error msg pop-up, which brings me back to my very problem.

    Questions:
    1. How would linking statically be failing with LoadLibrary (error code: 126) which goes away when MFC.DLL is included?

    I don't know what to do now. I have read sevearl posts. But most of posts about LoadLibrary failure has to do asking if the file path is correct..etc, and I haven't seen posts about linking statically still requiring MFC.DLL.

    Totally clueless. Please let me know if more info is needed..

    Thanks for any help,
    Jiac

  2. #2
    Join Date
    Jul 2003
    Posts
    260

    Re: Help: Statically linked MFC DLL not working

    Hi All,

    Perhaps I should rephrase my question, has anyone able to create and load resource files w/ using LoadLibrary() via statically linked to MFC?

    Also an attempt to get a response.

    Thanks,
    Jiac

  3. #3
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Help: Statically linked MFC DLL not working

    Man, the issue of this kind cannot be solved by abstract "talking about". It would be good to see some code sample.

    You tries to solve the problem by the "shooting into the dark" method. I cannot say it's quite effective. As I can understand you tries to build your MFC project with statically linked MFC code. This purpose contradicts to _AFXDLL usage, since the latter tells that you intend to use MFC shared dll.

    LoadLibrary problem cannot depend on the way of MFC code linkage because this is a system call wich works the same way always. You must just debug your code fragment.

    Can you show us that resource dll? Is it ok? Did you try to load it by some other code (plain WinAPI for example)?
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured