Error 1 error LNK1104 after change Preprocess to a File - c++

I had to use a preprocessor, so I changed:
Configuration Properties -> C++ -> Preprocessor -> Preprocess to a
File -> Yes
And got the error:
Error 1 error LNK1104: cannot open file 'Debug\asnreal.obj'
The solution to this problem:
I had to add quotes around the path to my .lib file in
Project->Properties->Configuration
Properties->Linker->Input->Additional Dependencies .
I do not understand what kind of file .lib? Where is it? In my project, it is not. What do I need to specify in Additional Dependencies? I tried to add the path to debug my project in quotation marks, but nothing happens.

The compiler outputs either the .obj file or the preprocessed file. When you enable the preprocessor output you effectively disable the output of the .obj file.
The VS doesn't take this in account and starts the linker anyway. Since you didn't output an .obj file the linker can't find it.
You can get much more in trouble when you have an old .obj file in place and changes in the source code generates new preprocessed output but don't get into the linked executable.

Related

Fatal error LNK1181: cannot open input file... But I don't want to open the file

I have obtained source code from another developer that I am attempting to build in VS2013. The solution consists of 11 projects: 1 application and 10 static libraries. Included in the file package was a VS project file for 'LibraryX', an 11th static library which is not included in the solution. However, attempting to build the solution gives the error 'cannot open input file libraryx.lib'
After contacting the developer he informed me that this LibraryX is not ready for release and is therefore not included in the source code (the folder containing the necessary cpp and header files is missing). I should therefore be able to build the solution without it. His suggestions were:
After you open the VS solution, remove the LibraryX library from the solution.
Check (It already wasn't included)
You also need to remove the libraryx.lib from the linker->input list (on the Properties page of the application project).
Check (Again, it was correctly not in the linker input)
You may also need to remove the line
LibraryX::InitModule();
from LibraryABC\libraryabc.cpp as well as remove the include line for LibraryX.h from this file.
I have opened this file and can see the headers and the code block of InitModule() for the other libraries, but LibraryX is not listed. I have searched the entire source code for references to LibraryX and there are none.
How do I find where/why VS is trying to open this file?

(C/C++) libjpeg, missing "Release.obj" file

I downloaded jpeglib-9a. In Visual studio (2012) command prompt I typed this:
nmake /f makefile.vc setup-v10
It created several files and one of them was named "jpeg.sln" which I opened in visual studio (updated to 2012 version) and built. After that, I made new project, included this folder "D:\Data\jpeg-9a" and added this folder "D:\Data\jpeg-9a\Release" to linker.
And when I tried to compile my project, this error appeared:
1>LINK : fatal error LNK1181: cannot open input file 'D:\Data\jpeg-9a\Release.obj'
I was looking for that file but couldn't find it anywhere. I also tried compile that library again but "Release.obj" is still missing.
This is the tutorial which I was following
http://www.dahlsys.com/misc/compiling_ijg_libjpeg/index.html
So is there any way how to create that file ?
Thank you.
(if you need additional information, ask me)
SOLVED: ... I cant read properly ...
Thank you bogdan
You don't need to create that file.
The linker is interpreting the D:\Data\jpeg-9a\Release directory name as an input .obj file name. Most likely, this is happening because you added the directory name in the wrong place in the linker configuration property pages. My guess is that you added it under Linker -> Input -> Additional Dependencies; that's not the right place for a directory - that property is supposed to contain a list of .obj and .lib files to be given as input to the linker.
You need to add the directory under Linker -> General -> Additional Library Directories.

Error LNK1181: cannot open input file when compiling as .LIB

I got a library here which uses the Intel Composer XE 2013 and I would like to compile it as a .lib as I am going to use it with another project (It is compiling as application/EXE by default). However, when I set the Configuration Type under Project Defaults under the Configuration Manager in Visual Studio 2012, I get " error LNK1181: cannot open input file" Odd part is that the file it looks for has no file ending. The project contains both C, C++ and ASM code. Does anyone got any experience with this kind of behavior?
Some common causes for error LNK1181 are:
filename is referenced as an additional dependency on the linker
line, but the file does not exist.
A /LIBPATH statement that specifies the directory containing filename
is missing.
To resolve the above issues, ensure any files referenced on the linker line are present on the system.
Use the /LIBPATH option to override the environment library path. The linker will first search in the path specified by this option, and then search in the path specified in the LIB environment variable. You can specify only one directory for each /LIBPATH option you enter. If you want to specify more than one directory, you must specify multiple /LIBPATH options. The linker will then search the specified directories in order.
To set this linker option in the Visual Studio development environment
Open the project's Property Pages dialog box.
Click the Linker folder.
Click the General property page.
Modify the Additional Library Directories property.
If that doesn't help then you can look through these links :
Getting fatal error LNK1181: cannot open input file
You receive a "fatal error LNK1181" error message when you build a
Managed C++ application
Visual Studio: LINK : fatal error LNK1181: cannot open input
file
I solved the issue by renaming the .obj files without their file extension. For example, it was looking for file name "foo", I had "foo.obj" so I renamed "foo.obj" to "foo".

C++ still looks for a .lib file but I can't see why

I have a VS 2010 C++ project.
When I try to compile it, it tells me
Error 1 error LNK1104: File "C:\Users\MyUser\Desktop\project1\Debug\mysynth.lib" could not be opened. C:\Users\MyUser\Desktop\project1\subproject\LINK subproject
I have removed all dependencies from Linker->Input->, but it is still looking for the above lib.
Where else could this link be stated?
You can specify additional linker options in the configuration dialog. Look under the Linker | Command Line page. Perhaps the errant lib is specified there. In any case you can see there the command line that is passed to the linker and determine whether or not your lib file is there.
The easiest way to work out where they are coming from is to open up the project file in a text editor and search for the errant lib file. If the problem is in the project configuration, this tactic is guaranteed to succeed.
If you have removed everything from your project settings, and you are not passing the errant lib to the linker command line, then the other place where a lib file may be specified is in code. In a #pragma statement. It would look like this:
#pragma comment(lib, "mysynth")
Look in the properties explorer. Read the MSBuild documentation for the order that they are read. This is the most confusing part of going from VS2008 forward.

How to include .obj files into the project

I have the following question:
I was given the task - to build an application. There was a ready file counter.h and some other file - counter.obj. It turned out that in the counter.h there were only declarations of the functions - how can I include .obj file into the .cpp file so that it compiles? I am using Microsoft Visual Studio 2010 - and in which folder should the file itself go?
Add the obj-file to the Solution just as you would do with cpp-files (i usually do this by drag-and-drop, that is, drag the file from the Windows Explorer and drop it on a project in the Solution Exporer window).
You can put the obj-file together with cpp-files; it doesn't really matter.
You do cannot include object file in to a cpp file.
The compiler compiles the cpp file and generates the obj files, for each cpp file, these files are further linked together to create an libray or an executable.
Usually, you would link libraries(.lib or .dll) to an Application, Check if those are with you.
If not,
You can try linking the object file to your application by:
Go to project properties then from "Property Page" select the node "C/C++" their you will get "Additional Include Directories" add the name of your object file.Keep your obj file in the directory where your source code is or you can add the directory from:
Tools->Options->Projects and Solutions->VC++Directories.
I have never tried the second method except for academic projects,which was years ago, So not sure about it, Please check information on MSDN.