Tips and Tricks for developers on Windows
Easily edit environment variables on Windows system
Environment variables are used on all system (Windows, Linux, Mac OS …) to define specific values used by software or the system itself.
On Windows system, editing environment variables can be really hassles if you use the default system tool. To answer this issue, we recommend you to use the freeware Rapid Environment Editor.
When launching it, on the left side of the application are displayed the system environment variables.
You may want to edit them using this explorer.
You will need administrator privilege to edit the system environment variable. Otherwise, you will be limited to local environment variables (located on the right side of the application).
The specific environment variable Path
is the most important one. It contains a list of folders in which the system will look for finding an application or a specific library.
The Path environment variable is thus really important to be correctly set, in order for CamiTK applications to find their dependencies (ITK, VTK libraries …).
Use Dependency Walker to understand why the application can not load plugins on Windows system
Dependency Walker is a free utility that builds a hierarchical tree diagram of all dependent modules. Dependency Walker is very useful if a module can not be loaded by your application. If you load the module into Dependendy Walker, it gives you the list of all the functions that are exported by that module, and which of those functions are actually being called by other modules. It will detect if the problem comes from missing modules, invalid modules, import/export mismatches, circular dependency errors, mismatched machine types of modules, or module initialization failures.
Check the DLL dependencies
This can be done thanks to cygwin. git bash
comes with numerous very handy tool for developers.
cygcheck
is one of them. This is the equivalent of ldd -r
on windows!
Just open a git-bash console and try for instance:
cygcheck.exe executable.exe
You may also use the MSVC tool dumpbin
, just to list the required dll.
The equivalent of the example above would be:
export PATH=$PATH:/c/path/to/executable
dumpbin -DEPENDENTS executable.exe
How to check if a DLL is compiled for 32 bits or 64 bits on Windows system ?
Using Visual Studio compiler
- Open visual studio command prompt
- Use this command:
dumpbin /headers C:\path\name.dll
- at the very beginning you will find “FILE HEADER VALUES”, the first value will have a “(x86) ” for 32 bit and “(x64)” for 64 bit
Using cygwin (that comes with git on Windows)
To check if a binary (in this example /c/install/bin/vtkrenderingcore-8.2.dll
) is compiled in 32bits or 64bits, just open a git-bash console
dumpbin -headers /c/install/bin/vtkrenderingcore-8.2.dll | findstr "machine"
# or even easier
file /c/install/bin/vtkrenderingcore-8.2.dll
This prints:
8664 machine (x64)
# or with file
/c/install/bin/vtkrenderingcore-8.2.dll: PE32+ executable (DLL) (console) x86-64, for MS Windows
- Check the output:
PE32
stands for 32bits DLLsPE32+
stands for 64bits DLLs
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.