views:

795

answers:

3

After loading an existing MFC application in Visual Studio 2008, I am left with one linking error:

LINK : fatal error LNK1104: cannot open file '..\..\xpressmp\lib\xprm_rt.lib'

I have looked "everywhere", but I can't figure out where the relative path is set. The lib file is located in C:\xpressmp\lib, and I have added this directory both under Tools-Options->Projects and Solutions->VC++Directories->Library files and Project->Properties->Linker->Additional Library Directories. I also searched all files in the project to no avail.

I have the library file (xprm_rt.lib) listed under Additional Dependencies for both Debug and Release. I also tried adding the path there, but that did not help. I cannot find any #pragma comment-directives.

About the LNK1104, the file clearly does not exist in the location that the linker is searching. But I can't see why it is searching there (..\..\...) as I have not specified any relative paths.

Any help appreciated :-)

UPDATE: In the project .vcproj file, I found the following xml:

<File RelativePath="..\..\XpressMP\lib\xprm_rt.lib"></File>
<File RelativePath="..\..\XpressMP\lib\xprs.lib"></File>

After deleting these lines (where were they set?), I was able to link successfully. Thanks for your help, it seems the relative library path was indeed being appended "automatically" by VS.

Thanks both of you, I think it was Nick that put me on the right track.

+2  A: 

In the project properties, look under Configuration Properties -> Linker -> Input -> Additional Dependencies, for each of your project's configurations (Debug, Release, etc). Also, look for #pragma comment(lib, ...) directives in the code.

As you've added the C:\xpressmp\lib folder to the library search path in VC++ Directories, check that only the library file name is specified under Additional Dependencies, and this does not include the path (i.e, xprm_rt.lib, not ..\..\xpressmp\lib\xprm_rt.lib).

Also, have you tried each of the solutions in the LNK1104 error documentation?

ChrisN
A: 

Thanks for answering so swiftly!

I have the library file (xprm_rt.lib) listed under Additional Dependencies for both Debug and Release. I also tried adding the path there, but that did not help. I cannot find any #pragma comment-directives.

About the LNK1104, the file clearly does not exist in the location that the linker is searching. But I can't see why it is searching there (..\..\...)

Lars
Answers are for answers. Use comments or edit the question to reply.
ephemient
Thanks, I realized after adding this that it's not the way to do it around here. Sorry
Lars
A: 

It sounds like one of a couple possibilities to me:

  • The library itself is setting the lib include path via a #pragma comment(lib, ...) directive; search library headers to see if that's the case
  • You have a project for the library included in your solution which your main project is dependent on, and the relative library path is being appended automatically by VC; check the command line property page for the main project to see if that's the case

That's what I can think of which could cause the error; hope it helps.

Nick