Link to home
Start Free TrialLog in
Avatar of shifty_mc
shifty_mc

asked on

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.
SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of shifty_mc
shifty_mc

ASKER

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.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I don't have that - have "Use MFC in a Shared DLL" which is already selected?
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
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 :)
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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 :)
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.
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.