Search code examples
c++visual-studio-2019fltk

Can not open file "fltkd.lib" error in Visual Studio 2019


#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>

int main()
{
    FI_Window window(200, 200, "Window title"); // error: FI
    FL_Box box(0, 0, 200, 200, "Hey, I mean, Hello, World! ");
    window.show();
    return Fl::run();
}

I build the above code in VS 2019 and and get an error code LNK1104 | Can not open file "fltkd.lib". I have all the linker settings/values checked as suggested in the book Programming Principles and Practices using C++ by Bjarne Stroustrup and other online sources but still I am getting the error. Is there some different settings with VS 2019 or am I putting the libs file in the wrong directries.

Directory where I put the libs files:-

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\lib


Solution

  • LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library

    If you compiled one file to use one kind of run-time library and another file to use another kind (for example, debug versus retail) and tried to link them, you will get this warning. You should compile all source files to use the same run-time library.

    Project -> Properties -> C/C++ -> Code Generation -> Runtime Library

    There are 4 versions of the CRT link libraries present in vc\lib:

    libcmt.lib: static CRT link library for a release build (/MT)

    libcmtd.lib: static CRT link library for a debug build (/MTd)

    msvcrt.lib: import library for the release DLL version of the CRT (/MD)

    msvcrtd.lib: import library for the debug DLL version of the CRT (/MDd)

    According to the Doc:Linker Tools Warning LNK4098

    when your executable uses the multi-threaded, non-debug run-time libraries, the list reported should include LIBCMT.lib, and not LIBCMTD.lib, MSVCRT.lib, or MSVCRTD.lib. You can tell the linker to ignore the incorrect run-time libraries by using /NODEFAULTLIB for each library you want to ignore.