0

i installed "Irrklang" sound library to include it in a project, but whenever i try to compile, i get errors like that

Severity    Code    Description Project File    Line    Suppression State
Error       unexpected token '\b'       C:\Users\HRJunior\Documents\IRRklang\lib\Winx64-visualStudio\irrKlang.lib   4

i have about 800 of those in a single file (the irrklang.lib), any idea?

VS Enterprise 2019 / W10 1903

  • 2
    It seems you try to build the library file as a source file. You should not. Instead you should *link* with it. To explain a little more: When you build your project, the compiler will compile the source files into *object files*. Object file are binary files with generated machine code. These object files are then passed to a *linker* which links them together into the executable file. A static library (like the `.lib` file you try to use) is basically an archive of object files. I.e. the library is already compiled, and just needs to be linked. – Some programmer dude Jan 17 '20 at 09:39
  • You do not want to compile a binary files – 0___________ Jan 17 '20 at 09:40

1 Answers1

0

You need to specify the .lib file in the project properties, it looks like you might have tried to include it with #include.

If you look in the download, you should see a number of files and directories such as:

  • lib\Winx64-visualStudio\irrKlang.lib
  • bin\winx64-visualStudio\ containing some examples and 3 DLL's
  • include\ containing a bunch of .h files.
  • examples\ containing a bunch of example projects include Visual Studio solutions.

So what we have here is a DLL library, with an import library (.lib) and a bunch of header files.

The example projects are a good thing to compare to and see where your project is wrong.

If you right click on your project -> properties -> Linker -> General. Under "Additional Library Directories" -> Edit add a line with the directory containing the .kib file, e.g. C:\Users\HRJunior\Documents\IRRklang\lib\Winx64-visualStudio\ (at this point I would note that the project probably won't work if given to anyone else. You might put IRRklang in a subdirectory of your project, e.g. C:\Users\HRJunior\Documents\CoolProject\thirdparty\IRRklang\lib\Winx64-visualStudio\ then in MSVC use $(SolutionDir)thirdparty\IRRklang\lib\Winx64-visualStudio\, then you can give anyone C:\Users\HRJunior\Documents\CoolProject\ and it should work).

Then under Linker -> Input, for Additional Dependencies -> Edit add a line with irrKlang.lib. Alternatively add the line #pragma comment(lib, "irrKlang.lib") somewhere in your source.

Then under C/C++ -> General, for Additional Include Directories -> Edit add a line to the directory containing the headers, C:\Users\HRJunior\Documents\IRRklang\include.

At this point your project should build, but trying to run you will get a missing DLL error, copy those 3 DLL files to your output directory containing your exe. You could have VS do this automatically by in properties going Build Events -> Post Build Event then for Command Line using a copy command such as: xcopy "C:\Users\HRJunior\Documents\IRRklang\bin\winx64-visualStudio\*.dll" "$(OutDir)" /Y

Fire Lancer
  • 29,364
  • 31
  • 116
  • 182