Building trouble : error LNK1104: cannot open file

Hi every body,

I'am in serious trouble cause i can't find the solution of my problem.

I'am trying to convert an .exe into .dll file after i downloaded the source file of the .exe .

I inserted the source code into a "MFC AppWizard(dll)" project and compiled it (was ok) and when generating the .dll file (after i mentioned the "Object/library Module" under the "Project/Settings/Link" Menu ) i got this error :

Linking...
LINK : fatal error LNK1104: cannot open file "C:\dll3\VisioneerDll\twaintest\Debug\twaintest.lib"
Error executing link.exe.
Creating browse info file...

twaintest.dll - 1 error(s), 0 warning(s)

with out mentionong this library ( which is not correct cause the library should be mentionned ) i got this error :

Linking...
Creating library Debug/twaintest.lib and object Debug/twaintest.exp
twaintest.obj : error LNK2001: unresolved external symbol "public: __thiscall CMainFrame::CMainFrame(void)" ( 0CMainFrame@@QAE@XZ)
twaintest.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CTwaintestDoc::classCTwaintestDoc" ( classCTwaintestDoc@CTwaintestDoc@@2UCRuntimeClass@@B)
twaintest.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CChildFrame::classCChildFrame" ( classCChildFrame@CChildFrame@@2UCRuntimeClass@@B)
twaintest.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CTwaintestView::classCTwaintestView" ( classCTwaintestView@CTwaintestView@@2UCRuntimeClass@@B)
Debug/twaintest.dll : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.
Creating browse info file...

twaintest.dll - 5 error(s), 0 warning(s)

Can anu one help me PLEASE.

Thinks



Answer this question

Building trouble : error LNK1104: cannot open file

  • cues7a

    What version of visual sutdio you are using

    Thanks,
    Ayman Shoukry
    VC++ Team


  • Ankini

    It looks to me like you're creating a DLL called twaintest in the same folder as the library, also called twaintest. When the DLL gets linked, the linker creates an import library for it, called twaintest.lib. And that will destroy your library since it has the same name.

    Try rebuilding your library and naming the DLL something else.


  • WRuschhaupt

    Thanks for help but we probably using differrent develeppement environment, all that i had doing : "Right-click the project that generates the "real" twaintest.lib and choose Properties " is "General", "Inputs" and "Outputs" Menus !!! and none of them have "Configuration Propriety Menu" !!!

    Today is my last day in this job so think to both of you again, but it will be nice to understand what is wrong.


  • jsedlak

    Doesn't work (i gave to the output file another name but created it in the same directory than the library, i called it "Debug/visioneer.dll" ).

    The amazing thing is that when i go to "Project\Settings\Links" and put in the field "Object\Library Modules" the name of the library (with the full path or relative path) i have the error :

    "LNK1104: cannot open file "Debug/twaintest.lib"

    and no library is there but if i don't mention it (i mean if i leave the filed "Object\Library Modules" empty), i have the other error mentionned before in my thread and in the "Degug" directory i have the "twaintest.lib".

    Thanks a lot for joyning to help


  • Mitesh Shah923

    if i understood what you mean, i should put le "twaintest.lib" file not under DEBUG directory but some where else, but this file is generated there automatically, i don't see where i did specify the DEBUG directory !!! that is the "real" twaintest.lib file you're talking about right .
  • DuncanP

    VC++ 6 !!


  • grouper

    First of all think you to much for your help but i could not do what you asked to cause i did not understand where to add the path and how to add the lib to linking command.

    I also checked the link you gave me but could not rich the "Property Pages dialog box" to modify the "Additionnal Dependencies" parameter.

    All i did is that i went again on the "Project\Setting" Menu and on the window i had as result i went on the "link" Menu and over "Category:output" and than added the library name in the "Object/Library Modules" and the path on which the file could be found in the field "Additional Library Path".

    I think i'll stay a littele bite late at work so if it is possible it will be kind from you to help me today can also rich me by email on mehdi_mejri@yahoo.com

    once again thinks a lot


  • HellsChicken

    This is what I usually do; I create both a debug and a release version of the library and put the .libs in the same folder as the project. That prevents linking problems and, in your case, avoids overwriting files.

    Right-click the project that generates the "real" twaintest.lib and choose Properties. Select Configuration properties, Librarian, General. Change "Output File" to "$(ProjectDir)\twaind.lib. Change configuration to "Release" (upper left combobox, click Yes) and change "Output File" to "$(ProjectDir)\twainr.lib. Build both the Debug and Release configurations. You'll now have two .lib files in your project folder, twaind.lib, suitable for use in other projects in their Debug build and twainr.lib, suitable for Release builds.

    Now open the project properties for your DLL. Select Linker, Input and put twaind.lib in the "Additional depencies" box. Switch to the Release configuration and put twainr.lib in the box. Build the DLL. If you still get LNK1104, put the full path to the twaind.lib/twainr.lib in the box.


  • Doraemon_1

    Where is twaintest.lib located on your machine

    Thanks,
    Ayman Shoukry
    VC++ Team


  • Ned Rise

    You're still getting your twaintest.lib file overwritten by the DLL import library. Try to stay out of trouble and put your "real" twaintest.lib in another folder.


  • WayneSpangler

    the "twaintest.lib" is located on "C:\dll3\VisioneerDll\twaintest\Debug" and when i mention it in the "object/Library Modules" i give the whole path of the file.

    I tried building ommiting to specify this file and i saw that it is belt in that directory, so this file is created but when i specify it in the "object/Library Modules" field it gives me that reading error, that it can not open it.

    LINK : fatal error LNK1104: cannot open file "Debug/twaintest.lib"


  • ctree555

    What you need to do is to add C:\dll3\VisioneerDll\twaintest\Debug to the additional dependency and then just add the lib to your linking command.

    http://msdn2.microsoft.com/en-us/library/ba1z7822.aspx contains more info.

    Thanks,
    Ayman Shoukry
    VC++ Team


  • Building trouble : error LNK1104: cannot open file