1

I have installed libraries with vcpkg using the correct triplet :

C:\Users\***>vcpkg list libnoise
libnoise:x64-windows              1.0.0       A general-purpose library that generates three-d...

Then I have executed the following command :

C:\Users\***>vcpkg integrate install
Applied user-wide integration for this vcpkg root.

All MSBuild C++ projects can now #include any installed libraries.
Linking will be handled automatically.
Installing new libraries will make them instantly available.

CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=C:/Windows/vcpkg/scripts/buildsystems/vcpkg.cmake"

But in my Visual Studio 2019 project, with an x64 project, only the headers have been successfully integrated :

#include <noise/noise.h> // The header is found as well as the definition of noise::module::Perlin

int main()
{
   noise::module::Perlin noise; // The implementation is not found
}

When trying to compile this, I get :

1>------ Build started: Project: Mayak, Configuration: Debug x64 ------
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl noise::module::Perlin::Perlin(void)" (__imp_??0Perlin@module@noise@@QEAA@XZ) referenced in function main
1>NoiseVideoGenerator.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl noise::module::Perlin::Perlin(void)" (__imp_??0Perlin@module@noise@@QEAA@XZ)
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl noise::module::Perlin::~Perlin(void)" (__imp_??1Perlin@module@noise@@UEAA@XZ) referenced in function main
1>NoiseVideoGenerator.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl noise::module::Perlin::~Perlin(void)" (__imp_??1Perlin@module@noise@@UEAA@XZ)
1>C:\Users\sylva\source\repos\Mayak\x64\Debug\Mayak.exe : fatal error LNK1120: 2 unresolved externals
1>Done building project "Mayak.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

On a side note, I have looked for the name of the .lib files of the noise library and tried to add them in the Linker > Input properties, it still doesn't work.

What did I do wrong ?

Xobtah
  • 464
  • 7
  • 20
  • Probably you failed to add the path to the library directory to the Linker/General/Additional Library Directories setting. Why you need to do this given the reassuring noises from vcpkg I'm not sure, but I'm not familiar with that tool. – john Oct 20 '20 at 09:00
  • Or maybe you added the library but forgot the .lib extension or both. – john Oct 20 '20 at 09:04
  • Thank you for your comments. After some tests, I found both a bin/ and a lib/ folder in my vcpkg installation, containing .lib files. I managed to compile my project by linking it to the content of the bin folder, with the lib it doesn't compile. Do you know the difference between bin and lib ? Also, as mentioned my vcpkg "Linking will be handled automatically" and the project wasn't automatically linked, so I'm still looking for a solution, if it exists – Xobtah Oct 20 '20 at 09:12
  • I'm not sure. It could be the difference between a static library and an import library, but I'm only guessing. I'm not familar with vcpkg. – john Oct 20 '20 at 09:15

2 Answers2

2

To enable AutoLink, select your current project and go to properties. (Alt-Enter) Make sure you edit the right configuration. Then go to Configuration Properties -> vcpkg and make sure AutoLink is enabled.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Simon
  • 61
  • 1
  • 7
  • 1
    "AutoLink" is already to "Yes". I have tried adding "noise.lib" to the "Additional Dep.", but got an error "LNK1104: cannot open file 'noise.lib'" – Xobtah Oct 20 '20 at 09:52
  • Have you tried it with a different library, eg. boost? It could also be an issue with the library itself. I tried it on my own system and I get the same linking errors you described in your Question – Simon Oct 20 '20 at 10:07
  • You are right, other libraries work... Thank you very much ! – Xobtah Oct 20 '20 at 10:50
  • Maybe vcpkg uses the wrong folder, but I'm not an vcpkg expert. It would be best if you open an issue on [Github](https://github.com/microsoft/vcpkg/issues) – Simon Oct 20 '20 at 11:15
0

It has been fixed by the developers, on GitHub : https://github.com/microsoft/vcpkg/issues/14127

Xobtah
  • 464
  • 7
  • 20