Ошибка 1104 visual studio

I’ve created a new C++ project in Visual Studio 2008. No code has been written yet; Only project settings have been changed.

When I compile the project, I receive the following fatal error:

fatal error LNK1104: cannot open file ‘C:\Program.obj’

asked Sep 25, 2008 at 14:29

Josh Sklare's user avatar

Josh SklareJosh Sklare

4,0243 gold badges23 silver badges17 bronze badges

This particular issue is caused by specifying a dependency to a lib file that had spaces in its path. The path needs to be surrounded by quotes for the project to compile correctly.

On the Configuration Properties -> Linker -> Input tab of the project’s properties, there is an Additional Dependencies property. This issue was fixed by adding the quotes. For example, changing this property from:

C:\Program Files\sofware
sdk\lib\library.lib

To:

«C:\Program Files\sofware
sdk\lib\library.lib»

where I added the quotes.

Amin Ya's user avatar

Amin Ya

1,5341 gold badge19 silver badges30 bronze badges

answered Sep 25, 2008 at 14:33

Josh Sklare's user avatar

Josh SklareJosh Sklare

4,0243 gold badges23 silver badges17 bronze badges

11

This can happen if the file is still running as well.

:-1: error: LNK1104: cannot open file ‘debug\****.exe’

answered Aug 13, 2014 at 16:10

Carol's user avatar

CarolCarol

1,85226 silver badges29 bronze badges

5

The problem went away for me after closing and re-opening Visual Studio. Not sure why the problem happened, but that might be worth a shot.

This was on VS 2013 Ultimate, Windows 8.1.

answered Feb 4, 2015 at 17:07

Daniel Neel's user avatar

Daniel NeelDaniel Neel

1,19713 silver badges28 bronze badges

3

Check also that you don’t have this turned on: Configuration Properties -> C/C++ -> Preprocessor -> Preprocess to a File.

answered Dec 26, 2015 at 19:11

Assaf Levy's user avatar

Assaf LevyAssaf Levy

1,3121 gold badge12 silver badges20 bronze badges

2

My problem was a missing .lib extension, I was just linking against mylib and VS decided to look for mylib.obj.

answered Dec 22, 2015 at 9:51

Patrizio Bertoni's user avatar

I had the same problem.It caused by a «,» in the name of a folder of additional library path.It solved by changing the additional library path.

answered Sep 26, 2013 at 5:20

harsini's user avatar

harsiniharsini

3262 silver badges14 bronze badges

Solution 1 (for my case): restart windows Explorer process (yes, the windows file manager).

Solution 2:

  1. Close Visual Studio. Windows Logoff
  2. Logon, reopen Visual Studio
  3. Build as usual. It now builds and can access the problematic file.

I presume sometimes the file system or whoever is controlling it gets lost with its permissions. Before restarting the windows session, tried to kill zombie msbuild32.exe processes, restart visual studio, check none even showing the problem file on. No build configuration issues. It happens now and then. Some internal thing in Windows does not fix up, needs a restart.

answered Dec 30, 2016 at 9:27

Lissandro's user avatar

1

In my case it was a matter of a mis-directed reference. Project referenced the output of another project but the latter did not output the file where the former was looking for.

answered Aug 13, 2014 at 19:54

Newtopian's user avatar

NewtopianNewtopian

7,5534 gold badges48 silver badges71 bronze badges

I had the same problem, but solution for my case is not listed in answers.
My antivirus program (AVG) determined file MyProg.exe as a virus and put it into the ‘virus storehouse’. You need to check this storehouse and if file is there — then just restore it. It helped me out.

answered Jun 7, 2016 at 6:16

Nazarii Plebanskii's user avatar

1

I had the same error, just with a Nuget package i had installed (one that is not header only) and then tried to uninstall.
What was wrong for me was that i was still including a header for the package i just uninstalled in one of my .cpp files (pretty silly, yes).
I even removed the additional library directories link to it in Project -> Properties -> Linker -> General, but of course to no avail since i was still trying to reference the non-existent header.

Definitely a confusing error message in this case, since the header name was <boost/filesystem.hpp> but the error gave me "cannot open file 'llibboost_filesystem-vc140-mt-gd-1_59.lib'" and no line numbers or anything.

answered Jan 19, 2016 at 11:22

Matthias's user avatar

MatthiasMatthias

3,1802 gold badges24 silver badges38 bronze badges

in my case it was the path lenght (incl. file name).

..\..\..\..\..\..\..\SWX\Binary\VS2008\Output\Win32\Debug\boost_unit_test_framework-vc90-mt-gd-1_57.lib;

as for the release the path was (this has worked correctly):

