Solved

Build fail

Posted on 2006-07-19
13
1,259 Views
Last Modified: 2007-11-27
I have an array of size 32k elemets.It is intialized in cpp file. I am using VC++. I am building the libray using debug mode in VC++.
I was getting "fatal error LNK1143: invalid or corrupt file: no symbol for comdat section 0xffff8000" error,
and causing build fail. Pls let me know how to handle that a big array.
0
Comment
Question by:srini_kandimalla
  • 5
  • 4
  • 2
  • +2
13 Comments
 
LVL 8

Expert Comment

by:manish_regmi
ID: 17143660
are you creating it statically or dynamically.

try to create it dynamically use new.

regards
Manish regmi
0
 

Author Comment

by:srini_kandimalla
ID: 17143715
This array is created statically, my parser generates that array and writes that array in to a cpp file.
Other programs access that array. So while building the library I was getting this follwoing
"StdAfx.obj : fatal error LNK1143: invalid or corrupt file: no symbol for comdat section 0xffff8000" error

When I tried with small size array, the lib is generating well.

I changed optimization setting in VC++ for "Release" version, it is working well. But the same problem I got for release also. It went away when I changed optimization settings. But the same techinique did not work for Debug version
0
 
LVL 8

Expert Comment

by:manish_regmi
ID: 17143834
That error means the object file is corrupted.

did you tried disabling optimization
/Od

regards
Manish Regmi
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 17143943
It looks like static arrays of > 30K are a problem for debug builds in MSVC. Can you get away with making the array smaller in your debug build and full size in the release build? If not, you'll need to load a dynamic array from a database (e.g a dictionary file).
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17144237
Possible solutions (..MSDN) :

a.. Turn off optimization with the /Od (Disable) option. ( as said above by Manish Regmi )

b.. Disable minimal rebuild with the /Gm- (Enable Minimal Rebuild) option.

c.. Compile with the /Gy (Enable Function-Level Linking) option to package functions.

d.. Use a different code generation option. See the /G (Optimize for Processor) options.

e.. Change the order of functions and global variables.


-MAHESH
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 17144608

>>>> StdAfx.obj

That is the Precompiled Header File. Did you include the header where the big array was defined in stdafx.h? If so, that probably is the reason why it get corrupted.

You could remove that include from stdafx.h or try to compile *not using PCH* (remove stdafx.cpp from project tree then).

You also could try to increase stack size of the dll by adding /STACK=nnnnn to the linker options.

Regards, Alex
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 17

Expert Comment

by:rstaveley
ID: 17144741
Experimenting a bit with Visual C and static strings, you soon come across:

    fatal error C1091: compiler limit: string exceeds 65535 bytes in length

Now that's a compiler limit rather than a linker one.

I was interested to see that you can get around that limit though.

This Perl script (run using ActivePerl on Windows) generates .cpp source with a null-terminated character array of 65538 characters, which seems to be usable - it certainly is handled correctly by strlen().

--------8<--------
#!/usr/bin/perl -w
use strict;

# Create a source code file with a large character array in it
open F, "> bigstr.cpp";
print F "char bigstring[] = {\n";
foreach (1..256) {
      print F "\t" . ("'x'," x 256) . "\n";
}
print F "\t'x','x','\\0'\n\t};\n";
close F;

# Create a source code file for a test harness to link with this
open F, "> test.cpp";
print F <<EOF;
#include <iostream>
#include <cstring>

extern char bigstring[];

int main()
{
      std::cout << strlen(bigstring);
}
EOF
close F;

# Compile and link
system "cl test.cpp bigstr.cpp";

# Run the generated executable
system "test.exe";
--------8<--------

There must ne a technet document somewhere that describes what the Visual C compiler and linker limits are.
0
 

Author Comment

by:srini_kandimalla
ID: 17148136
As Stavely mentioned, I dont have any problem with smaller array size since begining even for debug or realease versions. As  I worked first on Release version, as per my collegue suggested, I disabled the optimization ( that is set to default ). It went fine for it. As it is success for Releasae I thought that it will go well even for Debug version. I set the same optimization setting that I set for Release version even to Debug version, but it did not help.

