1

While I am using CMake project on VisualStudio 2019 for Windows machine, I have this error when I try building my program :

fatal error LNK1104: cannot open file 'boost_unit_test_framework-vc141-mt-x64-1_66.lib'

I have set the Boost Root directory and set the Boost use static libs to ON in my CMakeLists.txt file :

set(Boost_USE_STATIC_LIBS ON) 

set(BOOST_ROOT C:/boost_1_66_0)

find_package (Boost 1.66.0 COMPONENTS system filesystem unit_test_framework REQUIRED)

As described here : lib_prefix

I can see that static library on Windows begin with lib prefix so the error is complaining about the dynamic library which I don't have in my library directory and I don't want to use it.

On another hand, as described in the link also, for the toolset tag, which identifies the toolset and version used to build the binary, my error is complaining about -vc141, but I compiled my library with -vc142 toolset and that what I can find in my library directory.

I am certainly able to download a pre-compiled dynamic 14.1 Library version but I don't want to use it!

I don't know why CMake giving me this error, and how can I fix it, please? Thank you

Gonn
  • 377
  • 5
  • 21
  • I don't know about CMAKE or if you are using it to build boost or just a project. I hear it can be difficult. As you are running with 1.66 I'll guess you have downloaded that a while ago and the libs were built with an older version of VS. Build it yourself. There are countless [duplicates](https://stackoverflow.com/questions/13042561/fatal-error-lnk1104-cannot-open-file-libboost-system-vc110-mt-gd-1-51-lib) on that here. cd c:\boost_1_66_0, run bootstrap.bat. then run b2. The libs will be built in .\stage\lib. You will have to take an extra step with .\b2 and spec x64 if you want the x64 libs – lakeweb Mar 07 '20 at 16:33

0 Answers0