Error LNK1104 cannot open file ';.obj' project1
D:\project1\source\project1\project1\LINK 1
I'm using visual studio 2015 and openframeworks, I'm fairly new to the c++ language.
I couldn't find a line of code which refers to this file.
Has anyone had a similar error or does know any tips to find the cause of this error?
The build-process has two main step:
compile
link
In the compiling stage the obj files are built from the source file. In the linking step these obj files are "concatenated" resolving unresolved references and builds the final output (static/dynamic library or an executable).
Your error is a linker error which says that one of the compiled file cannot be found. This can happen when:
the compilation is failed (check the previous errors if any)
the compilation is skipped for the specified source file for some reason (this can happen when the whole project is excluded from the build process or you specified that it should save the preprocessed file only).
Do you have any other error messages or warnings? Please check if you're actually building the specified project (and the actual source file as well). As a first step, you can check it in the Build -> Configuration Manager. Look at the checkbox in the "Build" column.
How are you setting your input paths for the Linker? For C/C++, I have found for Visual Studio the location listed below is NOT the correct way to reference library files during the compiler-linking stage (at least in Community Version 2017). I had a project folder called 'lib' which contained all my .lib files. Originally I had specified a value like (which was wrong):
Linker --> General --> Additional Library Directories: $(ProjectDir)lib;%(AdditionalDependencies)
I was getting error messages like:
error LNK1104: cannot open file 'lib.obj'
I figured out this was the correct way to specify the library directories:
VC++ Directories --> Library Directories
In my case, my value was:
VC++ Directories --> Library Directories: $(ProjectDir)lib;$(LibraryPath)
I had built a static library, say TempLibrary.lib. I was linking this library with my application and got the above error in VS2015. The problem was, that I was mentioning only the name of the library and I missed the extension. i.e, I had added only the name "TempLibrary" in the
Linker->Input->Additional Dependencies.
After I had added the extension (.lib) to the name, the linker issue got resolved. i.e, TempLibrary.lib
I've been trying to compile tulip using cmake to generate visual studio 2012 project files. It's giving me lots of trouble. I don't know how to get this to build. I've been trying to get visual studio to build this for 4 days now, and I'm extremely frustrated. Essentially, I follow the steps here, and then set the variables CMAKE_LIBRARY_PATH AND CMAKE_INCLUDE_PATH according to these instructions.
To get to where I'm at, all you have to do is download tulip, and:
Unzip it, create a separate build directory outside of this source directory
Open CMake-gui to the source and build directories
Hit configure. Check use qt5, tell it where qmake is (make sure it's qt5)
You need some dependencies as described in The Independent CMake tutorial. Grab all those dependencies
As you continue to hit configure, specify each of the directories that it asks for as it errors out. It should ask for freetype, glew, zlib and sphinx. It shouldn't ask for where libxml or libpng, or libjpeg are. I don't know why it doesn't ask for those.
Generate, and then browse to the ALL_BUILD that you've generated. Open it with visual studio
try to build it with visual studio.
In those instructions and in the process of getting CMake to generate the visual studio build files, it specifically asks for freetype's location. But in my build, it doesn't have a clue how to link the freetype library.
Here are the errors that I get
Here is my CMakeCached.txt
I know that many people aren't going to want to exactly try and go about replicating the build environment, so I've uploaded my build directory to dropbox. You can pull the entire thing down, and then open it in cmake gui and open the visual studio files in there too.
https://www.dropbox.com/sh/qsvukh9t5gb6bvt/tOfOBxWgd0
The linker errors you point to (mostly "unresolved external" errors) indicate that there are missing libraries on the link command line.
That is most likely happening because target_link_libraries calls in the tulip project are either being skipped or being called with library names that do not match the library names on disk.
Open up the solution in Visual Studio and right click the project and choose "Properties" -- look at the "Linker > Input" panel at the "Additional Dependencies" field. That should list all the libraries it wants to link to. Is there a freetype library listed there? Does that library exist in the referenced location on your disk?
There could be a mistake in the tulip project, or there could just be something wrong with your build/install of freetype...
UPDATE AFTER SOME CHAT:
Or it may be that you have some libraries built for x86 and some for x64... or maybe some for Debug and some for Release... or maybe even some with the MinGW compiler and some with the Visual Studio compiler. If that's the case, start over, from a clean slate, and build everything with a consistent compiler, configuration type and architecture. Then report back again with an update and see if the problems still remain.
I do with Dave,
You should try to fix your error 1 by 1.
The first error seems to be a link error:
Error 1 error LNK2019: unresolved external symbol gzread referenced in function "public: virtual int __cdecl gzstreambuf::underflow(void)" (?underflow#gzstreambuf##UEAAHXZ) C:\Users\kenne_000\tulip-build\tulip-build-debug\thirdparty\gzstream\gzstream.obj gzstream
gzstream is a third party lib included with tulip source in:
thirdparty\gzstream
from
thirdparty\gzstream\CMakeLists.txt
you can see that the missing symbols should be coming from ZLIB.
However your CMakeCache.txt indicate that
ZLIB_LIBRARY:FILEPATH=C:/Users/kenne_000/dependencies/zlib128-dll/lib/zdll.lib
is found.
So the question may be, was this dependency compiled with the same compiler?
Don't you have compiler-specific name mangling issue ?
I tried to build log4cxx for visual 2012 and, after 4 hours of resolving errors, the build was succesful (i'm not sure :)).
As a second step I tried to create a vs project to test logging.
I used this example but it keep tell me that
mainapp.cpp(2): fatal error C1083: Cannot open include file:
'log4cxx\logger.h': No such file or directory
I already specified in the linker the path of directory debug in additional library directories and I added "log4cxx.lib" additional dependencies .
I'm confused and I don't know how to make it work
thanks in advance for your help
You also need to add the directory, where headers for log4cxx are. This is not for linking phase, but for compiler phase.
This can be done with Project Properties -> Compiler -> Preprocessor (I think, I don't have VS opened now)
You don't include .lib. This file is for linking.
You need to add to includes the directory, which contains directory log4cxx, and that (log4cxx) directory must contain logger.h!
I've been encountering a strange bug in Visual Studio 2010 for some time now.
I have a solution consisting of a project which compiles to a static library, and another project which is really simple but depends on this library.
Sometimes, in the last days extremely frequent, after Rebuilding the Solution or just compiling it with 1-3 changed source files, I get the following error:
2>LINK : fatal error LNK1181: cannot open input file 'thelibrary.lib'
========== Rebuild All: 1 succeeded, 1 failed, 0 skipped ==========
Where compiling thelibrary.lib was a success without any errors or warnings.
I have tried cleaning the solution, but that doesn't always work.
What is wrong here?
In Linker, general, additional library directories, add the directory to the .dll or .libs you have included in Linker, Input.
It does not work if you put this in VC++ Directories, Library Directories.
I can see only 1 things happening here:
You did't set properly dependences to thelibrary.lib in your project meaning that thelibrary.lib is built in the wrong order (Or in the same time if you have more then 1 CPU build configuration, which can also explain randomness of the error). ( You can change the project dependences in: Menu->Project->Project Dependencies )
Go to:
Project properties -> Linker -> General -> Link Library Dependencies set No.
I recently hit the same error. Some digging brought up this:
http://support.microsoft.com/kb/815645
Basically, if you have spaces in the path of the .lib, that's bad. Don't know if that's what's happening for you, but seems reasonably possible.
The fix is either 1) put the lib reference in "quotes", or 2) add the lib's path to your Library Directories (Configuration Properties >> VC++ Directories).
I had the same issue in both VS 2010 and VS 2012.
On my system the first static lib was built and then got immediately deleted when the main project started building.
The problem is the common intermediate folder for several projects. Just assign separate intermediate folder for each project.
Read more on this here
I solved it with the following:
Go to View-> Property Pages -> Configuration Properties -> Linker -> Input
Under additional dependencies add the thelibrary.lib. Don't use any quotations.
I had a similar problem in that I was getting LINK1181 errors on the .OBJ file that was part of the project itself (and there were only 2 .cxx files in the entire project).
Initially I had setup the project to generate an .EXE in Visual Studio, and then in the
Property Pages -> Configuration Properties -> General -> Project Defaults -> Configuration Type, I changed the .EXE to .DLL. Suspecting that somehow Visual Studio 2008 was getting confused, I recreated the entire solution from scratch using .DLL mode right from the start. Problem went away after that. I imagine if you manually picked your way through the .vcproj and other related files you could figure out how to fix things without starting from scratch (but my program consisted of two .cpp files so it was easier to start over).
I'm stumbling into the same issue. For me it seems to be caused by having 2 projects with the same name, one depending on the other.
For example, I have one project named Foo which produces Foo.lib. I then have another project that's also named Foo which produces Foo.exe and links in Foo.lib.
I watched the file activity w/ Process Monitor. What seems to be happening is Foo(lib) is built first--which is proper because Foo(exe) is marked as depending on Foo(lib). This is all fine and builds successfully, and is placed in the output directory--$(OutDir)$(TargetName)$(TargetExt). Then Foo(exe) is triggered to rebuild. Well, a rebuild is a clean followed by a build. It seems like the 'clean' stage of Foo.exe is deleting Foo.lib from the output directory. This also explains why a subsequent 'build' works--that doesn't delete output files.
A bug in VS I guess.
Unfortunately I don't have a solution to the problem as it involves Rebuild. A workaround is to manually issue Clean, and then Build.
I don't know why, but changing the Linker->Input->Additional Dependencies reference from "dxguid.lib" to "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Lib\x86\dxguid.lib" (in my case) was the only thing that worked.
Maybe you have a hardware problem.
I had the same problem on my old system (AMD 1800 MHz CPU ,1GB RAM ,Windows 7 Ultimate) ,until I changed the 2x 512 MB RAM to 2x 1GB RAM. Haven't had any problems since. Also other (minor) problems disappeared. Guess those two 512 MB modules didn't like each other that much ,because 2x 512 MB + 1GB or 1x 512 MB + 2x 1GB didn't work properly either.
For me the problem was a wrong include directory. I have no idea why this caused the error with the seemingly missing lib as the include directory only contains the header files. And the library directory had the correct path set.
You can also fix the spaces-in-path problem by specifying the library path in DOS "8.3" format.
To get the 8.3 form, do (at the command line):
DIR /AD /X
recursively through every level of the directories.
I had the same problem. Solved it by defining a macro OBJECTS that contains all the linker objects e.g.:
OBJECTS = target.exe kernel32.lib mylib.lib (etc)
And then specifying $(OBJECTS) on the linker's command line.
I don't use Visual Studio though, just nmake and a .MAK file
I had the same error when running lib.exe from cmd on Windows with a long argument list. apparently cmd.exe has max line length of about 8K characters, which resulted that the filenames at the end of this threshold got changed, thus resulting in bad filename error.
my solution was to trim the line. I removed all paths from filenames and added single path using /LIBPATH option. for example:
/LIBPATH:absolute_path /OUT:outfilename filename1.obj filename2.obj ... filenameN.obj
I found a different solution for this...
Actually, I missed comma separator between two library paths. After adding common it worked for me.
Go to: Project properties -> Linker -> General -> Link Library Dependencies
At this path make sure the path of the library is correct.
Previous Code (With Bug - because I forgot to separate two lib paths with comma):
<Link><AdditionalLibraryDirectories>..\..\Build\lib\$(Configuration)**..\..\Build\Release;**%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
Code after fix (Just separate libraries with comma):
<Link><AdditionalLibraryDirectories>..\..\Build\lib\$(Configuration)**;..\..\Build\Release;**%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
Hope this will help you.
In my case I had the library installed using NuGet package (cpprestsdk) AND I falsely added the lib to the Additional Dependancies in the Linker settings. It turns out, the package does it all for you.
The linker then tried to find the library in the library path and of course could not find it.
After removing the library from the Additional Dependencies everything compiled and linked fine.
Not quite the answer to OP's question as I am using CMake with Visual Studio as a generator but I personally also just encountered the same issue (I am using Visual Studio toolchain, but not the IDE to build stuff).
My fix was target linking the directory of the directory of the libraries (I had a few) before target linking the library.
//Works
target_link_directories(MyExe PRIVATE /out/of/scope/path/to/lib)
foreach(X IN LISTS LIBSLISTNAMES)
target_link_libraries(MyExe ${X})
endforeach()
//Throws cannot open cannot open input file error
foreach(X IN LISTS LIBSLISTNAMES)
target_link_libraries(MyExe /out/of/scope/path/to/lib/${X})
endforeach()
Not sure what is happening under the hood, but maybe VS IDE has equivalent setting somewhere?
I've also experienced this problem. For me the dependencies were properly set, but one of the projects in my solution wasn't selected for building in the configuration (VS 2022 pro).
I eventually figured out thanks to output in Build -> Clean Solution that mentioned one of the project in dependency chain being disabled. Interesingly enough, when trying to build the disabled project it wouldd not properly build its dependencies.
In the solution were two projects A and B. Building B requires A.lib, and somewhere along the line, the solution was cleaned.
Later, for testing purposes it was desired to build B alone, and the error was mistakenly taken as
cannot open input file 'B.lib'
instead of what it actually was
cannot open input file 'A.lib'
So burning the candles at both ends in order to comprehend why the project B build process would delete its own library!
I created a bin directory at the project_dir level, then created a release/debug directory inside the bin folder, which solved the problem for me.
I can compile the DLL project without any error. It says "Build succeeded".
But I don't see any DLL file in the Debug or Release folder.
There are only .exp, .lib and .pdb files
Visual Studio 2010 by default puts the output files in $(SolutionDir)\Debug or $(SolutionDir)\Release. It's quite likely you are looking at Debug and Release folders inside the project - which are the intermediate folders.
To find out where the output files got open Project Properties > General > Output Directory. By default it is $(SolutionDir)$(Configuration)\ which evaluates to either Debug or Release in your solution directory.
EDIT Visual Studio will tell you where it places the output files in the Output window. Just bring it up by going to "View > Output". It'll say something like this:
1> MFCInterop.vcxproj -> C:\temp\sotest\Debug\MFCInterop.dll
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
I have had issues w/ C# and VB where VS will not create output files.
The root issue seems to be that it lost its mind w/ respect to a reference.
I trouble shot this way
exclude all files
adding in a stub class1 file / compile / verify files are created
add files back one by one and eventually you can determine what the issue is
The issue for me was a .Net version mismatch. The reference had a higher version than the project failing
No answer as to why VS does not yield a compile error in this situation.
If I delete the reference altogether , it definitely complains.
greg
At the bottom Show output from:
Change to Build
Look in the folder identified.