To follow the comments by Mahesh, I dont know how to set
"a.. Turn off optimization with the /Od (Disable) option. ( as said above by Manish Regmi )"

My present options  are as follows for Debug version.

/nologo /MDd /W3 /Gm /GR /GX /ZI /Od /I

I tried to set /Gy option in C++ -> Customize ( click on C++ button, then selected Customize ), there "Enable Function-level is shaded" unable to select. Except /Gy alomost everything is there as said by MAHESH.
The problem is still open
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 17148819
Try removing that /I switch.

When I ran the following, it was /I that caused the error: LINK : fatal error LNK1561: entry point must be defined, which is odd because you'd think it was an include directory directive, but it doesn't have a directory and that might be confusing matters.

--------8<--------
#!/usr/bin/perl -w
use strict;

open F, "> bigstr.cpp";
print F "char bigstring[] = {\n";
foreach (1..256) {
      print F "\t" . ("'x'," x 256) . "\n";
}
print F "\t'x','x','\\0'\n\t};\n";
close F;

open F, "> test.cpp";
print F <<EOF;

#include <iostream>
#include <cstring>
extern char bigstring[];
int main()
{
      std::cout << strlen(bigstring);
}
EOF
close F;

system "cl /nologo /MDd /W3 /Gm /GR /GX /ZI /Od /I test.cpp bigstr.cpp";
system "cl /nologo /MDd /W3 /Gm /GR /Zi /ZI /Od test.cpp bigstr.cpp";
system "cl /I test.cpp bigstr.cpp";
system "test.exe";
--------8<--------
0
 

Author Comment

by:srini_kandimalla
ID: 17148937
How do I remove /I option in my project. It is not a stand alone program. So how do I navigate in my VC++ 6.0 IDE to disable /I. I erased from "Project Options" of "C++" button. But it exist there only after click on OK.
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 17150062
Try putting an include directory in like . (i.e. current directory). My guess is that you have the include path set to a space and the IDE is passing the space as a command line parameter with the /I switch. If you put an actual directory in there it ought to work OK.

With my perl script test....

   system "cl /nologo /MDd /W3 /Gm /GR /GX /ZI /Od /I . test.cpp bigstr.cpp";

...works OK.
0
 

Author Comment

by:srini_kandimalla
ID: 17151487
Dear All,

Thanks for your help. Even if I did not get the exact answer the discussion helped me a lot. Just Y'day approximately at the same time I registered to this site. While registering to this site I was in dilemma that whether this would be useful or not far a price of $99.50. But I simply registered based on the fact that if I dont spent some 100 bucks then there is no meaning in earning some $x0 K. But today I am really as being a part of this group and it is really a worth site to register.

Coming to the problem I sloved this thru many iterations of changing the options.
The following are the conclusions based on my experience with this problem.

1.. We should know that the theory behind some of these options carefully.

2.. In this case, the problem is solved after replacing the /ZI with /Zi( Here I compared the options of my Release and Debug builds setting). When you set /ZI, evenif you turn off optimization option(/Od), it does not much useful.

3.. We should not use both /ZI, /Zi at the same time, both's usability is mutually exclusive.

4.. /Zi does not impact the /Od effect

5.. But /ZI suppress the Optimize(/Od) setting. This is what I was having, which caused the problem.

6.. while builiding .lib files, it is better to use /Zi instead of /ZI.

I may guess some of the above points might be wrong, but these are my understinding after going thru the msdn web sites.

You can also go thru these following links

Thanks to Alex.
Thanks a lot & lot for Stavely & Mahesh for so many valuble replies.

See you at a different occasion( the problem in our case )
Thanks
///Srini

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_Precompiled_Header_Compiler_Options.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_core_.2f.z7.2c_2f.zd.2c_2f.zi.asp

http://msdn2.microsoft.com/en-us/library/958x11bc.aspx

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_.2f.z7.2c_2f.zd.2c_2f.zi.asp

0
 
LVL 17

Accepted Solution

by:
rstaveley earned 500 total points
ID: 17152016
It sounds like it is a "there be dragons" area and you are dealing with compiler limits. It would be good to dig up a link to some documentation about limits (e.g. string cannot 65535 bytes in length), but I expect that limits are complicated when you have debugging. I doubt if they are comprehensively documented in the public domain.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now