..\..\..\..\..\..\..\SWX\Binary\VS2008\Output\Win32\Release\boost_unit_test_framework-vc90-mt-1_57.lib;

==> one char shorter.

  1. i have also verified this by renaming the lib file (using shorter name) and changing this in the

Linker -> input -> additoinal dependencies

  1. i have also verified this by adding absolut path instead of relative path as all those «..» has extended the path string, too. this has also worked.

so the problem for me was the total size of the path + filename string was too long!

answered Dec 8, 2020 at 9:09

Alfred Meier's user avatar

1

I had a similar problem. I solved it with the following command to kill the running task:

taskkill /f /im [nameOfExe]

/f: Forces the task to close.
/im: The next parameter is a image name aka executable name e.g. Program.exe.

answered Sep 13, 2021 at 11:44

Marci's user avatar

MarciMarci

3025 silver badges12 bronze badges

For an assembly project (ProjectName -> Build Dependencies -> Build Customizations -> masm (selected)), setting Generate Preprocessed Source Listing to True caused the problem for me too, clearing the setting fixed it. VS2013 here.

answered Nov 16, 2014 at 0:26

MadeOfAir's user avatar

MadeOfAirMadeOfAir

2,9435 gold badges31 silver badges39 bronze badges

I run into the same problem with linker complaining about the main executable missing. This happened during our solution port to the new Visual Studio 2013. The solution is a varied mix of managed and un-managed projects/code. The problem (and fix) ended up being a missing app.config file in the solution folder. Took a day to figure this one out :(, as output log was not very helpful.

answered Dec 4, 2014 at 21:58

Nicko Po's user avatar

Nicko PoNicko Po

7275 silver badges21 bronze badges

I checked all my settings according to this list: http://msdn.microsoft.com/en-us/library/ts7eyw4s.aspx#feedback . It is helpful to me and for my situation, I find out that Link Dependency of projects’ properties has double-quote, which should not be there.

answered Dec 19, 2014 at 16:07

David's user avatar

DavidDavid

1,64617 silver badges22 bronze badges

I’m answering because I don’t see this particular solution listed by anyone else.

Apparently my antivirus (Ad-Aware) was flagging a DLL one of my projects depends on, and deleting it. Even after excluding the directory where the DLL lives, the same behaviour continued until I restarted my computer.

answered Nov 23, 2015 at 1:13

easuter's user avatar

easutereasuter

1,16714 silver badges20 bronze badges

In my case, I had replaced math library files from a previous Game Engine Graphics course with GLM. The problem was that I didn’t add them to the project within Visual Studio’s Solution Explorer (even though they were in the project repository).

answered Feb 4, 2017 at 23:51

Artorias2718's user avatar

I had this issue in conjunction with the LNK2038 error, followed this post to segregate the RELEASE and the DEBUG DLLs. In this process I had cleaned up the whole folder where these dependencies were residing.

Luckily I had a backup of all these files, and got the file for which this error was throwing back into the DEBUG folder to resolve the issue. The error code was misleading in some way as I had to spend a lot of time to come to this tip from one of the answers from this post again.

Hope this answer, helps someone in need.

Community's user avatar

answered Feb 7, 2017 at 4:56

N00b Pr0grammer's user avatar

N00b Pr0grammerN00b Pr0grammer

4,5035 gold badges32 silver badges46 bronze badges

I solved it by adding an existing project to my solution, which I forgot to add in the first time.

answered May 31, 2017 at 18:20

Markus Weber's user avatar

Markus WeberMarkus Weber

1,0591 gold badge11 silver badges24 bronze badges

I had the same error:

fatal error LNK1104: cannot open file 'GTest.lib;'

This was caused by the ; at the end. If you have multiple libraries, they should be separated by empty space (spacebar), no comma or semi-colons!

So don’t use ; or any anything else when listing libraries in Project properties >> Configuration Properties >> Linker >> Input

answered Oct 25, 2017 at 18:31

zar's user avatar

zarzar

11.4k15 gold badges96 silver badges178 bronze badges

I tried above solution but didnt work for me.
So i rename the exe and rebuild the solution.
It works for me.

answered Nov 20, 2019 at 6:20

user3500315's user avatar

I had this exact error when building a VC++ DLL in Visual Studio 2019:

LNK1104: cannot open file ‘C:\Program.obj’

Turned out under project Properties > Linker > Input > Module Definition File, I had specified a def file that had an unmatched double-quote at the end of the filename. Deleting the unmatched double quote resolved the issue.

answered Dec 12, 2019 at 22:14

MikeOnline's user avatar

MikeOnlineMikeOnline

1,00412 silver badges18 bronze badges

Killed msbuild32.exe and built again. It worked for me.

answered Jul 16, 2020 at 11:09

Imad's user avatar

ImadImad

7,14612 gold badges55 silver badges112 bronze badges

My issue was caused by other application using the .dll file I was trying to debug.

Closing the application that was using the .dll solved it for me.

answered Sep 13, 2020 at 1:32

NAGA's user avatar

NAGANAGA

133 bronze badges

Possible solutions:

  1. Check if path contain any white spaces, Go to Properties > Linker > Input > additional path and include «path with white space»

  2. If program are still running, close everything and restart.

  3. Check if .obj file is not created. This happens when you directly build a project while Properties > C++ > Preprocessor > Generate preprocessor file is on. Turn it off and build the project then you can onn Properties > C++ > Preprocessor > Generate preprocessor file.

answered May 30, 2021 at 19:09

Faizanur Rahman's user avatar

I hit the same problem with «Visual Studio 2013».

LNK1104: cannot open file 'debug\****.exe

It resolved after closing and re-starting Visual studio.

answered Nov 14, 2018 at 5:25

user3860869's user avatar

user3860869user3860869

1211 gold badge1 silver badge6 bronze badges

I was having the same problem , I have just copied the code to new project and started the build .
Some other error started coming.
error C4996: ‘fopen’: This function or variable may be unsafe. Consider using fopen_s instead

To solve this problem again, I have added my one property in the Project project as below.
Project -> Properties -> Configuration property -> c/c++ .
In this category there is field name Preprocessor Definitions
I have added _CRT_SECURE_NO_WARNINGS this to solve the problem
Hope it will help …

Thank You

answered Sep 14, 2017 at 10:19

Sunil's user avatar

SunilSunil

31 bronze badge

2

Search code, repositories, users, issues, pull requests…

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

4 Answers

Sounds like a copy of the exe (Debug/Assignment.exe) is already running so visual studio can’t overwrite the file. Have a look in the task manager / process explorer and kill any copies that are running then try again.

answered May 28, 2014 at 0:53

John3136's user avatar

John3136John3136

28.9k4 gold badges51 silver badges69 bronze badges

2

  • What is the task explorer in VS?

    Dec 15, 2018 at 3:57

  • @okey_on thanks for the correction (first person to pick the error in 4.5 years ;-) . task manager or process explorer. Not task explorer. If you still don’t know what I mean google will help ;-)

    Dec 16, 2018 at 18:50

