views:

45

answers:

3

When I link to the one under Release/ ,got a fatal error:

LINK : fatal error LNK1146: no argument specified with option '/machine:'

Then I tried to link to the .lib under Debug/ and this time it works.

But what can be different?

+2  A: 

Usually, no optimization is done to debug assemblies, while release assemblies are optimized. Debug assemblies will also often contain cruft like source file line numbers.

Billy ONeal
But why build fails with release libs?
ieplugin
@ieplugin: The error looks like you made a typo on the command line, not that the library has anything to do with it.
Billy ONeal
A: 

You may want to change the build configuration for debug and release versions seperately.

Praveen S
+1  A: 

This isn't actually a C question; it relates to the platforms used.

Frequently, a project/solution will be set up to create a version for debugging and one for release, and putting them in Debug/ and Release/ directories is a common way to distinguish. The debug version will typically compile fast and run slowly, and contain information to link the internal execution to the source code (such as line numbers and variable names). The release version is typically slower to compile and faster to run, and it's much more difficult to track what's going on inside.

Obviously, there have to be differences between the debug and release versions, if only the appropriate compiler flags. However, in the build systems I'm familiar with, it's possible to make arbitrary other changes, and sometimes this will cause a release-version-only bug, which is a pain. Alternately, if the C code doesn't specify the behavior properly, the debug and release versions might interpret it differently, and that's also a pain.

In this case, I'd guess that there was a difference in how they were built. I can't really comment further without more information.

What is the OS? What is the C compiler used? What build system do you use (if you're using an IDE, possibly the one standard with the IDE)? What is the library you're using. Does your organization build it, or do you get it from outside? Knowing these things would give us a clue as to where to start looking.

David Thornley