Unable to link very small program 
Author Message
 Unable to link very small program

Hello,

I have a big application which uses ATL/COM... But I am unable to link it
compiled with /clr.

Here is a very small app to verify this problem:

<LinkTest.cpp>
#include <afxwin.h>
class Exept
{

Quote:
};

void main(void)
{
  throw Exept();
Quote:
}

</LinkTest.cpp>

I compile/link it with (VC7):
cl /clr LinkTest.cpp

I always get the follwing error:

LinkTest.obj
nafxcw.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete

LinkTest.exe : fatal error LNK1169: one or more multiply defined symbols
found

What can I do ????

--
Greetings
  Jochen



Fri, 21 Jan 2005 14:39:24 GMT  
 Unable to link very small program
The probles is the same. libcmt is C-LIBrary MultyThreaded.
You have more then one implementation of delete operator. Ensure that all
modules use the same CRT (multithreaded without debug). the best way is to
use shared CRT
project settings->C++->code generation->use run-time library->multithreaded
DLL.


Quote:
> Hello,

> I have a big application which uses ATL/COM... But I am unable to link it
> compiled with /clr.

> Here is a very small app to verify this problem:

> <LinkTest.cpp>
> #include <afxwin.h>
> class Exept
> {
> };
> void main(void)
> {
>   throw Exept();
> }
> </LinkTest.cpp>

> I compile/link it with (VC7):
> cl /clr LinkTest.cpp

> I always get the follwing error:

> LinkTest.obj
> nafxcw.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete

> LinkTest.exe : fatal error LNK1169: one or more multiply defined symbols
> found

> What can I do ????

> --
> Greetings
>   Jochen



Fri, 21 Jan 2005 19:06:50 GMT  
 Unable to link very small program

Quote:

>> <LinkTest.cpp>
>> #include <afxwin.h>
>> class Exept
>> {
>> };
>> void main(void)
>> {
>>   throw Exept();
>> }
>> </LinkTest.cpp>

>> cl /clr LinkTest.cpp

> The probles is the same. libcmt is C-LIBrary MultyThreaded.
> You have more then one implementation of delete operator. Ensure that
> all modules use the same CRT (multithreaded without debug). the best
> way is to use shared CRT
> project settings->C++->code generation->use run-time
> library->multithreaded DLL.

Thanx for your answer...
I have only one problem:
I want to link with the static version of the runtime... I do not add any
modules... I only include ATL...

If I compile it without "/clr" then everything works fine...
So this is an bug... (or at least some problems within the linker...)
Normally the linker must first link with the "nafxcw.lib" and if all
symbols are resolved with this LIB, it should look at the "week" symbolds
in "libcmt.lib".

And if I do not use "/clr" the linker works correctly...
If "/clr" is active, the linker does not work correctly...

So for me, I am at the moment unable to build a managed-Assembly which
uses ATL internally and is linked with the static runtime...

Any help would be great...

--
Greetings
  Jochen



Fri, 21 Jan 2005 19:20:45 GMT  
 Unable to link very small program
No, this is very much by design. When compiling /CLR, we default to the
multithreaded library since finalizers run on a separate thread.

Ronald Laeremans
Visual C++ compiler and libraries team


Quote:

> >> <LinkTest.cpp>
> >> #include <afxwin.h>
> >> class Exept
> >> {
> >> };
> >> void main(void)
> >> {
> >>   throw Exept();
> >> }
> >> </LinkTest.cpp>

> >> cl /clr LinkTest.cpp

> > The probles is the same. libcmt is C-LIBrary MultyThreaded.
> > You have more then one implementation of delete operator. Ensure that
> > all modules use the same CRT (multithreaded without debug). the best
> > way is to use shared CRT
> > project settings->C++->code generation->use run-time
> > library->multithreaded DLL.

> Thanx for your answer...
> I have only one problem:
> I want to link with the static version of the runtime... I do not add any
> modules... I only include ATL...

> If I compile it without "/clr" then everything works fine...
> So this is an bug... (or at least some problems within the linker...)
> Normally the linker must first link with the "nafxcw.lib" and if all
> symbols are resolved with this LIB, it should look at the "week" symbolds
> in "libcmt.lib".

> And if I do not use "/clr" the linker works correctly...
> If "/clr" is active, the linker does not work correctly...

> So for me, I am at the moment unable to build a managed-Assembly which
> uses ATL internally and is linked with the static runtime...

> Any help would be great...

> --
> Greetings
>   Jochen



Fri, 21 Jan 2005 23:54:16 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Unable to link very small program

2. Help with smaller programs within a larger program

3. .inf files and dsklayt program and makink small setup programs

4. Unable to link a Win32 API function

5. Unable to link C library in Visual C++ code

6. Unable to link a Win32 API function

7. Unable to link (_outpw)

8. Unable to link a Win32 API function

9. Unable to link (_outpw)

10. How Can I Link *.exe to VC or link C program to VC

11. unable to compile a simple c program in C++ dev

12. unable to compile a simple c program in C++ dev

 

 
Powered by phpBB® Forum Software