Curiously, in my case it was a CMake ‘debug’ linker library path setting that caused almost the same error, and I guess you can have similar problems with ‘optimized.obj’ linking failures.

LINK : fatal error LNK1104: cannot open file ‘debug.obj’

answered Sep 11, 2017 at 13:45

StarShine's user avatar

StarShineStarShine

1,9401 gold badge27 silver badges45 bronze badges

This is because the compiler doesn’t have access to that file. Change the project directory and try again.

gudok's user avatar

gudok

4,0492 gold badges20 silver badges30 bronze badges

answered Mar 21, 2019 at 14:19

Goutham Raj R's user avatar

For me this error started coming when I turned on Preprocessing output
Project properties -> C/C++ -> Preprocessing -> Preprocess to a file: Yes (/P)

answered Sep 18, 2021 at 3:58

MrNams's user avatar

MrNamsMrNams

6388 silver badges14 bronze badges

  • Remove From My Forums
  • Question

  • 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

Answers

  • 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.

The error message «LINK : fatal error LNK1104: cannot open file ‘MSVCRTD.lib'» is a common issue faced by C++ developers when building their projects in Visual Studio. This error occurs when the linker is unable to find the required runtime library file ‘MSVCRTD.lib’, which is the standard C++ library implementation in Visual Studio. Without this library, the linker will not be able to build the project and generate the final executable.

Method 1: Check Project Configuration Settings

To fix the LINK : fatal error LNK1104: cannot open file 'MSVCRTD.lib' error in C++, you can use the «Check Project Configuration Settings» method. Follow these steps:

  1. Open your project in Visual Studio.
  2. In the Solution Explorer, right-click on your project and select «Properties».
  3. In the left-hand pane, select «Configuration Properties» > «Linker» > «Input».
  4. In the «Additional Dependencies» field, make sure that MSVCRTD.lib is listed. If it is not, add it by clicking the dropdown arrow and selecting «Edit».
  5. In the «Additional Library Directories» field, make sure that the directory containing MSVCRTD.lib is listed. If it is not, add it by clicking the dropdown arrow and selecting «Edit».
  6. Click «OK» to save the changes to your project properties.

Here is an example code snippet showing how to add MSVCRTD.lib to your project configuration:

#pragma comment(lib, "MSVCRTD.lib")

