Visual Studio is not compiling due to lib error

694 Views Asked by At

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

1

There are 1 best solutions below

0
Fire Lancer On

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