Visual Studio 2019, Win10, and HDF5 installed using vcpkg. Unresolved external symbol H5T_IEEE_F64BE_g - visual-studio-2019

Any help is much appreciated. I'm having link errors when trying to use HDF5 libraries installed using vcpkg with Visual Studio 2019 on Windows 10.
I installed HDF5 1.12.0 on Windows 10 using vcpkg:
PowerShell: .\vcpkg install hdf5 hdf5:x64-windows
I then attempted to use Visual Studio 2019 to build my project that uses HDF5, but I keep getting the following LNK2001 errors.
unresolved external symbol H5T_IEEE_F64BE_g
unresolved external symbol H5T_STD_I64BE_g
unresolved external symbol H5T_C_S1_g
unresolved external symbol H5T_NATIVE_INT_g
unresolved external symbol H5T_NATIVE_DOUBLE_g
I tried to solve this by directly adding the additional library directories that are under the vcpkg/packages/ for HDF5, SZIP, and ZLIB, that were automatically installed as part of the HDF5 installation step given previously, and I also added the library files to the additional dependencies in the order prescribed by the HDF5 documentation:
hdf5_hl.lib
hdf5.lib
szip.lib
zlib.lib
But I still have the unresolved external symbol errors.

All those symbols are prefixed with H5_DLLVAR. As such you need to explicitly set the preprocessor definitionH5_BUILT_AS_DYNAMIC_LIBif you are not using CMake and only the MSBuild integration vcpkg provides. You could also open and issue with vcpkg since it should embedded that definition into the correct hdf5 header if the library is built dynamically.

The vcpkg command that I used installs the dynamic version of the libraries. Instead I installed the static version of the libraries using:
./vcpkg install hdf5:x64-windows-static
No manual inclusion of the library directories or libraries themselves is needed. Just be sure to run this command as well (when first installing vcpkg):
./vcpkg.exe integrate install
Once that was done, Visual Studio 2019 was able to properly use the HDF5 libraries for my project and the linker error was gone (binary produced).
Hope this helps someone in the future!

Related

How to solve LNK2019 unresolved external __imp____iob_func

Attempt to link with Visual Studio 2019 an old Visual Studio 2008 x86 project using Gsl library v1.13, I got this error on link step:
LNK2019 symbole externe non résolu __imp____iob_func référencé dans la fonction _gsl_error
Options are same from Visual Studio 2008 project and already tried these points in this link :
unresolved external symbol __imp__fprintf and __imp____iob_func, SDL2
If someone has idea and can help?
Thank you
__iob and __printf are symbols contained in the stdio library.
It seems to me that the standard libc library is not statically linked to your new executable.
Try to this:
Configure the new project to statically link the libc library
The constitution of the project is:
Main Executable (AA)
refers to intermediate static lib (BB)
refers to gsl v1.13 static lib build ten years ago it seems (CC)
https://ftp.igh.cnrs.fr/pub/gnu/gsl/
I may be looking for the option to statically link the main executable (AA) with the standard libc library under Visual Studio 2019 but can't find accurate information out of this https://learn.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=msvc-160.
Just so as not to mislead my protagonist to link statically, can you confirm to me that it is necessary to link with the standard library (AA) , (BB) or (CC) ?

Is it possible to use TensorFlow C++ API on Windows?

