How to import DLL libraries in Visual Studio 2012? - visual-studio-2012

I would like to use an external precompiled library for Fast Fourier Transform.
The files provided are all .dll files with corresponding .def files. In the instructions, it writes that I should create a .lib import library file with lines like:
lib /def:libfftw3f-3.def
Should I just copy the statements in a txt file and rename it to lib? And where I should put this .lib file? And how do I include in my project? Would I still need to state "#include <XXX.dll>" or would the lib file do?
Also, the dll seems to be in C language, would I be able to call its functions in C++?
Thank you very much!

Command prompt: FAQ is a good place to start. You need a .h header file as well as the resulting link .lib, or you can use the .h header file and then use LoadLibrary/GetProcessAddress. See MSDN

Related

How add shared-library to my library project in QT

May i load external library in my library project? If yes. How i can do this.
With Qlibrary? or typically include in pro file LIBS += -L /lib -lmylib and add *.h file to project?
Sorry for my English))))
Just go to your respective Qt .pro file in Qt Creator IDE itself, and right click on empty area and choose "Add Library", Select external Library and click next, now click on browse in front of include path text box and choose the .lib file you want to include and select the platforms you want to target and now click next and finish the process. To add .h file, first copy the .h file in your project folder, and right click on the header under solution explorer, and click on add existinf file, now select your .h file and add it.
Yes you can.
If you want to use shared library just add in you application *.pro file
LIBS+=-Llibrary_location_path -llibraryName
INCLUDEPATH += library_headers_location
Check original documentation http://doc.qt.io/qt-5/third-party-libraries.html
P.S. I suppose you understand that .h files contains declaration of methods that you are going to use in your appplication, while library contains implementation of this methods

writing c++ installer files

My have written a function definition in c++ which I want to use in other c++ projects. In a typical way we include .hpp files in the header
#include "my_fun.hpp"
I don't want to copy each time this file to the right location. What I want is to install this .hpp on my linux machine so that I can type
#include <my_fun>
How to write installer files on linux for c++ project? You know, not just on my machine, but any other person equipped with those files can install and use my function (like a library).
Just copy your header to /usr/local/include. That way it will be included by default, and it will not get mixed in with the headers installe by your package manager to /usr/include.

Merge .cpp with .cu file

I'm a beginner in CUDA programming and I use VC++ 2010. I'm trying to call a kernel file .cu from a main() function in a .cpp file. Now I can't merge these two because they are different projects and solutions. Can you please help me with this? Thanks in advance!
You need to put them in the same project. In msvc10, you have the option to add a .cuh or .cu file (that way it is automatically set up so that nvcc will compile the specific file, and only the binaries? will be linked in the end)
A picture says a million words:

Including files in VS 2012

I want to include a library - I've downloaded it and found exactly four files inside:
.h
.lib
.dll
.def
I've put the header file inside of my project. That's the only thing I did - and the visual throws an error that it cannot open the .lib file.
So I immediately wanted to beg for help on stackoverflow, but I've decided to do a little research first. I've found out that the .dll file should be placed inside of the windows/SYSWOW64 location (for my 64-bit windows 7), I placed it there but VS still displays the same error.
How should I deal with that? Did I missed some step during the "installation"? If so, which ones?
You have to specify the path to the library (*.lib) in your project settings.
(You can put it also into your directory with sources)
The presence of DLL file during build is not required.

How the basic link process works for ELF and PE

I've always been confused about how the linker works, and it's a difficult subject to search for.
To demonstrate my question and to provide a framework for an answer, I'll put down what I know (or think I know) so far. I may be very wrong. :)
First, each .cpp file is built into an intermediate file (.o for Posix/ELF and .obj for Win/PE I believe). This intermediate file contains all the symbols defined by the .cpp it was built from and has instructions for what external links it needs to be properly resolved. As an extension to this, Posix systems let you combine the .o files into a .a file (Which doesn't seem to do anything more than combine? What command does this?). Is .lib the Win/PE equivalent of the Posix .a file?
Next, the intermediate files are linked together, external dependencies resolved, and you have your executable. Am I missing any steps?
Thanks!
Here's a few pieces of the puzzle:
ar(1) is used to create .a files. They are similar to tar(1) or zip files (possibly
with a index to look up an object file by symbol name)
The linker copies together the sections of object files (text, data, bss). For GNU ld, the precise copying of sections can be controlled with a linker script (e.g. copy all sections from .o files containing "text" in their names into a single text section)
The linker also does relocations: patching instructions (jump and data load) with the respective target addresses, once the value of a symbol is known. In some cases, this can't be done at link time, so the linker copies/adjusts the relocation records from the .o files into the final executable.
the windows .lib serves two purposes: a static library (.lib) is similar to .a libraries. An import library (.lib) does not contain the actual code, but only symbol lists. The linker can resolve symbols from the import library, but then knows it needs to put a reference to the corresponding .dll into the executable. On Unix/ELF, the .so file has both the code and the symbol table.

Resources