fatal error LNK1104: tcl86.lib

I have tried to compile OpenCascade on Win10 64bit, using VS2017. I compiled on 64bit, but I encounter a link errors, one of them is:

 

1>------ Build started: Project: TKDraw, Configuration: Debug x64 ------
1>LINK : fatal error LNK1104: cannot open file 'tcl86.lib'
========== Build: 0 succeeded, 9 failed, 50 up-to-date, 1 skipped ==========

I noticed that in project TKDraw, I have the following link settings:

 

..\..\win64\vc14\libd\TKMesh.lib
..\..\win64\vc14\libd\TKService.lib
..\..\win64\vc14\libd\TKHLR.lib
C:\ActiveTcl\lib\tcl86t.lib
C:\ActiveTcl\lib\tk86t.lib
gdi32.lib
advapi32.lib
user32.lib
shell32.lib
..\..\win64\vc14\libd\TKShHealing.lib
opengl32.lib
windowscodecs.lib
C:\Program Files\freetype\lib\freetyped.lib
winmm.lib
..\..\win64\vc14\libd\TKTopAlgo.lib
..\..\win64\vc14\libd\TKGeomAlgo.lib
..\..\win64\vc14\libd\TKBRep.lib
..\..\win64\vc14\libd\TKGeomBase.lib
..\..\win64\vc14\libd\TKG3d.lib
..\..\win64\vc14\libd\TKG2d.lib
..\..\win64\vc14\libd\TKMath.lib
..\..\win64\vc14\libd\TKernel.lib
 

As you see, none of them tell me about tcl86.lib, but the compiler say that this lib is missing. Why ? Moreover, I didn't found any tcl86.lib in opencascade folder, so, why is asking  me about this file ? Can you help me a little bit ?

 

Kirill Gavrilov's picture

This is because Visual Studio C++ compiler has a "#pragma lib" feature allowing to add library dependencies directly in C++ code, see src/Draw/Draw.cxx:

// on MSVC, use #pragma to define name of the Tcl library to link with,
// depending on Tcl version number
#ifdef _MSC_VER
// two helper macros are needed to convert version number macro to string literal
#define STRINGIZE1(a) #a
#define STRINGIZE2(a) STRINGIZE1(a)
#pragma comment (lib, "tcl" STRINGIZE2(TCL_MAJOR_VERSION) STRINGIZE2(TCL_MINOR_VERSION) ".lib")
#pragma comment (lib, "tk"  STRINGIZE2(TCL_MAJOR_VERSION) STRINGIZE2(TCL_MINOR_VERSION) ".lib")
#undef STRINGIZE2
#undef STRINGIZE1
#endif

Apparently, your Tcl build has an extra suffix "t" in a file name "tcl86t.lib", so that linker is unable to find "tcl86.lib".
Solutions:

  • Rename tcl86t.lib -> tcl86.lib (the same for tk) in your Tcl installation.
  • Comment/remove "pragma comment" in OCCT source code.
  • Propose OCCT patches to support tcl libraries with extra suffixes which would not require extra steps.