Why does fatal error “LNK1104: cannot open file &#

2019-01-04 00:12发布

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'

20条回答
Viruses.
2楼-- · 2019-01-04 00:21

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.

查看更多
三岁会撩人
3楼-- · 2019-01-04 00:22

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

查看更多
何必那么认真
4楼-- · 2019-01-04 00:23

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

查看更多
Summer. ? 凉城
5楼-- · 2019-01-04 00:25

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.

查看更多
你好瞎i
6楼-- · 2019-01-04 00:30

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

查看更多
一纸荒年 Trace。
7楼-- · 2019-01-04 00:31

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

查看更多
登录 后发表回答