473,320 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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(mstartup.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 2260
"B." <gu*******@gmail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
We converted VC++ 6.0 to VS 2005 and tried to compile with /clr,
however, we got few linking errors:
MSVCMRTD.lib(mstartup.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*******@gmail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
We converted VC++ 6.0 to VS 2005 and tried to compile with /clr,
however, we got few linking errors:
MSVCMRTD.lib(mstartup.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*******@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.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
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...
7
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...
1
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...
6
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...
2
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...
7
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...
3
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...
0
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...
3
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...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.