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
Related
Situation
I learned a lot over the last year, but this is something I just could not wrap my head around. Project is C++. CMake 1.15.2. Visual Studio 2015.
I converted a whole Solution *.sln file with cmake-converter and wrote FindXXX.cmake Modules for all external *.libs defined in the *.vcxproj files.
Everytime I encountered an error: unresolved external I added the corresponding Target Sometarget::somecomponent to the target_link_libraries(ConsumingTarget ... ) call.
Now I have a build that works and produces no errors. Some executables say something along the lines of:
"Execution of code cannot be continued because somecomponent.dll is not found..."
I have
An original .sln file that produces executables only requiring .lib files
A CMake generated .sln file that produces executables requiring .dll files
Working FindXXX.cmake files which add_library(XXX::yyy UNKNOWN IMPORTED)
They find the headers and the .lib files (.dll files are not existing/intended/needed in the original VS .sln)
They create the corresponding Targets for all .lib files
Consuming Targets which target_link_libraries(ConsumingTarget PRIVATE XXX::yyy)
"A working build"
An error "before starting the main function".
What I have tried
I have tried defining an OBJECT Library and adding this to the sources of ConsumingTarget and removing Sometarget::somecomponent from the target_link_libraries call. CMake Doc on Object Libraries
I have tried reading and understanding the difference between module and library. Even the CMake documentation on imported Libraries couldn't help me understand my problem.
I have tried reading and understanding the difference between linking a static and shared library.
My Assumptions
Adding the imported library is done wrong by me.
Reason: DependenciesGui.exe shows different dependencies for the cmake-generated-executable and the original-sln-executable but the linker calls (shown in VisualStudio 2015) seem to be the same.
Whole Program Optimization in the CMake File does not work the same way it does in the original .sln file although the Flags are activated at all levels described in this answer.
Reason: compiling with the original file I noticed warning C4505: 'foobar': unreferenced local function has been removed - I don't seem to get those warnings with the cmake-generated build.
subassumption: Functions which won't be called are optimized away, thus removing the necessity for the .dll file.
I expect/hope for
ConsumingTarget.exe to run without asking for somecomponent.dll
another explanation on imported targets and how to link libraries where .dlls should not be necessary.
an explanation on how to analyze/compare the two binaries regarding their symbols(?) and map the seen information to CMake commands. (I am using DependenciesGui.exe to look for dependencies in the .exe file)
Possible reason for failure
One executable had no /DELAYLOAD... directive after conversion with cmake-converter. Opened Issue. Question Title still holds.
Edits:
1: Added possible reason for failure
I am attempting to compile a project in visual studio 2013 that is using boost 1.58.
I am receiving this error:
Error 3 error LNK1104: cannot open file 'libboost_log-vc120-mt-1_58.lib'
This entry is in my VC++/General/Library Directories
$(BOOSTDIR)\lib\x64
the value of my BOOSTDIR directory is
C:\Projects\boost_1_58_0
I have verified that the path C:\Projects\boost_1_58_0\lib\x64 has the "libboost_log-vc120-mt-1_58.lib" file.
What could I be missing?
I resolved the issue by rebuilding boost and then adding the new lib location as follows:
Add $(BOOSTDIR)\libs;$(BOOSTDIR)\stage\lib; to Additional Libraries
Add $(BOOSTDIR) to Additional Include Directories
I'm guessing there was a compiler mis-match between my project and whatever boost was built with (even though my coworker told me it was built using the same compiler). Or it could have been the path was wrong or missing.
I am trying to use OpenCv in Visual Studio 2012. I followed every single step this question has provided and every other that can be found on the internet. I even tried to work with different versions of opencv but the error didn't go away.
The error is:
error LNK1104: cannot open file 'opencv_calib3d230d.obj'
All the required libraries are included in linker configurations of visual Studio. Envoirnmental variable "Path" has also been updated but still the error is there.
What can I do to solve this problem?
I have search for calib3d230d.obj every where but it is not inside the extracted folder.
I downloaded OpenCv superpack.exe from HERE
Regards
Firstly, you should be linking to .lib files, opencv does not normally include any .obj files. Change this in your linker dependencies. Secondly, do you definitely have the debug version of the libraries? If not, then you need to specify the static libraries without the d on the end of the name (opencv_calib3d230d.lib -> opencv_calib3d230.lib).
I encountered the same problem before. Finally I found that I forgot to type ".lib" after the library file in vc++ linker.
Wish this can help you.
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!
Running visual studio 2010 writing an openGL program in C++
I'm getting this error, and can't for the life of me figure out why
fatal error LNK1104: cannot open file 'Image_Loading/nvImage.lib'
The file is in the correct place, and nvImage.lib is present in the additional dependencies of the linker, any ideas??
The folder "Image_Loading" is probably not in your library search path. Include files has a different search path, so even if its find the includes, the folder might be missing from the libary search path.
you should either add the folder to the LIB enviromental variable, or add /LIBPATH:folder to the command line of the linker.