LNK2005 and LNK2001 errors using CString 
Author Message
 LNK2005 and LNK2001 errors using CString

Hi Everyone,

I created a win32 console application project in vc++, for
some reason as soon as I attempt to instantiate a CString
object I get the following errors:

nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl

in LIBCD.lib(new.obj)
nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl

LIBCD.lib(dbgdel.obj)
nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl

nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved
external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved
external symbol __beginthreadex
Debug/RelCalc.exe : fatal error LNK1120: 2 unresolved
externals
Error executing link.exe.

I have tried removing the libraries one by one specyfied
in the project->settings->link tab but it didn't work.
Does any one know why this is happening and what I can do
to fix it?

Thanks in advance!

My Code:

//includes headers used by other functions
//in this source file
#include "StdAfx.h"
#include <Afx.h>
#include "NI.h"
#include <stdlib.h>
#include <iostream.h>
#include <Windows.h>
#include <stdio.h>
#import <msxml4.dll> raw_interfaces_only
using namespace MSXML2;

int NIModule::testFunc()
{
        CString x("Hello");

        return 0;

Quote:
}



Sat, 17 Dec 2005 03:34:57 GMT  
 LNK2005 and LNK2001 errors using CString
See if KB article

            Q138400 - Troubleshooting LNK2001 or L2029 Unresolved External
Errors

    helps you.

--
Cheers
Check Abdoul [ VC++ MVP ]
-----------------------------------


Quote:
> Hi Everyone,

> I created a win32 console application project in vc++, for
> some reason as soon as I attempt to instantiate a CString
> object I get the following errors:

> nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl

> in LIBCD.lib(new.obj)
> nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl

> LIBCD.lib(dbgdel.obj)
> nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl
> operator new(unsigned int,int,char const *,int)" (??

> nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved
> external symbol __endthreadex
> nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved
> external symbol __beginthreadex
> Debug/RelCalc.exe : fatal error LNK1120: 2 unresolved
> externals
> Error executing link.exe.

> I have tried removing the libraries one by one specyfied
> in the project->settings->link tab but it didn't work.
> Does any one know why this is happening and what I can do
> to fix it?

> Thanks in advance!

> My Code:

> //includes headers used by other functions
> //in this source file
> #include "StdAfx.h"
> #include <Afx.h>
> #include "NI.h"
> #include <stdlib.h>
> #include <iostream.h>
> #include <Windows.h>
> #include <stdio.h>
> #import <msxml4.dll> raw_interfaces_only
> using namespace MSXML2;

> int NIModule::testFunc()
> {
> CString x("Hello");

> return 0;
> }



Sat, 17 Dec 2005 03:39:16 GMT  
 LNK2005 and LNK2001 errors using CString
Thanks for the advice but it didnt help. I tried changing
the project from win console to windows application but I
still got the same errors.

Do you have any other ideas?

Lena

ps. I am using visual studio 6.0

Quote:
>-----Original Message-----
>See if KB article

>            Q138400 - Troubleshooting LNK2001 or L2029
Unresolved External
>Errors

>    helps you.

>--
>Cheers
>Check Abdoul [ VC++ MVP ]
>-----------------------------------



>> Hi Everyone,

>> I created a win32 console application project in vc++,
for
>> some reason as soon as I attempt to instantiate a
CString
>> object I get the following errors:

>> nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl

defined
>> in LIBCD.lib(new.obj)
>> nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl

in
>> LIBCD.lib(dbgdel.obj)
>> nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl
>> operator new(unsigned int,int,char const *,int)" (??

(dbgnew.obj)
>> nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved
>> external symbol __endthreadex
>> nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved
>> external symbol __beginthreadex
>> Debug/RelCalc.exe : fatal error LNK1120: 2 unresolved
>> externals
>> Error executing link.exe.

>> I have tried removing the libraries one by one specyfied
>> in the project->settings->link tab but it didn't work.
>> Does any one know why this is happening and what I can
do
>> to fix it?

>> Thanks in advance!

>> My Code:

>> //includes headers used by other functions
>> //in this source file
>> #include "StdAfx.h"
>> #include <Afx.h>
>> #include "NI.h"
>> #include <stdlib.h>
>> #include <iostream.h>
>> #include <Windows.h>
>> #include <stdio.h>
>> #import <msxml4.dll> raw_interfaces_only
>> using namespace MSXML2;

>> int NIModule::testFunc()
>> {
>> CString x("Hello");

>> return 0;
>> }

>.



Sat, 17 Dec 2005 04:32:07 GMT  
 LNK2005 and LNK2001 errors using CString
See the following KB articles also.

        Q126646 - PRB: Error Msg: LNK2001 on __beginthreadex and
__endthreadex
        Q148652 - PRB: LNK2005 Errors When Link C Run-Time Libraries Are
