So your goal is to OpenCV function in UE4, then you need to add OpenCV in to build settings in build scripts, so compiler will know how to link to library. Keep in mind UE4 does not use XCode or VS build systems, or either CMake (but use them indirecly thats why they still needed to be installed), but it has it’s own build system called UnrealBuildTool, because of that build settings in IDEs are mostly ignored and settings in build scripts are more valid.
Lucky for you someone made a nice wiki page showing how to use OpenCV in UE4, including setting up build scripts as well as make basic blueprint integration:
Steps are very similar to any other library you want to use, but before you decide to use any external library makes sure that UE4 does not already have support for it’s function (for example you don’t need to link Steam library, there SteamOnlineSubsystem UE4 module for that) , using build-in functions is the safest and fastest route.