I'm interested in incorporating TensorFlow into a C++ server application built in Visual Studio on Windows 10 and I need to know if that's possible.
Google recently announced Windows support for TensorFlow: https://developers.googleblog.com/2016/11/tensorflow-0-12-adds-support-for-windows.html
but from what I can tell this is just a pip install for the more commonly used Python package, and to use the C++ API you need to build the repo from source yourself: How to build and use Google TensorFlow C++ api
I tried building the project myself using bazel, but ran into issues trying to configure the build.
Is there a way to get TensorFlow C++ to work in native Windows (not using Docker or the new Windows 10 Linux subsystem, as I've seen others post about)?
Thanks,
Ian
It is certainly possible to use TensorFlow's C++ API on Windows, but it is not currently very easy. Right now, the easiest way to build against the C++ API on Windows would be to build with CMake, and adapt the CMake rules for the tf_tutorials_example_trainer project (see the source code here). Building with CMake will give you a Visual Studio project in which you can implement your C++ TensorFlow program.
Note that the tf_tutorials_example_trainer project builds a Console Application that statically links all of the TensorFlow runtime into your program. At present we have not written the necessary rules to create a reusable TensorFlow DLL, although this would be technially possible: for example, the Python extension is a DLL that includes the runtime, but does not export the necessary symbols to use TensorFlow's C or C++ APIs directly.
There is a detailed guide by Joe Antognini and a similar TensorFlow ReadMe at GitHub explaining the building of TensorFlow source via CMake. You also need to have SWIG installed on your machine which allows connecting C/C++ source with the Python scripting language. I did use Visual CMAKE (cmake-gui) with the screen capture shown below.
In the CMake configuration, I used Visual Studio 15 2017 compiler. Once this stage successfully completes, you can click on the Generate button to go ahead with the actual build process.
However, on Visual Studio 2015, when I attempted building via the "ALL_BUILD" project, the setup gave me "build tools for v141 cannot be found" error. This did not go away even when I attempted to retarget my solution. Finally, the solution got built successfully with Visual Studio 2017. You also need to manually set the SWIG_EXECUTABLE path in CMake before it successfully configures.
As indicated in the Antognini link, for me the build took about half an hour on a 16GB RAM, Core i7 machine. Once done, you might want to validate your build by attempting to run the tf_tutorials_example_trainer.exe file.
Hope this helps!
For our latest work on building TensorFlow C++ API on Windows, please look at this github page. This works on Windows 10, currently without CUDA support (only CPU).
PS:
Only the bazel build method works, because CMake is not supported and not maintained anymore, resulting in CMake configuration errors.
I had to use a downgraded version of my Visual Studio 2017 (from 15.7.5 to 15.4) by adding "VC++ 2017 version 15.4 v14.11 toolset" through the installer (Individual Components tab).
The cmake command which worked for me was:
cmake .. -A x64 -DCMAKE_BUILD_TYPE=Release ^
-T "v141,version=14.11" ^
-DSWIG_EXECUTABLE="C:/Program Files/swigwin-3.0.12/swig.exe" ^
-DPYTHON_EXECUTABLE="C:/Program Files/Python/python.exe" ^
-DPYTHON_LIBRARIES="C:/Program Files/Python/libs/python27.lib" ^
-Dtensorflow_ENABLE_GPU=ON ^
-DCUDNN_HOME="C:/Program Files/cudnn-9.2-windows10-x64-v7.1/cuda" ^
-DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v9.0"
After the build, open tensorflow.sln in Visual Studio and build ALL_BUILD.
If you want to enable GPU computation, do check your Graphics Card here (Compute Capability > 3.5). Do remember to install all the packages (Cuda Toolkit 9.0, cuDNN, Python 3.7, SWIG, Git, CMake...) and add the paths to the environment variable in the beginning.
I made a README detailing how to I built the Tensorflow dll and .lib file for the C++ API on Windows with GPU support building from source with Bazel. Tensorflow version 1.14
The tutorial is step by step and starts at the very beginning, so you may have to scroll down past steps you have already done, like checking your hardware, installing Bazel etc.
Here is the url: https://github.com/sitting-duck/stuff/tree/master/ai/tensorflow/build_tensorflow_1.14_source_for_Windows
Probably you will want to scroll all the way down to this part:
https://github.com/sitting-duck/stuff/tree/master/ai/tensorflow/build_tensorflow_1.14_source_for_Windows#step-7-build-the-dll
It shows how to pass command to create .lib and .dll.
Then to test your .lib you should link it into your c++ project,
Then it will show you how to identify and fix the missing symbols using the TF_EXPORT macro
I am actively working on making this tutorial better so feel free to leave comments on this answer if you are having problems.

Why doesn't CLion link my project with OpenCV for Windows?

I'm attempting to use OpenCV for Windows as supplied by opencv.org in a project I'm building with JetBrains' CLion IDE. I've installed the opencv library and configured CLion (set(OpenCV_DIR) to reference the build directory under it, but CMake issues the warning:
Found OpenCV Windows Pack but it has no binaries compatible with your configuration.
You should manually point CMake variable OpenCV_DIR to your build of OpenCV library.
I've tried some of the older distributions from opencv.org with the same results. It appears CMake is locating the OpenCV libraries, but doesn't want to use them. Why, and how do I get the OpenCV libraries to work under CLion?
The short answer is, you will probably need to build OpenCV from source in order to use it with CLion. But given the number and range of partially answered and unanswered questions here* and elsewhere on using JetBrains' CLion IDE with the OpenCV library, I think an overview is needed (my notes are from CLion 2016.3 and OpenCV 3.1, YMMV):
Though not produced by JetBrains, CMake is very central to CLion's operation. Understanding CMake therefore helps greatly in diagnosing CLion build problems. In particular CMake maintains a disk "cache" of settings which you may need to clear to incorporate changes to your environment (Tools->CMake->Reset Cache and Reload Project).
To make use of OpenCV in your build you must specify it in your project's CMakeLists.txt file. You request that CMake locate your OpenCV location and link it to your TARGET. An example of a sequence of commands from CMakeLists.txt for an executable named mushroom follows:
add_executable(mushroom ${SOURCE_FILES})
FIND_PACKAGE(OpenCV REQUIRED)
TARGET_LINK_LIBRARIES(mushroom ${OpenCV_LIBS})
(For more on FIND_PACKAGE, see CMake:How To Find Libraries.)
FIND_PACKAGE for package XXX works either by way of FindXXX.cmake files located at CMake's Modules directory, or by consulting environment variable XXXX_DIR. On my system, no FindOpenCV.cmake file was present, so I relied on the OpenCV_DIR environment variable instead. This must be set, not to the root of your OpenCV installation, but to the build folder beneath it. I used an entry in CMakeLists.txt to set this variable, e.g.:
set(OpenCV_DIR C:/Users/myacct/AppData/Local/opencv-3.0.0/build)
To link with OpenCV, CMake uses either FindOpenCV.cmake or OpenCV_DIR (see previous point above) to locate a file named OpenCVConfig.cmake. This file is generated by and ships with a particular build of OpenCV in order to document what components are present and where they are located.
Problems may occur when variable names used by OpenCVConfig.cmake conflict with those CLion has stored in its environment. In particular, if your OpenCV was built by Microsoft Visual C (MSVC), as is the Windows distribution from opencv.org, it won't work with CLion.
Because CLion's build toolchain (ControlAltS-toolchain) uses either MinGW or Cygwin, OpenCVConfig.cmake will search for OpenCV binaries under a subdirectory named mingw or cygwin and will find none because the binaries were built with MSVC (it will look in a directory like vc11 or vc12 instead). This probably means you will need to build OpenCV from source in order to use it with CLion.
Would reconfiguring OpenCVConfig.cmake to point to the MSVC binaries make this work? you may ask. Unfortunately the answer is still no, because libraries built with one compiler typically cannot be linked with another one.
OpenCVConfig.cmake or FindOpenCV.cmake likely contain diagnostic messages, but when CLion executes CMake for you, message(STATUS) calls are not displayed. To make them display, change them to message(WARNING) or message(FATAL_ERROR). But CLion 2016.3 EAP relieves this problem; see https://stackoverflow.com/a/39398373/5025060.
CLion does not indicate which .cmake script issued which diagnostics; don't assume they all come from the same script.
Hopefully this provides some general guidance on resolving CLion / CMake / OpenCV compatibility problems. Note that this does not cover compiler or linker issues; these will not appear until CMake completes its initial makefile build. Compiler or linker issues occur at a later stage and are controlled by include*(), link*() and other commands in CMakeLists.txt.
*Some related SO questions:
OpenCV Windows setup with CLion
OpenCV CLion (Cmake) linking issue - cmake reports a strange error
use OpenCV with Clion IDE on Windows
Compiling OpenCV on Windows with MinGW
Could not find module FindOpenCV.cmake ( Error in configuration process)
CMake: Of what use is find_package() if you need to specify CMAKE_MODULE_PATH anyway?

Cannot resolve symbol in libprotobuf in openwrt

I have cross compiled a client server program to be run on openwrt plattform
I have used protoc version 2.6.1 to generate the .pb.h and .pb.cc files.
I have installed he protobuf package for cross compilation using the this
I have linked the compiled protobuf libraries to the source while compiling.
But when I try to run the executable on the openwrt VM (chaos calmer) it gives me the following error.
symbol '_ZN6google8protobuf8internal13empty_string_B5cxx11E': can't
resolve the symbol in lib './opwenwrt-client'
error image
I can guess the that there is mismatch between linking library.
But I dont understand that everywhere I am using protobuf version 2.1.6.
Any kind of help would be appreciated.
This looks like it's probably caused by using a different compiler / C++ ABI to compile your application vs. libprotobuf.so. See this previous question for more:
Undefined reference to google::protobuf::internal::empty_string_[abi:cxx11]

How to install OpenCV 3.1 with nonfree module?

I'm trying to write a program that uses SURF algorithm and I know that the nonfree module must be installed separately. I've downloaded and installed the latest version of CMake(3.5.2) and I'm following the instructions from:
https://github.com/itseez/opencv_contrib/ . I'm using the GUI and I run Visual Studio 2015 on a 64 bit Windows 10.
Since I know that for SURF you must include xfeatures2d when it asked me the source of the code I only specified the xfeatures2d folder. When I first pressed the configure button I had some errors(I've attached an image of them). I managed to get rid of one of the errors, the one that said to write a line of code at the top of the file
cmake_minimum_required(VERSION 3.5), but I still have one error:
CMake Error at CMakeLists.txt:4 (ocv_define_module):
Unknown CMake command "ocv_define_module".
I'm also attaching a picture of the CMakeLists.txt. Please help me find the problem.
Also, if you could help my install all modules at once, I would be grateful. Or do I have to set as input every folder in the modules folder?
GUI error and CMakeLists.txt
Try using Visual Studio 12 2013 for compilation, this has worked for me, but not the other (newer) versions of Visual Studio.

Resources