Linked Before MFC Libraries

--
Cheers
Check Abdoul [ VC++ MVP ]
-----------------------------------


Quote:
> Thanks for the advice but it didnt help. I tried changing
> the project from win console to windows application but I
> still got the same errors.

> Do you have any other ideas?

> Lena

> ps. I am using visual studio 6.0

> >-----Original Message-----
> >See if KB article

> >            Q138400 - Troubleshooting LNK2001 or L2029
> Unresolved External
> >Errors

> >    helps you.

> >--
> >Cheers
> >Check Abdoul [ VC++ MVP ]
> >-----------------------------------



> >> Hi Everyone,

> >> I created a win32 console application project in vc++,
> for
> >> some reason as soon as I attempt to instantiate a
> CString
> >> object I get the following errors:

> >> nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl

> defined
> >> in LIBCD.lib(new.obj)
> >> nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl

> in
> >> LIBCD.lib(dbgdel.obj)
> >> nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl
> >> operator new(unsigned int,int,char const *,int)" (??

> (dbgnew.obj)
> >> nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved
> >> external symbol __endthreadex
> >> nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved
> >> external symbol __beginthreadex
> >> Debug/RelCalc.exe : fatal error LNK1120: 2 unresolved
> >> externals
> >> Error executing link.exe.

> >> I have tried removing the libraries one by one specyfied
> >> in the project->settings->link tab but it didn't work.
> >> Does any one know why this is happening and what I can
> do
> >> to fix it?

> >> Thanks in advance!

> >> My Code:

> >> //includes headers used by other functions
> >> //in this source file
> >> #include "StdAfx.h"
> >> #include <Afx.h>
> >> #include "NI.h"
> >> #include <stdlib.h>
> >> #include <iostream.h>
> >> #include <Windows.h>
> >> #include <stdio.h>
> >> #import <msxml4.dll> raw_interfaces_only
> >> using namespace MSXML2;

> >> int NIModule::testFunc()
> >> {
> >> CString x("Hello");

> >> return 0;
> >> }

> >.



Sat, 17 Dec 2005 04:57:56 GMT  
 LNK2005 and LNK2001 errors using CString
Lena,

I believe that what's going on is that your project isn't linking to the MFC
library.  This is something that new VC programmers hit fairly often...

CString is an MFC construct, and a console application is, by default, a
non-MFC entity.  Go to your project settings and on the General tab, select
the drop-down for 'Microsoft Foundation Classes', and choose a linking
option- either static or dynamic.  More than likely it shows  that you're
'Not using MFC'...

Hope this helps.

Paul


Quote:
> Thanks for the advice but it didnt help. I tried changing
> the project from win console to windows application but I
> still got the same errors.

> Do you have any other ideas?

> Lena

> ps. I am using visual studio 6.0

> >-----Original Message-----
> >See if KB article

> >            Q138400 - Troubleshooting LNK2001 or L2029
> Unresolved External
> >Errors

> >    helps you.

> >--
> >Cheers
> >Check Abdoul [ VC++ MVP ]
> >-----------------------------------



> >> Hi Everyone,

> >> I created a win32 console application project in vc++,
> for
> >> some reason as soon as I attempt to instantiate a
> CString
> >> object I get the following errors:

> >> nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl

> defined
> >> in LIBCD.lib(new.obj)
> >> nafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl

> in
> >> LIBCD.lib(dbgdel.obj)
> >> nafxcwd.lib(afxmem.obj) : error LNK2005: "void * __cdecl
> >> operator new(unsigned int,int,char const *,int)" (??

> (dbgnew.obj)
> >> nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved
> >> external symbol __endthreadex
> >> nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved
> >> external symbol __beginthreadex
> >> Debug/RelCalc.exe : fatal error LNK1120: 2 unresolved
> >> externals
> >> Error executing link.exe.

> >> I have tried removing the libraries one by one specyfied
> >> in the project->settings->link tab but it didn't work.
> >> Does any one know why this is happening and what I can
> do
> >> to fix it?

> >> Thanks in advance!

> >> My Code:

> >> //includes headers used by other functions
> >> //in this source file
> >> #include "StdAfx.h"
> >> #include <Afx.h>
> >> #include "NI.h"
> >> #include <stdlib.h>
> >> #include <iostream.h>
> >> #include <Windows.h>
> >> #include <stdio.h>
> >> #import <msxml4.dll> raw_interfaces_only
> >> using namespace MSXML2;

> >> int NIModule::testFunc()
> >> {
> >> CString x("Hello");

> >> return 0;
> >> }

> >.



Sat, 17 Dec 2005 06:17:35 GMT  
 LNK2005 and LNK2001 errors using CString
