Import a dll function in Mathematica?

LibraryLink is a C interface. This means that it is straightforward to use it either from C or C++.

If you use CreateLibrary from within Mathematica, you should place the source code in a separate file that has a .cpp extension. Do not write the code in a Mathematica string. Put it in a separate file. Then everything will work out of the box.

If you use Windows, I strongly recommend you use the officially supported Microsoft compiler. You can download a compatible version here. Install the command line tools and the Windows SDK. No addition configuration is needed from within Mathematica.

Then start with the basic examples here: