Solved

Fatal Error LNK1181: cannot open file mfc30.lib

Posted on 2011-09-14
16
669 Views
Last Modified: 2012-05-12
Hi Experts,

I get this error when I build an MFC application in release mode at a couple of PC's. At these machine, I get a clean build in debug mode.  On some other PC's where this application resides, I don't even have the mfc30.dll, yet the build in release mode is clean.  How can I avoid this error?  I am using Visual Studio 6.0 C++ on Windows XP.

Thanks in advance.
0
Comment
Question by:ChiliPequin
  • 6
  • 6
  • 2
  • +2
16 Comments
 
LVL 7

Accepted Solution

by:
tampnic earned 50 total points
Comment Utility
mfc30.lib is required for a static link to MFC. Are you linking to MFC statically or dynamically in your project options?

mfc30.lib could be either missing or corrupted - if I remember correctly you need Visual C++ Professional to have the MFC libraries installed - are you sure that its not VC++ 6 Standard edition on the machines where your project won't build.

An alternative is that the location of mfc30.lib is not in your linker input path. I would search the file-systems of the PC's where the app won't build to see if the mfc30.* files exist first, then go to project options to make sure they are on the linker input path.

Cheers,
  Chris
0
 
LVL 7

Assisted Solution

by:Slimfinger
Slimfinger earned 50 total points
Comment Utility
a) You get this when you build a particular MFC app, or ANY MFC app?
b) Are you using the exact same project on each machine?  (Does one project include that .lib while another does not?)
c) The presence of the dll should not matter (it's looking for a .lib file)
0
 
LVL 30

Assisted Solution

by:Zoppo
Zoppo earned 100 total points
Comment Utility
Hi ChiliPequin,

a strange thing is that VC++ 6 doesn't use MFC30.DLL (which is part of the very old Visual C++ 2.0). With VC++ 6 the MFC library has been implemented in MFC42.DLL and MFC42.LIB.

Does your project use any libraries which are not built with your project, i.e. some third-party libraries? It could be such a library is built with older version so MFC30.* are needed.

Beside this the answers to Slimfinger's would be helpful ...

ZOPPO
0
 
LVL 32

Assisted Solution

by:sarabande
sarabande earned 300 total points
Comment Utility
i have vc6 and vc9 (vs2008) installed on my notebook, but neither mfc30.lib nor mfc30.dll. i would assume it came with vc5 or older and the problem comes from not having made correctly distinct installations on the computers such that now is a mix between old and new dlls.

mfc version wasn't the same as vc version in the nineties. i think mfc 3.0 was shipped with vc4 or vc5.

Sara
0
 

Author Comment

by:ChiliPequin
Comment Utility
Hi Experts,

Thank you very much for your fast response.

I have the Professional version installed.  
I copy the same project from the machine that works to this machine.
I use VC++6, so I don't think it use MFC30.

I do suspect that one of the third party controls I use built under the old version MFC30.LIB.  There are a few of these controls. The application is built clean in debug mode, however.  

I will update as soon as I find out.



0
 
LVL 32

Assisted Solution

by:sarabande
sarabande earned 300 total points
Comment Utility
for the build, only the mfc30.lib was needed. if you have a computer where the mfc30.lib exists and the mfc30.dll is missing, the build would be ok but at runtime you only get problems if the mfc30.dll really was used (from the third-party) what is good possible that it never happens.

you should look with dependency walker (depends.exe) which module needs the mfc30.lib. then try to get an update.

Sara
0
 

Author Comment

by:ChiliPequin
Comment Utility
Hi sarabande,

Thanks so much for your advice.  I will download depends.exe and try to find out if there is a component that uses mfc30.lib.  What's strange is that at one of my PC, I do not have mfc30.lib nor mfc30.dll, yet the same application is built clean and run fine in both debug and release mode.
0
 
LVL 32

Assisted Solution

by:sarabande
sarabande earned 300 total points
Comment Utility
yes, that's strange but microsoft made some tricks in the nineteens to find the correct mfc and c runtime libraries by default and less by explicit specificition. so the executable built when no mfc30.lib existed, shouldn't have a reference to mfc30.dll neither.

Sara
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 30

Assisted Solution

by:Zoppo
Zoppo earned 100 total points
Comment Utility
What third-party controls are you using? Is there any third-party control with some kind of SDK which has to be installed? If so maybe there are different versions installed on different machines or the SDK wasn't installed properly on some machines ...
0
 

Author Comment

by:ChiliPequin
Comment Utility
Hi Zoppo,

The third-party controls I use are gtmask32, gtdate32, gtnum32.  I have downloaded the dependency walker program and run it on the PC that does not have the problem.  I do not see any component using mfc30.  I try to run it on the PC with problem using the debug dll, I do not see any component using mfc30.  It seems like the dependency walker only shows the DLL'S.  It does not show any LIB file.  I am going to deinstall Visual Studio and reinstall it.

Thanks.
0
 
LVL 32

Assisted Solution

by:sarabande
sarabande earned 300 total points
Comment Utility
it  is ok that dependency walker only shows dlls. the lib is the import lib what means it contains wrapper functions which do the call into the dll. the import library is only a matter of the linker.

but if you see mfc30.dll with depends.exe you can see which executable (dll or exe) needs it by looking at tthe "parent" nodes in the tree shown in depends.

Sara
0
 
LVL 32

Assisted Solution

by:sarabande
sarabande earned 300 total points
Comment Utility
i don't think that reinstalling the visual studio will change anything cause the wrong paths/controls/libraries already might exist on the computer outside of visual studio. so if you don't have a "clean" computer to install on, you probably will get the same issues again.

Sara
0
 
LVL 32

Assisted Solution

by:sarabande
sarabande earned 300 total points
Comment Utility
third party controls rarely are the cause of the linker errors beside they would have an own sdk as Zoppo has already mentioned. normal active-x controls don't have import libraries to add to your project linker input but were accessed via COM interface. only if controls could be taken as a base for your own controls, they would need libraries to be added to your project and that way could generate dependencies to other dlls like mfc30.dll.

Sara
0
 

Author Comment

by:ChiliPequin
Comment Utility
Hi Sarabande,

Thanks so much for your advice.  You are right, I de-install VS then re-install.  But the problem still persists.  I think I know the lib files that cause this error.  When I replace these lib files with the their debug version in the link tab, the link error mfc30.lib is gone, but I now get the warning LNK4098 for the mfc42d lib files.  I run depends.exe to check the suspected lib files, but I have not found any reference to MFC30.DLL.  The only thing I notice is that these DLL's have only MFC32U.DLL and not MFC32.DLL.  I will update as soon as I find anything new.
0
 

Author Comment

by:ChiliPequin
Comment Utility
Sorry for the typo.  I mean these DLL's have only MFC42U.DLL and not MFC42.DLL.
0
 

Author Comment

by:ChiliPequin
Comment Utility
Hi experts,

Thank you all for your advice on this error.  Your opinion has helped me learned a lot.  I use the workaround on the PC with problem (use the debug lib of the third party component to buid the release with warning) for now.  

Your help is greatly appreciated.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now