Thanks again, but it only half way worked...
The first article worked and got rid of the LNK2001
errors. I tried the second article which said to put the
library causing on the ignore list (input category), this
eliminated certain errors but caused the following 3
errors to occur:

NI.OBJ : error LNK2001: unresolved external symbol
__afxForceEXCLUDE
NI.OBJ : error LNK2001: unresolved external
symbol "public: __thiscall CString::~CString(void)" (??

NI.OBJ : error LNK2001: unresolved external
symbol "public: __thiscall CString::CString(char const *)"

Seems like CString is defined in nafxcwd.h so I can't
leave it out, uggghh what to do!?

Lena

Quote:
>-----Original Message-----
>See the following KB articles also.

>        Q126646 - PRB: Error Msg: LNK2001 on
__beginthreadex and
>__endthreadex
>        Q148652 - PRB: LNK2005 Errors When Link C Run-
Time Libraries Are
>Linked Before MFC Libraries

>--
>Cheers
>Check Abdoul [ VC++ MVP ]
>-----------------------------------



Sat, 17 Dec 2005 06:23:06 GMT  
 LNK2005 and LNK2001 errors using CString
Thank you! That was the problem, I had to choose to use
MFC in a shared dll. :-) :-)

Thanks again!
Lena

Quote:
>-----Original Message-----
>Lena,

>I believe that what's going on is that your project isn't
linking to the MFC
>library.  This is something that new VC programmers hit
fairly often...

>CString is an MFC construct, and a console application
is, by default, a
>non-MFC entity.  Go to your project settings and on the
General tab, select
>the drop-down for 'Microsoft Foundation Classes', and
choose a linking
>option- either static or dynamic.  More than likely it
shows  that you're
>'Not using MFC'...

>Hope this helps.

>Paul



>> Thanks for the advice but it didnt help. I tried
changing
>> the project from win console to windows application but
I
>> still got the same errors.

>> Do you have any other ideas?

>> Lena

>> ps. I am using visual studio 6.0

>> >-----Original Message-----
>> >See if KB article

>> >            Q138400 - Troubleshooting LNK2001 or L2029
>> Unresolved External
>> >Errors

>> >    helps you.

>> >--
>> >Cheers
>> >Check Abdoul [ VC++ MVP ]
>> >-----------------------------------



>> >> Hi Everyone,

>> >> I created a win32 console application project in
vc++,
>> for
>> >> some reason as soon as I attempt to instantiate a
>> CString
>> >> object I get the following errors:

>> >> nafxcwd.lib(afxmem.obj) : error LNK2005: "void *
__cdecl

>> defined
>> >> in LIBCD.lib(new.obj)
>> >> nafxcwd.lib(afxmem.obj) : error LNK2005: "void
__cdecl

defined
>> in
>> >> LIBCD.lib(dbgdel.obj)
>> >> nafxcwd.lib(afxmem.obj) : error LNK2005: "void *
__cdecl
>> >> operator new(unsigned int,int,char const *,int)" (??

>> (dbgnew.obj)
>> >> nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved
>> >> external symbol __endthreadex
>> >> nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved
>> >> external symbol __beginthreadex
>> >> Debug/RelCalc.exe : fatal error LNK1120: 2 unresolved
>> >> externals
>> >> Error executing link.exe.

>> >> I have tried removing the libraries one by one
specyfied
>> >> in the project->settings->link tab but it didn't
work.
>> >> Does any one know why this is happening and what I
can
>> do
>> >> to fix it?

>> >> Thanks in advance!

>> >> My Code:

>> >> //includes headers used by other functions
>> >> //in this source file
>> >> #include "StdAfx.h"
>> >> #include <Afx.h>
>> >> #include "NI.h"
>> >> #include <stdlib.h>
>> >> #include <iostream.h>
>> >> #include <Windows.h>
>> >> #include <stdio.h>
>> >> #import <msxml4.dll> raw_interfaces_only
>> >> using namespace MSXML2;

>> >> int NIModule::testFunc()
>> >> {
>> >> CString x("Hello");

>> >> return 0;
>> >> }

>> >.

>.



Sat, 17 Dec 2005 20:08:02 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. LNK2005 and LNK2001 errors!

2. LNK2001 error - CString related

3. using _variant_t rather than _bstr_t causing linker error LNK2005

4. error LNK2005: using MFC with ATL

5. link problem, error LNK2005 using CSocket

6. LNK2001 error (class using template)???

7. LNK2001 error when using namespace....

8. Link error LNK2001 while using CView derivative in a DLL

9. error LNK2001: using CTime.Format

10. Link error using GetFileVersionInfoSize() (LNK2001)

11. HELP: LNK2001 error when using CList template

12. Linking error LNK2001 when using template classes

 

 
Powered by phpBB® Forum Software