NAnt linking problems : LNK1256

H

harleybl

Hello,

I have a C++ mixed mode dll ( unmanaged/managed ) that wraps a C#
dll to provide some functionality for Microsoft Excel. I am able to
compile my solution fine in Visual Studio .NET 2003 and it links and
works with no errors. There is a desire at my company to have things
checked out of source control and built on a machine dedicated to
building to remove the "I don't know, it works on my machine" problem.

I have created an NAnt script which compiles my C++ classes and then
attempts to link them into a dll. I made sure that the parameters that
are passed to the cl task and the link task are the same as in the
build log that MSVC .Net generates when it builds the solution
correctly.

However at the end of the build I get this error :
[link] LINK : fatal error LNK1256: ALINK operation failed
(8013110E) :

I looked around on MSDN and it said that there might be some version
incompatibility between the linker and alink.dll. My versions appear to
be in line with what is distributed on the CD.

I saw another posting that link needs the windir set within the
command shell you are using. In my command prompt it is set.

Has anyone run into a similar problem. Does anyone have an idea? Does
the hex value within the parenthesis have any meaning?

Thanks,
Harley Blumenfeld
 
M

Marcus Heege

Do you sure you execute this from the VS 2003 command propmt?
Do you also have VS 2002 or VS 2005 installed on the machine?
 
H

harley

I am sure that I don't have Visual Studio 2005 on this machine.
My development machine was imaged from a machine that had
Visual Studio 2002 on it, but I uninstalled that before I installed
VS 2003 .NET.

The only version of alink.dll that I have is in the
C:\WINNT\Microsoft.NET\Framework\v1.1.4322
directory and is version 7.10.3052.4.

The version of the linker that I have is in
C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin
and it's version is 7.10.3077.0 which is higher than the other
version so that is probably the reason for the error.

What I am wondering is why it works within Visual Studio, but not from
NAnt when I only have 1 version of the linker and the required dll?

Also I believe that I am using the exact linker from the command prompt
as VS 2003 because I am taking the options from the build log.

Thanks for replying...

-Harley
 
M

Marcus Heege

I have the same versions of link.exe and alink.dll as you. Could it be a
conflict with another DLL that is by accident named alink.dll?

Marcus
 
H

harley

I got it to work!!!!

The problem was with the way that NAnt handles modules... or maybe I
just misunderstood how nant handles modules. I had assumed that the
<modules/> section of the link task would just include a list of
modules like VS 2003 .NET does at the end of the command line, before
the object files.

However it does not, instead nant adds /ASSEMBLYMODULE:[path to module]
for each one it finds in the the modules fileset. I guess the
documentation could be a little clearer.

In my modules section I had this xml :
<modules>
<include name="kernel32.lib" />
<!-- removed for brevity /-->
<include name="c:/Program Files/Microsoft Visual Studio .NET
2003/Sdk/v1.1/Lib/mscoree.lib">
</modules>

So NAnt was adding /ASSEMBLYMODULE:c:/Program Files/Microsoft Visual
Studio .NET 2003/Sdk/v1.1/Lib/mscoree.lib to the linker command line.
NAnt was ignoring kernel32.lib and all the other modules since I did
not set a basedir attribute of the modules section, and it could not
find them.

I removed my modules section and added the lib files I needed to the
options attribute of the task element to mimic the way the linker in VS
2003.NET calls the linker.

I was tipped of to the cause of the problem by this bug on sourceforge.
http://sourceforge.net/tracker/index.php?func=detail&aid=1165130&group_id=31650&atid=402868

Thank you for all your help Marcus.

-Harley
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top