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

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.
shifty_mcAsked:
Who is Participating?
 
SteHCommented:
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
 
jkrCommented:
>>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
 
shifty_mcAuthor Commented:
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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
bkfirebirdCommented:
go to Project|Settings|General and select Use MFC in a dynamic dll
0
 
shifty_mcAuthor Commented:
I don't have that - have "Use MFC in a Shared DLL" which is already selected?
0
 
bkfirebirdCommented:
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
 
shifty_mcAuthor Commented:
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
 
SteHCommented:
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
 
shifty_mcAuthor Commented:
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
 
SteHCommented:
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
 
shifty_mcAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.