how to auto link to OCC external dlls for personal OCC projects in visual studio?

eue

Active CAD practitioner
I involve OCC libraries with my executable. I have added the lib libd and inc directory and set the Environment PATH shown below, according to OCC Installation and Build instructions. The problem is while it compiles, the exe keep popping occ external dlls not found such as FreeImage.dll and Tbb_debug.dll, I wander how to auto link or not link to the dlls with current configuration?

1662430580080.png
1662430773049.png
1662430927502.png
 
Last edited:

JSlyadne

Administrator
Staff member
FreeImage and Tbb are optional dependencies of OCCT. You can switch them off via CMake, see the picture below

2022-09-06_07-11-12.png
 
  • Like
Reactions: eue

eue

Active CAD practitioner
FreeImage and Tbb are optional dependencies of OCCT. You can switch them off via CMake, see the picture below

View attachment 388
how to do that for personal OCC projects? Each time I configure visual studio for OCC based projects, it will always link to tbb and freeimage of such dll.
 
Last edited:

eue

Active CAD practitioner
o
FreeImage and Tbb are optional dependencies of OCCT. You can switch them off via CMake, see the picture below

View attachment 388
ok, I figured out part of the puzzle, the OCC dlls and lib seems to be built with the tbb and freeimage which are part of PATH variables set by msvc.bat with env.bat.
Although it befuddles me as to why HAVE_TBB and HAVE_FREEIMAGE is set to false while OCC still links to it.
---------
ok never mind, it is the custom.bat that set the two true
 
Last edited:

eue

Active CAD practitioner
but the question still lies as to why same configuration compile and run for all the previous OCC projects I did but fail to run now when I added just my personal dll which does not require tbb and freeimage?
 

JSlyadne

Administrator
Staff member
but the question still lies as to why same configuration compile and run for all the previous OCC projects I did but fail to run now when I added just my personal dll which does not require tbb and freeimage?
Personally I use CMake for MSVC solution configuration & generation, and so don't deal with *.bat files and, unlikely, can assist you. I suppose *.bat files are kinda of outdate configuration system which is still alive out of "humanistic" reasons.

Haven't you though to switch to CMake?
 

natalia

Moderator
Staff member
Hello @eue

There is an example how to manage them in CMake in the ‘extras_viewerNative’ sample of https://gitlab.com/ssv/lessons.

The proposal here is to change CMake file:

- declare variables for FreeType and TBB
Code:
# FreeType
if (NOT DEFINED 3RDPARTY_Freetype_DLL_DIR)
  set (3RDPARTY_Freetype_DLL_DIR "" CACHE PATH "The directory containing binaries of freetype")
  message (FATAL_ERROR "Define 3RDPARTY_Freetype_DLL_DIR dir")
endif()
# TBB
if (NOT DEFINED 3RDPARTY_TBB_DLL_DIR)
  set (3RDPARTY_TBB_DLL_DIR "" CACHE PATH "The directory containing binaries of tbb")
  message (FATAL_ERROR "Define 3RDPARTY_TBB_DLL_DIR dir")
endif()

- append them into the application PATH:
Code:
set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DEBUGGER_ENVIRONMENT "PATH=${3RDPARTY_Freetype_DLL_DIR};${3RDPARTY_TBB_DLL_DIR};%PATH%")


After, at configuration step we'll give path to binaries of these libraries to the variables.

Doing this, Visual Studio will silently has them in its 'PATH' (as we described in CMake file) and will not require them on start.

Best regards
 

natalia

Moderator
Staff member
but the question still lies as to why same configuration compile and run for all the previous OCC projects I did but fail to run now when I added just my personal dll which does not require tbb and freeimage?
Assume that in your personal dll you have linkage to some library of OCCT (e.g. TKService) that has freeimage or tbb connection. It's possible to check it by depends.
 
Top