Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Resource loading fails in a static library (.lib)

Resource loading fails in a static library (.lib)

Scheduled Pinned Locked Moved C / C++ / MFC
debuggingc++helpquestionlearning
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mr Accident
    wrote on last edited by
    #1

    Hey all. I had a DLL project (using MFC) that I recently decided to convert to a statically-linked library. Everything seemed to go smoothly, but when I try to use my library in a test application, all the resource-loading calls in the library fail. That is to say, the library project has a resource file containing some resources used in the library; a string table, a couple of bitmaps, a dialog box or two, etc. Elsewhere in the library code, there's a routine that, say, wants to get a string from the string table. So I have something like this: CString str; VERIFY(str.LoadString(IDS_STRINGID); When I run an application that uses this part of the library, the LoadString() function fails (returns 0). The same seems to apply for dialog boxes, bitmaps, and all other resources. A quick debug trace revealed that it was passing the correct numeric value for the resource ID; it just seemingly could not load the resource. I've never tried making a static library containing resources before, so I really have no idea what needs to be done. I'm assuming there is something in particular that I need to do so that the resources can be loaded correctly from the library. Does anyone know what I could do in this situation? Any help would be greatly appreciated.

    R 1 Reply Last reply
    0
    • M Mr Accident

      Hey all. I had a DLL project (using MFC) that I recently decided to convert to a statically-linked library. Everything seemed to go smoothly, but when I try to use my library in a test application, all the resource-loading calls in the library fail. That is to say, the library project has a resource file containing some resources used in the library; a string table, a couple of bitmaps, a dialog box or two, etc. Elsewhere in the library code, there's a routine that, say, wants to get a string from the string table. So I have something like this: CString str; VERIFY(str.LoadString(IDS_STRINGID); When I run an application that uses this part of the library, the LoadString() function fails (returns 0). The same seems to apply for dialog boxes, bitmaps, and all other resources. A quick debug trace revealed that it was passing the correct numeric value for the resource ID; it just seemingly could not load the resource. I've never tried making a static library containing resources before, so I really have no idea what needs to be done. I'm assuming there is something in particular that I need to do so that the resources can be loaded correctly from the library. Does anyone know what I could do in this situation? Any help would be greatly appreciated.

      R Offline
      R Offline
      rschuler
      wrote on last edited by
      #2

      I have the same problem - cannot load resources that are compiled into the static library. I know that a solution to the problem exists because there are resources in the static MFC library. When I compile using VS 2002 I get warning on the .res file corresponding to the .rc file in the static library. warning LNK4221: no public symbols found; archive member will be inaccessible I think that may be a clue to the answer. Did you ever find an answer? Thanks -Rodney

      M 1 Reply Last reply
      0
      • R rschuler

        I have the same problem - cannot load resources that are compiled into the static library. I know that a solution to the problem exists because there are resources in the static MFC library. When I compile using VS 2002 I get warning on the .res file corresponding to the .rc file in the static library. warning LNK4221: no public symbols found; archive member will be inaccessible I think that may be a clue to the answer. Did you ever find an answer? Thanks -Rodney

        M Offline
        M Offline
        Mr Accident
        wrote on last edited by
        #3

        Actually, I did find a solution! I did a little hunting around on Google, and I found this page: http://www.differentpla.net/~roger/devel/tips/vc/resources_in_libs/[^] It's not an incredibly elegant solution, but it's very simple, easy to use, and it works well. (On Visual Studio 6, at least; I assume it will work equally well on VS 2002, but I haven't tried it. ...Come to think of it, I've been using VS 6 ever since it came out. Oh well, if it ain't broke, don't fix it! ;)) [Insert witty and relevant signature here]

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups