Using .dll in Visual Studio 2010 C++ - c++

I have a problem. I place my .DLL and .LIB file in the same directory as my project, go to Properties -> Common Properties -> Framework and References -> Add New Reference. But the list comes up empty.
Is there something else I should be doing?

C++ is not C#. You don't include .dlls in C++ applications by adding "references". Unless it's C++/CLI, but that's not C++.
In C++, you would go, in the project configuration, to Linker->Input->Additional Dependencies. There, you would list the library name plus path to the .lib in question.
Normally, when you build a Windows C/C++ DLL, you also get a .lib. This is an import library; users of the library include (as stated above) that .lib in order to access the DLL. They generally do not load the .dll directly (though there are ways to do that).

Related

Visual Studio 2019 - How to add a .lib to a c++ library project?

I created a c++ library with VS2019
my other projects see and use that library fine, they compile fine
but my library itself cannot be compiled as it complains about missing entry points for a depending lib
I want to add that .lib file, like I did for my other projects
but in the library project settings, there is no linker option, so I cannot tell it to use the missing .lib dependency
how do I resolve this ?
thanks for helping me on this
[edit] strangly enough SDL libraries dont cause any problem (becos of dll's ?) while nfd.lib has no dll
maybe the reason I cannot link my library with static libraries ?
image
but my library itself cannot be compiled as it complains about missing entry points for a depending lib
The library project can only be built but not compiled. After you finish building the .lib project, you will get a .lib file like this in the debug folder. And then you could add it to your C++ project.
According to your description, If you want to add a .lib to a .lib project? If so, I suggest you could try to add the name of the .lib file with its extension to Additional Dependencies. Librarian -> General -> Additional Dependencies. Here is the equivalent of linker input. And then add the path to the .lib file to the Additional Library Directories. Librarian -> General -> Additional Library Directories.Here is the equivalent of linker General.

how to call unmanaged dll from managed c++

I am calling an unmanaged DLL from managed C++. The DLL has more than one native dependency. I am trying to compile this through Visual Studio.
I have done the following:
Added the directory that contains the DLLs and the .lib to Properties -> VC++ Directories -> Library directories
Added the unmanaged .lib to Properties -> Input -> Additional Dependencies
However, I get linking errors for the functions that I refer to. I haven't added any DLL or lib to the project except for the header file of the library.
UPDATE:
So it is able to find the .lib because if I give a bogus .lib in additional dependencies I get compilation error of the .lib not found. The error that I have is "unresolved token .... " .
I suggest you have a good read of this. Calling DLLs from C# is straightforward, because .NET supports it and managed C++ is just another .NET implementation, and should also be straightforward.

Add a C++ dll in Visual Studio 2012 - No references folder

Ok, so I've seen a few tutorials tell me how to do this but my interface and results don't match theirs. I've done this a lot myself with C#, and I don't get why the difference is.
*I have a third party dll (and lib, and .h files)
*I have a project in Visual Studio 2012 Express
*I want to add the dll to the project (I believe what I want is to implicitly link).
There is no References folder in my Solution Explorer. If I select [Project > Properties > Framework and References > Add New Reference] then all it will show me is other projects in my solution. I've looked around at the project options (Linker > Additional Dependencies, etc) but there are a lot of possible places which might do something (or not) in who-knows-what combination.
C++ and C# are different. when you choose c++ project it requires different approach than C# to configure things. You have to add first you header files path in additional include directory then you dll path in linker and dll name in linker input in project settings.
Add the .lib file to the Project -> Properties -> Linker -> Input -> Additional Dependencies field, and #include the .h file. The .dll file will need to be in the search path which is documented here.

How to implement and use a .dll or .lib in a Visual C++ Project? [SA-MP Source]

I am trying to learn more about Multiplayer Modifications so i've downloaded the source code of San Andreas Multiplayer.
My problem is that the client project creates a .dll and a .lib files. I've searched on many sites how to implement them into a new project but i just did not find a clear answer.
So i am creating a new Visual C++ project where i need to implement the libraries resulted from SAMP Client compilation. Any help would be great :).
If you want you can join me in this project.
I don't know how SAMP dlls are but in general, this is how it works:
Linker need *.lib files. So you should copy lib files to your default lib directories or create a new directory under libraries of your project and copy them in it.
If the project you want to link have include files too, do what you did for lib files for include files too. Copy them to include directory.
Put DLLs in a directory that your application can reach. This can be your Debug folder or even it can be Windows or System32 directory. Choose where to put them on your own (it depends on many parameters. Pick one that fits you).
This link tells you how to put them in project directories.
That's it. You can call functions of the project you want to use. Tell me if you got problem.

Simple Way to Use a DLL

I followed the MSDN walkthrough on creating and using a DLL in Visual C++ Studio, but it requires the user to add the DLL project to the same solution as the project they're working on.
Is there a simple way to include a DLL? Ideally, I'd like to just distribute my .dll (and the .lib, I suppose) to my friends so they can use it in their own projects.
I realize there are other walkthroughs out there (some of them on SO), but they all require editing the PATH environment variable, etc. Is that really the simplest way?
At a minimum, you need to do the following:
Include the .lib file in the project
Tell the linker where you put the .lib file (library search path)
Make the .dll file available at runtime (easiest is to put it in the same directory as the .exe)
To distribute the compiled .dll to your friends, you will need to include:
the .h file(s) for the compiler
the .lib file for the linker
the .dll file for runtime