1>LINK : fatal error LNK1104: cannot open file - c++

I am trying to add external libraries to my project but I always get this error
LINK : fatal error LNK1104: cannot open file 'C:\Users\Lubdmila\Desktop\OpenMAT-1.3.4\lib\x86.obj'. I was following these instructions:
(I was given these instructions )
The LpSensor library contains classes that allow a user to integrate LPMS devices into their own applications. The standard library is a Windows 32-bit C++ library for MS Visual C++ (express) 2010. Should you require a binary of the library to work on another operating system or 64-bit applications, please contact LP-RESEARCH.
Compiling applications that use the LpSensor library requires the following components:
Header files (usually in C:/OpenMAT/include):
LpmsSensorManagerI.h Contains the interface for the LpmsSensorManager class.
LpmsSensorI.h Contains the interface for the LpmsSensor class
ImuData.h Structure for containing output data from a LPMS device
LpmsDefinitions.h Macro definitions for accessing LPMS
DeviceListItem.h Contains the class definition for an element of a LPMS device list
LIB files (usually in C:/OpenMAT/lib/x86):
LpSensorD.lib LpSensor library (Debug version)
LpSensor.lib LpSensor library (Release version)
DLL files (usually in C:/OpenMAT/lib/x86):
LpSensorD.dll LpSensor library (Debug version)
LpSensor.dll LpSensor library (Release version)
PCANBasic.dll PeakCAN library DLL for CAN interface communication (optional).
ftd2xx.dll The FTDI library to communicate with an LPMS over USB.
To compile the application please do the following:
Include LpmsSensorManagerI.h.
Add LpSensor.lib (or LpSensorD.lib if you are compiling in debug mode) to the link libraries file list of your application
Make sure that you set a path to LpSensor.dll / LpSensorD.dll, PCANBasic.dll (optional) and ftd2xx.dll so that the runtime file of your application can access them.
Build your application.
I am using MS Visual Studio 2010 express 32-bit.And this is what I have done:
1) Project/Properties/Configuration Properties/C/C++/General/Additional Include Directories path---C:\Users\Lubdmila\Desktop\OpenMAT-1.3.4\include
2)Project/Properties/Configuration Properties/Linker/General/Additional Library Directories---C:\Users\Lubdmila\Desktop\OpenMAT-1.3.4\lib\x86
3)Project/Properties/Configuration Properties/Linker/Input/Additional Dependencies---C:\Users\Lubdmila\Desktop\OpenMAT-1.3.4\lib\x86
4) Project/Properties/Configuration Properties/VC++ Directories/General/ Include Directories path---C:\Users\Lubdmila\Desktop\OpenMAT-1.3.4\include
5) include "LpmsSensorManagerI.h"
I have tried to add quotes around the paths but it did not help.I have no clue why I am getting this error.
Does anyone know what I am doing wrong?
Thank you

It seems you have mistakenly added
" C:\Users\Lubdmila\Desktop\OpenMAT-1.3.4\lib\x86 " to the additional dependencies under
" Properties/Linker/Input/Additional Dependencies- "
In this section you should simply list your additional library names, such as
" LpSensor.lib "
The path " C:\Users\Lubdmila\Desktop\OpenMAT-1.3.4\lib\x86 " is already set in " Properties/Linker/General/Additional Library Directories--- " for the linker to look for.

It works now. I created a new project did the same steps but I changed step 3 as harry 268 advised and then I added path to dll files.
Here's the link to the solution: How to add a path to dll files
Visual Studio: how to set path to dll?

In my case I had fatal error LNK1104: cannot open file 'C:\Users\..\proj.exe'
in order to solve this issue, I just copied whole proj folder and renamed it. and that is working now

Related

Configuring Visual Studio to work with Boost.Python and Python 3

