Compiling, Linking, and Executing
These questions are related to the build and runtime issues on macOS.
Problems executing your application under macOS
macOS dynamic libraries (.dylib) embed the full path to their installed location. This is different from dynamic libraries on Unix (.so and .dll), where the path is set at link time by the executable application.
The macOS dynamic library supplied with Wiretap uses a preset hard-coded path that might not match your desired install location. By default, the Wiretap dynamic library (libwiretapClientAPI.dylib
) sets its install path to /Library/Frameworks
, which is the standard install location for 3rd-party (non-OS) libraries available to all users.
To work around this issue, you can use the environment variable (DYLD_LIBRARY_PATH
), provided by macOS, to have the executable application override the embedded path. Alternatively, you can use the command-line tool install_name_tool
to reset the install path of the dynamic library and replace the contents (in place) within the library. The Wiretap dynamic library is built with 1024 bytes of reserved install path.
To change the library install path:
From the command line, run
install_name_tool
:install_name_tool -id <new_path> <current_install_location>
where,
current_install_location
is where you installed the library, andnew_path
is the desired new path for the library. For example, suppose you installed the library to/tmp
. To change the path to/usr/lib
, run theinstall_name_tool
as follows:install_name_tool -id /usr/lib/libwiretapClientAPI.dylib /tmp/libwiretapClientAPI.dylib
From a command-line, run
otool
to verify the path change:otool -L libwiretapClientAPI.dylib
For example, if you set the new path to
/usr/lib/libwiretapClientAPI.dylib
,otool
returns something similar to the following:libwiretapClientAPI.dylib: /usr/lib/libwiretapClientAPI.dylib (compatibility version 0.0.0, current version 0.0.0) /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0) /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.1.2)
Compile your executable with the changed library.