This line should be added to your source code file, typically at the top of the file.

Here is an example code snippet showing how to add the directory containing MSVCRTD.lib to your project configuration:

#include <iostream>
#include <Windows.h>

int main() {
    // Add directory containing MSVCRTD.lib to linker search path
    SetDllDirectory("C:\\path\\to\\MSVCRTD.lib\\directory");

    // Rest of your code here
    std::cout << "Hello, world!" << std::endl;

    return 0;
}

This code snippet uses the SetDllDirectory function to add the directory containing MSVCRTD.lib to the linker search path. This function should be called before any other code that uses MSVCRTD.lib.

By following these steps and adding the necessary code to your project, you should be able to fix the LINK : fatal error LNK1104: cannot open file 'MSVCRTD.lib' error in C++.

Method 2: Reinstall Visual Studio

If you are facing the error «LINK : fatal error LNK1104: cannot open file ‘MSVCRTD.lib'» while building your C++ project, you can try reinstalling Visual Studio to fix the issue. Here are the steps to do so:

  1. Uninstall Visual Studio: Go to Control Panel -> Programs and Features -> Uninstall a program. Find Microsoft Visual Studio in the list, right-click on it and select Uninstall. Follow the prompts to complete the uninstallation.

  2. Download Visual Studio: Go to the Visual Studio website and download the latest version of Visual Studio. Make sure to download the version that matches your operating system.

  3. Install Visual Studio: Run the downloaded Visual Studio installer and follow the prompts to install Visual Studio. Make sure to select the C++ development workload during the installation process.

  4. Open your project: Open your C++ project in Visual Studio.

  5. Rebuild your project: Go to Build -> Rebuild Solution to rebuild your project. This should resolve the «LINK : fatal error LNK1104: cannot open file ‘MSVCRTD.lib'» error.

Here is an example of how to rebuild a C++ project in Visual Studio:

#include <iostream>

int main()
{
    std::cout << "Hello, World!";
    return 0;
}

Save the above code as a .cpp file and create a new Visual Studio project with this file. Then follow the above steps to reinstall Visual Studio and rebuild the project.

I hope this helps you resolve the «LINK : fatal error LNK1104: cannot open file ‘MSVCRTD.lib'» error.

Method 3: Check Windows System Environment Variables

To fix the LINK : fatal error LNK1104: cannot open file 'MSVCRTD.lib' error in C++, you can check the Windows System Environment Variables. Here are the steps:

  1. Open the Start menu and search for «Environment Variables».
  2. Click on «Edit the system environment variables».
  3. Click on the «Environment Variables» button.
  4. Under «System Variables», scroll down and find the «Path» variable. Click on «Edit».
  5. Click on «New» and add the path to the folder containing the MSVCRTD.lib file. For example, C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\lib\x64.
  6. Click «OK» on all the windows to save the changes.

Here is an example of how to add the path to the MSVCRTD.lib file using C++ code:

#include <Windows.h>

int main() {
    // Get the current system environment variables
    LPWSTR env = GetEnvironmentStringsW();

    // Find the "Path" variable
    LPWSTR pathVar = wcsstr(env, L"Path=");

    // Add the path to the folder containing the MSVCRTD.lib file
    wchar_t newPath[] = L";C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29333\\lib\\x64";
    wcscat_s(pathVar, wcslen(pathVar) + wcslen(newPath) + 1, newPath);

    // Set the updated environment variables
    SetEnvironmentStringsW(env);

    return 0;
}

This code gets the current system environment variables, finds the «Path» variable, adds the path to the folder containing the MSVCRTD.lib file, and sets the updated environment variables. This should fix the LINK : fatal error LNK1104: cannot open file 'MSVCRTD.lib' error.

Method 4: Manually Add the Library to the Linker Input

To manually add the library to the linker input, you can follow these steps:

  1. Open your project in Visual Studio.
  2. Right-click on your project in the Solution Explorer and select Properties.
  3. In the left-hand pane, select Configuration Properties > Linker > Input.
  4. In the Additional Dependencies field, add «MSVCRTD.lib» (without quotes).
  5. Click OK to save the changes.

Here is an example of what the Additional Dependencies field should look like after adding «MSVCRTD.lib»:

kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;MSVCRTD.lib

This should resolve the «LINK : fatal error LNK1104: cannot open file ‘MSVCRTD.lib'» error you are encountering.

Понравилась статья? Поделить с друзьями:
  • Ошибка 1103 транзит
  • Ошибка 11003 шкода йети
  • Ошибка 1102 кайрон дизель
  • Ошибка 1103 саньенг кайрон
  • Ошибка 1101 kyocera при сканировании как исправить