I had Microsoft Visual Studio Community 2013 (Version 12.0.31101.00 Update 4) and Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017) on my PC with Windows 10 Pro.
In order to try examples with Boost.Python I downloaded boost 1.64.0 and build libraries by b2 with options --with-python --toolset=msvc --build-type=complete. As a result I have the following files:
boost_python3-vc120-mt-1_64.dll
boost_python3-vc120-mt-1_64.lib
boost_python3-vc120-mt-gd-1_64.dll
boost_python3-vc120-mt-gd-1_64.lib
libboost_python3-vc120-mt-1_64.lib
libboost_python3-vc120-mt-gd-1_64.lib
libboost_python3-vc120-mt-s-1_64.lib
libboost_python3-vc120-mt-sgd-1_64.lib
libboost_python3-vc120-s-1_64.lib
libboost_python3-vc120-sgd-1_64.lib
Then I created project (type: Win32 / DLL) in Visual Studio with the following code taken here:
char const* greet()
{
return "hello, world";
}
#include <boost/python.hpp>
BOOST_PYTHON_MODULE(hello)
{
using namespace boost::python;
def("greet", greet);
}
In project properties for C/C++ settings I added "Additional Include Directories" to locations of Boost and Python (ends with \Python36\include).
During the first attempt to build the project an error appears:
Error 1 error LNK1104: cannot open file 'python36.lib'
So in project properties for Linker settings "Additional Library Directories" I added corresponding location (ends with \Python\Python36\libs). After that I could move on ... to the next error:
Error 1 error LNK1104: cannot open file 'boost_python-vc120-mt-gd-1_64.lib'
It is noteworthy that the difference in filenames I had and VS2013 looking for is just digit 3 after word python.
Similar questions at stackoverflow and in google groups are discussed but without valuable tips. The only useful information is that library file names *boost_python-* corresponds to Python 2 and *boost_python3-* to Python 3.
I noticed that changing the build type (Solution Configuration) from Debug to Release leads to change the error message in part of library file name (there is no -gd- now):
Error 1 error LNK1104: cannot open file 'boost_python-vc120-mt-1_64.lib'
I suppose, VS2013 knows boost library file name convention, but probably does not know the difference about Python 2 and Python 3.
So, I have 3 questions:
Is it possible to influence the logic used by VS to look for Boost.Python library? (Of course lib-files renaming is also an option, but I do not like this for some reason)
Do the linker options allow specifying lib-file directly? (i.e. I can write whole path to the boost_python3-vc120-mt-1_64.lib including file name, not just folder name in section "Additional Library Directories")
What option in the project properties should make VS2013 to use different LIB or DLL files, e.g. libboost_python3-vc120-mt-1_64.lib or boost_python3-vc120-mt-1_64.dll instead of boost_python-vc120-mt-1_64.lib?
With the community help I have found answers to couple of the questions.
Is it possible to influence the logic used by VS to look for Boost.Python library?
Name of library depends on value defined as macro BOOST_LIB_NAME in file boost/python/detail/config.hpp.
I have tried to change line (108 in boost 1.64.0)
#define BOOST_LIB_NAME boost_python
to
#define BOOST_LIB_NAME boost_python3
And desirable library file changed from boost_python-vc120-mt-1_64.lib to boost_python3-vc120-mt-1_64.lib.
It should be noted, that instead of changing values in config.hpp file auto_link.hpp can be created and used with redefinition of BOOST_LIB_NAME.
What option in the project properties should make VS2013 to use different LIB or DLL files, e.g. libboost_python3-vc120-mt-1_64.lib or boost_python3-vc120-mt-1_64.dll instead of boost_python-vc120-mt-1_64.lib?
That is also regulated by defines.
In particular, adding to the beginning of my code (before #include <boost/python.hpp>) the line
#define BOOST_PYTHON_STATIC_LIB
forces MSVS to search file libboost_python3-vc120-mt-1_64.lib (or libboost_python-vc120-mt-1_64.lib), i.e. static lib.
And vice versa line
#define BOOST_PYTHON_DYNAMIC_LIB
or
#define BOOST_ALL_DYN_LINK
can be used to import code from a dll.

Linking a library and still fatal error LNK1104: cannot open file 'OpenVolumeMesh.lib'

I really did not want to post on something possibly asked a zillion times, but this is very desperate.
I have a solution named HexEx containing 6 projects. 3 of them do not build due to not finding this lib.
The process I follow:
step 1) Configuration properties>general>configuration type set to .exe
step 2) VC++ directories: Added the path where the .lib is (doubled checked the path is correct through the cmd and checked the name is correct (indeed the name is OpenVolumeMesh.lib although the .lib does not appear in windows)).
I added the path in executable directories and library directories.
step 2.5) VC++ directories: Added also include path used to create the OpenVolumeMesh.lib
step 3) In linker >general I added the same path to >Additional Library Directories.
step 4) In linker, once more in >Input I added the library (OpenVolumeMesh.lib) to Additional dependencies.
The error I get is:
3>LINK : fatal error LNK1104: cannot open file 'OpenVolumeMesh.lib'
in 3 out of the 6 projects, I suppose the ones needing it.
Another attempt I tried (and this is probably stupid) was to add #pragma comment(lib,"OpenVolumeMesh.lib") in every .c or c++ file containing code.
The .lib was created by building a previous project of mine. All of this is done in VS 12 2013 x64.
From what I read there must also be some .dll put in windows system32 folder some times? Might this be the problem?
Any suggestions?

Error when trying to compile using sqlite3_open in Visual Studio 2013

