nafxcwd.lib library linker error LNK2019 - help

Hello experts,

Below is the small program I am having issues with. It compiles successfully. As you see is quite small and simple program, but for some reason I am unable to link it when I tried to build it.

I have also pasted the last part of the output from the linker with verbose.

Hopping someone can help me out. It seems a problem with nafxcwd.lib but I am unsure.

/* Setup includes */
#include <stdafx.h>
#include <afxwin.h>

/* Addinitional includes */
#include "ifl.h"

/* Main */
int main(int argc, char** argv)
{
// Variables Declaration
IFL_RC iRetCode = IFL_SUCCESS;
HWND m_hwndMain;

// Get Handle to the main window
m_hwndMain = AfxGetMainWnd()->m_hWnd;

// Initialize the use of IFL
iRetCode = IFLInitialize(m_hwndMain);

if (iRetCode)
{
printf("\n Connection Failed..");
return 4;
}
else
{
printf("\n Connection Succed..");
return 0;
}

// Terminate the use of IFL
IFLTerminate();
}

COMPILE OUTPUT:

------ Build started: Project: ziden_test, Configuration: Debug Win32 ------

Compiling...

ziden_test.cpp

WINVER not defined. Defaulting to 0x0501 (Windows XP and Windows .NET Server)

Build log was saved at "file://c:\Documents and Settings\jose.moctezuma\My Documents\Visual Studio Projects\ziden_test\ziden_test\Debug\BuildLog.htm"

ziden_test - 0 error(s), 0 warning(s)

---------------------- Done ----------------------

Build: 1 succeeded, 0 failed, 0 skipped

BUILD OUTPUT:

------ Rebuild All started: Project: ziden_test, Configuration: Debug Win32 ------

Deleting intermediate files and output files for project 'ziden_test', configuration 'Debug|Win32'.

Compiling...

stdafx.cpp

Compiling...

ziden_test.cpp

WINVER not defined. Defaulting to 0x0501 (Windows XP and Windows .NET Server)

Linking...

Starting pass 1

Processed /DEFAULTLIB:libcpd

Processed /DEFAULTLIB:LIBCD

Processed /DEFAULTLIB:OLDNAMES

Processed /DEFAULTLIB:nafxcwd.lib

Processed /DEFAULTLIB:kernel32.lib

Processed /DEFAULTLIB:user32.lib

Processed /DEFAULTLIB:gdi32.lib

Processed /DEFAULTLIB:msimg32.lib

Processed /DEFAULTLIB:comdlg32.lib

Processed /DEFAULTLIB:winspool.lib

Processed /DEFAULTLIB:advapi32.lib

Processed /DEFAULTLIB:shell32.lib

Processed /DEFAULTLIB:comctl32.lib

Processed /DEFAULTLIB:shlwapi.lib

Processed /DEFAULTLIB:uuid.lib

ziden_test.obj : LNK9038: module unsafe for SAFESEH image.

Searching libraries

Searching ifl.lib:

Found _IFLInitialize@4

Referenced in ziden_test.obj

Loaded ifl.lib(IFL.dll)

Found __IMPORT_DESCRIPTOR_IFL

Referenced in ifl.lib(IFL.dll)

Loaded ifl.lib(IFL.dll)

Found __NULL_IMPORT_DESCRIPTOR

Referenced in ifl.lib(IFL.dll)

Loaded ifl.lib(IFL.dll)

Found IFL_NULL_THUNK_DATA

Referenced in ifl.lib(IFL.dll)

Loaded ifl.lib(IFL.dll)

Searching c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib\kernel32.lib:

....

........ here continues searching ....................

....

Finished searching libraries

Finished pass 1

Generating non-SAFESEH image.

nafxcwd.lib(thrdcore.obj) : error LNK2019: unresolved external symbol __endthreadex referenced in function "void __stdcall AfxEndThread(unsigned int,int)" ( AfxEndThread@@YGXIH@Z)

nafxcwd.lib(thrdcore.obj) : error LNK2019: unresolved external symbol __beginthreadex referenced in function "public: int __thiscall CWinThread::CreateThread(unsigned long,unsigned int,struct _SECURITY_ATTRIBUTES *)" ( CreateThread@CWinThread@@QAEHKIPAU_SECURITY_ATTRIBUTES@@@Z)

Debug/ziden_test.exe : fatal error LNK1120: 2 unresolved externals

Build log was saved at "file://c:\Documents and Settings\jose.moctezuma\My Documents\Visual Studio Projects\ziden_test\ziden_test\Debug\BuildLog.htm"

ziden_test - 3 error(s), 0 warning(s)

---------------------- Done ----------------------

Rebuild All: 0 succeeded, 1 failed, 0 skipped




Answer this question

nafxcwd.lib library linker error LNK2019 - help

  • Ben Taylor

    Hi Jonathan,

    Not sure if I understood well .....Should I include the multi-threaded libraries in Additional Dependancies and also Ignore the single-threaded libraries like shown below

    Go to Project -> Properties -> Linker -> Input

    - Additional Dependancies: afl.lib; libcmtd.lib; libcpmtd.lib

    - Ignore Specific Library: libcd.lib;libcpd.lib

    or how do I indicate VC++ to use the multi-threaded libraries instead of single ones

    Thanks,

    Jose



  • Noemie

    No: these libraries have been shipping for a longtime - they are definitely included in Visual C++ 2003.

    Look in $(InstallDir)\vc7\lib



  • sdoc

    Ok, I suppose that these multi-threaded versions of C runtime are located in a different compiler version, correct

    Do you recomend trying to link the program in a new version of visual C++ such as Visual studio 2005

    or I can search and get those libraries by myself in the microsoft support site and just incorporate them into the Linker input as Additional Dependencies

    Thank you for your help, I really appreciate it,

    Jose



  • programmer01

    Your problem is that __beginthreadex (and __endthreadex) required multi-threaded versions of the C runtime (libcmtd.lib and libcpmtd.lib) while you are linking against single thread versions of the libraries (libcd.lib and libcpd.lib).

  • Christian Liensberger - MSP

    Hi Jonathan,

    I am using Microsoft Visual C++ .NET 2003. Please let me know if you need further information.

    Thanks,

    Jose



  • REspawn

    Which compiler are you using

  • nafxcwd.lib library linker error LNK2019 - help