473,569 Members | 2,704 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Linking error while compiling unmanaged C++ code with /clr

B.
We converted VC++ 6.0 to VS 2005 and tried to compile with /clr,
however, we got few linking errors:
MSVCMRTD.lib(ms tartup.obj) : error LNK2022: metadata operation failed
(8013118D) : Inconsistent layout information in duplicated types
(tagTEXTMETRICA ): (0x02000039).

I knew that other ppl had same problem and solved it by turning Struct
Member Alignment to be default. However, our application need it to be
1 byte. Is there any other way to solve the issue?

Thanks a lot,
B.

Oct 3 '06 #1
3 2274
"B." <gu*******@gmai l.comwrote in message
news:11******** *************@i 42g2000cwa.goog legroups.com...
We converted VC++ 6.0 to VS 2005 and tried to compile with /clr,
however, we got few linking errors:
MSVCMRTD.lib(ms tartup.obj) : error LNK2022: metadata operation failed
(8013118D) : Inconsistent layout information in duplicated types
(tagTEXTMETRICA ): (0x02000039).

I knew that other ppl had same problem and solved it by turning Struct
Member Alignment to be default. However, our application need it to be
1 byte. Is there any other way to solve the issue?
You're apparently changing the structure packing globally, while you need to
change it locally - only for the types that you define.

How are you changing the packing? Using #pragma pack() at the top of your
files is not a good solution as you'll inadvertantly change the packing of
type introduced by headers that aren't themselves wrapped in an appropriate
#pragma pack().

-cd
Oct 3 '06 #2
B.
Hi Carl,

Thanks for reply. We set the Struct Member Alignment in C/C++ code
generation tab. And we cannot afford to change it since it is a
complicated product and we don't know what unexpected issues will
happen.
Carl Daniel [VC++ MVP] wrote:
"B." <gu*******@gmai l.comwrote in message
news:11******** *************@i 42g2000cwa.goog legroups.com...
We converted VC++ 6.0 to VS 2005 and tried to compile with /clr,
however, we got few linking errors:
MSVCMRTD.lib(ms tartup.obj) : error LNK2022: metadata operation failed
(8013118D) : Inconsistent layout information in duplicated types
(tagTEXTMETRICA ): (0x02000039).

I knew that other ppl had same problem and solved it by turning Struct
Member Alignment to be default. However, our application need it to be
1 byte. Is there any other way to solve the issue?

You're apparently changing the structure packing globally, while you need to
change it locally - only for the types that you define.

How are you changing the packing? Using #pragma pack() at the top of your
files is not a good solution as you'll inadvertantly change the packing of
type introduced by headers that aren't themselves wrapped in an appropriate
#pragma pack().

-cd
Oct 3 '06 #3
"B." <gu*******@gmai l.comwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
Hi Carl,

Thanks for reply. We set the Struct Member Alignment in C/C++ code
generation tab. And we cannot afford to change it since it is a
complicated product and we don't know what unexpected issues will
happen.
Well, you're going to have to find out. Changing the global option in the
IDE (which sets the command-line option /Zp1) simply won't work for a
managed project - you're changing the definition of system types that are
eposed by the CRT. This is a so-called "ODR Violation" (ODR = One
Definition Rule). Under VC6, you could get away with many ODR violations
(especially related to type you're not using). Under the CLR, you have no
such liberty.

You need to remove the setting in the IDE and set structure packing with
#pragma pack around the structs that you care about or you'll never get it
to work with the CLR.

-cd
Oct 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
5087
by: Steven T. Hatton | last post by:
Is there anything that gives a good description of how source code is converted into a translation unit, then object code, and then linked. I'm particularly interested in understanding why putting normal functions in header files results in multiple definition errors even when include guards are used. -- STH Hatton's Law: "There is only...
7
6538
by: wmkew | last post by:
Hello everyone I'm encountering a R6002 Runtime error and several bugs when trying to generate a simple Managed C++ application with .NET 2003. The main problem seems to arise from linking with LIBCMT(D).DLL. (My requirement is that we can't link with MSVCRT(D).LIB.) Below are steps I've followed, and the resulting problems 1. Using the...
1
8107
by: Joannes Vermorel | last post by:
I am currently trying to port a small open source scientfic library written in C++ to .Net. The code (including the VS solution) could be found at http://www.vermorel.com/opensource/selfscaling.zip My problem is that when I try to compile the library I got a list of linking error messages. I am not a specialist of porting C++ code to .Net....
6
1681
by: Heloise | last post by:
Hi, ..NET version: Visual C++ 2005 Express Edition Beta OS: XP I have a set of dlls built with .NET 2003. They are unmanaged C++ and C code. I am writing a managed C++ dll layer to call my unmanaged libraries using IJW.
2
1428
by: Joerg M. Colberg | last post by:
I have a VS.Net solution that contains various projects. Some of the projects contain programme blocks (legacy code) that are used by some of the other projects. One project contains some C code (managed and unmanaged) that uses external libraries (GNU Scientific Library). These external libraries are linked to in the...
7
7382
by: Lee Crabtree | last post by:
I'm starting work on what will eventually be a very, very LARGE project. A lot of the project involves taking C/C++ class libraries and wrapping them with managed C++. I'd like to minimize the number of DLLs I have (because I'd like to keep my sanity). Is there some way to compile a managed C++ DLL into a C# DLL, or am I just stuck...
3
4365
by: walkeraj | last post by:
I'm trying to compile an open source game called IVAN , and I'm able to compile it from a makefile, but not from an IDE. I have attempted to recreate the way the makefile compiles the project as closely as possible, yet I'm getting odd linking errors. I think I've traced it to some kind of problem with the SDL libraries it uses, yet I can't...
0
2547
by: Philip Lowman | last post by:
I am in the process of trying to migrate a couple of build solutions to Visual Studio Express 2005 from VS 2003 Professional and I am running into a weird C/C++ runtime library linking issue when using the /MT compilation option. Our debug solution's /MTd flag works fine and using /MD also seems to work ok. For some reason I can't fathom,...
3
2846
by: Pixel.to.life | last post by:
Hi, Gurus, I recently attempted to build a .Net forms application, that links with old style unmanaged C++ static libs. Of course I had to recompile the static lib projects to link properly with the managed application. My questions are two fold: The managed project uses /clr and /MDd (in debug) options. The
0
7698
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8122
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7970
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.