I'm working in a Cocos2dx (c++) win 32 project and trying to use sqlite to save the game data. My knowledge of c++ / Visual Studio is very limited right now.
This is part of the code that I'm trying to compile.
#include <sqlite3\include\sqlite3.h>
...
void HelloWorld::SaveAndLoadTest()
{
sqlite3 *pdb = NULL;
sqlite3_open("writablePath", &pdb);
...
}
But when I try to compile the line with the sqlite3_open command I get the following error:
Error 7 error LNK2019: unresolved external symbol _sqlite3_open referenced in function...
I've been trying to find an answer for this many hours. The most similar question I found was this one but I don't understand the answer.
Error: undefined reference to `sqlite3_open'
You need to link the sqlite3 library along with your program:
g++ main.cpp -lsqlite3
I'm new to Visual Studio and I don't understand how to solve this, anyone?
The error LNK2019 means that references are missing probably because a library is mising.
To add sqlite to a MSVC project, you have to make sure that:
the header is included in your source files
sqlite3.dll is in the path or in the directory of the executable
AND that sqlite3.lib is added to the additional dependencies in the VS project (options of the project > Linker > Input > Additional dependencies)
This last point is mandatory, because the lib tells the linker which functions are stored in the dll.
The solution, quite simply, is to link sqlite3 to your project. Libraries need to be linked (via the linker) for you to be able to use them. Head over here and download the pre-compiled binaries for your platform of choice (in this case, Win32). You may also choose to compile sqlite3 from source. You should end up with a .lib file. Go to Project -> Configuration Properties -> Linker -> General -> Additional Include Directories and add the path to your library file to it. Then go to Linker -> Input -> Additional Dependencies and put in sqlite3.lib.
And remember that you must build sqlite3.lib from file SQLite3.def:
Download source from source (https://www.sqlite.org/download.html)
For example: source https://www.sqlite.org/2022/sqlite-amalgamation-3390300.zip
Or download binary from binary
For example: binary https://www.sqlite.org/2022/sqlite-dll-win64-x64-3390300.zip
Extract both archives to the same directory
Open Developer Command Prompt for VS 2017 by typing Developer Command in Windows Search
Go to directory where you've extracted source code and binary files (via opened cmd)
Run lib /DEF:sqlite3.def /OUT:sqlite3.lib /MACHINE:x64
(Remember if win32, replace "MACHINE:x64" by MACHINE:x86)

visual c++, LINK : fatal error LNK1104: cannot open file

I'm new C++, I have a dll file called DiceInvaders.dll, in my project, I need to use this library, I'm using visual c++ 2010, I set the Linker Input as DiceInvaders.lib and DiceInvaders.dll, I also copied this dll file to my porject directory, I always got error in this line of code:
m_lib = LoadLibrary("DiceInvaders.dll");
assert(m_lib);
The error is assertion failure. How should I solve this? Thank you in advance.
First you cannot pass the DLL to the linker like you are, it is not a file type that the linker recognizes and cannot be linked that way. When you create the Diceinvaters.dll file the linker will create an import library with the same filename and the extension .lib. It appears this is already being done. That is the library file you should pass to the linker when building any application that uses it.
Second, the Diceinvaders.dll file must be accessible in the DLL search path. This varies slightly depending on which version of Windows you are using but is generally something like the following
The directory the program was loaded from.
The current working directory.
The System directory.
The Windows directory.
The directories that are listed in the PATH environment variable.
Placing the DLL in your project directory is not going to be enough. Instead you should place it in the same directory as the EXE file(s) that have a dependency on it.

delay load DLL error (module not found)

I am working on Visual Studio 2010 Express and I have a question concerning external DLLs.
I am using a DLL.
My question is: why do I get an error (0xC06D007E: Module not found) unless I put the .dll file in my project file.
To be specific, I use FFTW as an external library (a fast Fourier transform library). I followed the procedure: adding the .h file to the project; setting the proper linker properties:
I have added the fftw library path to "répertoire de bibliothèques supplémentaires", in the "general" tab of the linker property tab (sorry, it’s in french!)
I have added the name of the .lib file in the "Dépendances supplémentaires" field and the name of the .dll file in the "Chargement différé des DLL" field, both in the "entrée" (input) tab.
I have tried to fix things without changing the location of the dll file. I did not succeed.
Does someone have a suggestion?
Thanks
In a rough translation, "répertoire de bibliothèques supplémentaires" could be "directory containing additional libraries", "Dépendances supplémentaires" ~ "other dependencies" and "Chargement différé des DLL" ~ "DLL delayed loading" (not sure of this one).
This is a runtime issue. All the IDE settings that you discuss relate to the compilation and linking. But your issue arises at runtime.
DLLs are loaded at runtime and the system looks for them using the Dynamic-Link Library Search Order. Clearly you need your DLL to be found by that search. The simplest, and usually the preferred, way to achieve this is to place the DLL in the same directory as the executable.