Solved

New to Visual C++ - Link error - fatal error LNK1104: cannot open file "nafxcw.lib"

Posted on 2004-04-12
11
3,904 Views
Last Modified: 2013-12-14
Hi all,

I'm new to Visual C++ 6, and am trying to build a project that was written by someone else (I know it works).

I've downloaded a few demonstration projects, and I can't get any of them to build (they compile ok but the build doesn't work)- what am I doing wrong?!

This particular error is
fatal error LNK1104: cannot open file "nafxcw.lib"
Now, I searched for the file, and found it in a subdirectory of Visual Studio .Net (I had that installed before I installed VC++6) but not in my VC98 folder. I have no idea what the file is, if it's relevant to this particular project or just something generally wrong with my settings,

all help appreciated, cheers.
0
Comment
Question by:shifty_mc
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 86

Assisted Solution

by:jkr
jkr earned 50 total points
ID: 10809783
>>This particular error is
>>fatal error LNK1104: cannot open file "nafxcw.lib"

Make sure that the path you found the library in is listed under "Project|Settings|Link|Additional Library Path" and it should work.
0
 

Author Comment

by:shifty_mc
ID: 10809807
I have "Additional Library Path" under the 'Input' category - this right?

Because now I get 108 errors!

Linking...
nafxcw.lib(olevar.obj) : warning LNK4044: unrecognized option "alternatename:??$HashKey@PB_W@@YGIPB_W@Z=?HashKey@@YGIPB_W@Z"; ignored
Drawwnd.obj : error LNK2001: unresolved external symbol "public: int __thiscall CWnd::CreateEx(unsigned long,char const *,char const *,unsigned long,struct tagRECT const &,class CWnd *,unsigned int,void *)" (?CreateEx@CWnd@@QAEHKPBD0KABUtagRECT@@PAV
1@IPAX@Z)
Saver.obj : error LNK2001: unresolved external symbol "public: __thiscall CString::~CString(void)" (??1CString@@QAE@XZ)
.
.
.
Release/Saver.scr : fatal error LNK1120: 13 unresolved externals
Error executing link.exe.
0
 
LVL 4

Assisted Solution

by:bkfirebird
bkfirebird earned 100 total points
ID: 10809818
go to Project|Settings|General and select Use MFC in a dynamic dll
0
 

Author Comment

by:shifty_mc
ID: 10809829
I don't have that - have "Use MFC in a Shared DLL" which is already selected?
0
 
LVL 4

Expert Comment

by:bkfirebird
ID: 10809844
I have "Additional Library Path" under the 'Input' category - this right?

go to Tools->Options->Directories Tab->Show directories for Library Files and add the path to the nafxcw.lib file there
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:shifty_mc
ID: 10809883
yeah, still get the same 108 errors as before.

If anyone has the time to download the same zipped file (161kb) as I'm working from and get it to compile, I can't remember where I downloaded it from, but I could email it, and I'd be happy to increase the points for your time - this is pretty urgent at the moment :)
0
 
LVL 13

Accepted Solution

by:
SteH earned 100 total points
ID: 10811914
I have the file nafxcw.lib under VC98\MFC\Lib using VC++ 6.0 with service pack 5 installed. It might be that you are mixing .NET and VS6 libraries using the one under Visual Studio .Net. What OS are you using?
0
 
LVL 13

Expert Comment

by:SteH
ID: 10811940
What version of VC++ are you using. Static linking to MFC DLLs is only available in professional and enterprise editions. If you are not using any of these you need to link dynamically to MFC (using it in a shared DLL).

For what version were the sample projects designed? To change them from static to dynamic linking might involve a lot of prjects settings to be changed.
0
 

Author Comment

by:shifty_mc
ID: 10811987
Ummm, I'm just using the standard version. I'm in the process of downloading SP5 now. That file certainly isn't is in the same place on my comp.
Unfortunately I don't know how the source was designed - it's just a demonstration project I downloaded from the internet.

I've started designing my own from scratch, and it's working so far... I don't know what this file was meant to do, but I haven't run into any problems yet.

I'll see how it goes, but if everything goes ok working on my own I'll just share the points around here for people's time.

But I might come back to this in a few hours time :)
0
 
LVL 13

Expert Comment

by:SteH
ID: 10812077
For the file itself have a look at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_library_naming_conventions.asp

The setence stating that statically linking to MFC DLLs is possible only for prof and enterprise I found only in the 6.0 help files but not for the .net version on the net.

So what you need to keep in mind is to only create projects that use MFC in a shared DLL. That should work with you version of VC++ since they are not using nafxcw.lib.
0
 

Author Comment

by:shifty_mc
ID: 10834496
Right, sorry about the delay, got it working - to be honest I don't even know how - done so much in the last day or two that it all blurs, maybe it was just installing the service pack.

But anyway, it worked which is all that counts. It's a bit of a nightmare isn't it? After that mess I had to go about getting gdi+ to work, which I eventually did, again after about 6 hours of trawling the internet, only to eventually find it all came down to what order the include directories are specified in.  Maybe it's just me, but I just wrote a fairly sizeable project in VS.Net and didn't get a single problem.

Cheers anyway, I'll give the points for your help.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

747 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

12 Experts available now in Live!

Get 1:1 Help Now