Problem with installing Shark machine learning library - c++

I am Installing Shark machine learning library in my Laptop which its config is :
CPU: CoreI7 10th generation
GPU: Radeon RX640
OS: Windows 10
IDE: Visual studio 2019
according to shark website help, Boost library must be installed before any action .
I got the Boost library boost_1_74_0-msvc-14.2-64 from its boost website. Running the exe makes a folder C:\local\boost_1_74_0
some helps from Youtube says it is enough to install boost and use the addresses belong to this folder and some other helps says you must build it , so I did two ways separately for two kind of installing.
After that , I got the shark library from its official website
or
http://image.diku.dk/shark/sphinx_pages/build/html/rest_sources/downloads/downloads.html
I started to extract it and put it in a source folder and then I made a build folder near it.
I run the CMAKE and put the source address in the source text box and build address in the build text box.
then I made to entries to CMAKE : BOOST_ROOT:C:\local\boost_1_74_0 and BOOST_LIBRARYDIR:C:\local\boost_1_74_0\lib64-msvc-14.2
the I configured it , some messages were in the output page in the CMAKE:
CMake Warning at C:/Program
Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1179 (message):
New Boost version may have incorrect or missing dependencies and
imported targets Call Stack (most recent call first): C:/Program
Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1303
(_Boost_COMPONENT_DEPENDENCIES) C:/Program
Files/CMake/share/cmake-3.17/Modules/FindBoost.cmake:1904
(_Boost_MISSING_DEPENDENCIES) Test/CMakeLists.txt:11 (find package)
I kept going it because it was just warning and I had put the BOOST address in the CMAKE config
so I generate it via CMAKE and the run the visual studio solution in ADMIN and build the shark.sln but the after a lot of compiling time , the result was : 198 projects FAILED
Visual studio makes these errors after building the shark project:
Error LNK1181 cannot open input file '..\lib\Release\shark.lib'
Error C2668 'shark::size': ambiguous call to overloaded function
Error C3861 'make_iterator_range': identifier not found
these errors are repeated for 230 times in shark project building process
these errors makes me confused and I don't know what to do because when shark.lib is created that building process gets completed and in the middle of building , compiler is looking for what?
another item is shark::size error is not clear for me because all the relations between library files and header files in this project is clear but compiler cannot relate them together and makes error

Boost is a collection of libraries. Some must be built, others are header-only (just #include). Visual Studio is common enough that Boost provides a link to pre-built libraries. You downloaded the correct MSVC 14.2 build for VS2019.
Since Boost is a collection of libraries, sometimes library A needs library B. CMake knows about the dependencies in most Boost versions, but not the newest. So when a project tells CMake it needs Boost library A, CMake will automatically include B as well. If this is the problem with Shark, you'll need to manually add the missing Boost dependencies to CMakeLists.txt.

Related

Visual Studio's CMake with vcpkg: Error gdal is not found

I have been trying to build a cmake c++ project. More specifically I am trying to use the gdal library in this project. In the CMakeLists.txt it says find_library(GDAL gdal) after doing some research i found, that visual studio can open cmake files by default as mention in this thread: https://learn.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=vs-2019.
Moreover, visual studio should also automatically include the gdal library once i have set it up with vcpkg correctly. I've already downloaded the x64-windows version of the library (vcpkg install gdal:x64-windows) in order to build for the right architecture and made it available via vcpkg integrate install on a user-wide scope.
After some trial and error, everything works fine now, the toolchain gets included accordingly and the library is found automatically, resulting in a configuration like that:
However, when trying to include the header files (or anything else; see code snippet), visual studio does not seem to link the library correctly as it will result in the error message: cannot open source file "gdal/gdal.h".
#include <gdal/ogrsf_frmts.h>
#include <gdal/gdal.h>
#include <gdal>
Where should I further investigate?
As others have said vcpkg integrate install and vcpkg.cmake don't work together the reason being:
set_target_properties(${name} PROPERTIES VS_USER_PROPS do_not_import_user.props)
set_target_properties(${name} PROPERTIES VS_GLOBAL_VcpkgEnabled false)
this deactivates the integration. The reason to deactivate the integration is so that you don't write an incomplete CMakeLists.txt (e.g. missing the include directory or not linking all required libraries).
As such replace find_library(GDAL gdal) with find_package(GDAL REQUIRED) and target_link_libraries against the target GDAL::GDAL (https://cmake.org/cmake/help/v3.17/module/FindGDAL.html)

Cmake finds hdf5 but tries to link against dll on windows

I use find_package(HDF5 COMPONENTS CXX REQUIRED) in my CMAKE script to load the include directories and libraries of HDF5. Cmake tells me
Found HDF5: C:/Program Files/HDF_Group/HDF5/1.10.0/bin/hdf5_cpp.dll (found version "1.10.0") found components: CXX
And generates my visual studio solution.
I also use the library stored in ${HDF5_LIBRARIES} ${HDF5_CXX_LIBRARIES} for my target, but when I try to build it, I get a Linker Error LNK1107 saying that for file hdf5_cpp.dll:
invalid or corrupt file: cannot read at 0x380
which I think is due to the fact that visual studio is trying to directly link against the dll file instead of against the lib file which is in another folder, namely in:
C:\Program Files\HDF_Group\HDF5\1.10.0\lib
Question: Is this a bug in FindHDF or did I configure something wrong?
I have not used hdf5 on windows for some time, but I do recall there being a bug that causes it to link against the dll instead of the lib.
you should manually set (either via the command line cmake -D method, or via the cmake gui)
HDF5_hdf5_LIBRARY=C:\Program Files\HDF_Group\HDF5\1.10.0\lib\libhdf5.lib
HDF5_hdf5_cpp_LIBRARY=C:\Program Files\HDF_Group\HDF5\1.10.0\lib\libhdf5_cpp.lib
etc. - or just
HDF5_LIBRARY=C:\Program Files\HDF_Group\HDF5\1.10.0\lib\libhdf5.lib
HDF5_cpp_LIBRARY=C:\Program Files\HDF_Group\HDF5\1.10.0\lib\libhdf5_cpp.lib
depending on whether you have an older or newer version of FindHDF5 (they change the library var names in newer versions - check the ones used to make sure you get them right - I'm doing this from memory so might have made a mistake)
EDIT:
If the option of manaully specifying the libs is a problem, then there is the option of using FindPackage(HDF5 NO_MODULE) if your hdf5 library was compiled using cmake generated makefilesetc.
When using NO_MODULE, the find package scripts will bypass the findhdf5.cmake script and look for the HDF5Config.cmake or hdf5-config.cmake file that is placed in the relevant subdir of the hdf5 build/install folfer.
This is cross platform friendly and is supported by all newer hdf5 versions - provided they were built using cmake and not ./configure ...

CMake can not find opencl sdk by NVIDA

I just installed NVIDIA CUDA tool kit to use it for developing the OpenCL application on windows 8.1.
I came across some problems:
1- FinedOpenCl.cmake doesn't work since opencl_dir is not set by the Nvidia tool kit.
cmake file is:
FIND_PACKAGE(OpenCL REQUIRED)
INCLUDE_DIRECTORIES(${OPENCL_INCLUDE_DIR})
and cmake error is:
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
Could NOT find OpenCL (missing: OPENCL_LIBRARY OPENCL_INCLUDE_DIR)
Call Stack (most recent call first):
C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/FindPackageHandleStandardArgs.cmake:374 (_FPHSA_FAILURE_MESSAGE)
cmake/FindOpenCL.cmake:35 (find_package_handle_standard_args)
CMakeLists.txt:5 (FIND_PACKAGE)
2- There is no cl.hpp for c++ interface.
3- Headers and libraries are on different directories and hence it is difficult to use them with the application.
My questions:
1- Is there anything that I can do to solve them?
2- Is there any option during setup that does the required setting automatically.
Using definitions found here:
http://www.cmake.org/cmake/help/v3.1/module/FindOpenCL.html
Try the below (I did a quick test on Windows 10 Pro and Ubuntu 14.04LTS):
FIND_PACKAGE(OpenCL REQUIRED)
INCLUDE_DIRECTORIES(${OpenCL_INCLUDE_DIRS})
LINK_DIRECTORIES(${OpenCL_LIBRARY})
You may also want to check:
How to add header file path in CMake file
You can run cmake with additional -D options, like:
cmake [some_your_options] -DOpenCL_LIBRARY=/cygdrive/c/cuda/lib -DOpenCL_INCLUDE_DIR=/cygdrive/c/cuda/include [some_your_other_options] .....
So it will see OpenCL such manually specified paths.
Upper example provided for my CygWin64, where in the folder C:\cygdrive I added several symbolic links by mklink for all needed logical drives before, so "c" links to "C:\", "d" links to "D:\" and so on.
My NVidia CUDA install path is really C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\, but it is not very handy, so I also maked symlink (mklink /D linkname "path") on C: named "cuda", so /cygdrive/c/cuda/lib is really points to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\lib.
Unix environment emulation on windows and compiling in command promt is very tricky, yes..
There is no standard FindOpenCl.cmake, so I don't know what file you are using, but in my code I search in a bunch of different folders, including these:
$ENV{OPENCL_DIR}
$ENV{NVSDKCOMPUTE_ROOT} # NVIDIA on Windows
$ENV{CUDA_PATH_V6_5}
$ENV{CUDA_PATH}
In addition, I have seen some trouble depending on whether the paths has a final '\' or not - it seems like some kind of bug in CMake, where it fails to automatically handle both situations. So try adding a backslash to your environment variables.
That's a fact - NVIDIA simply doesn't include cl.hpp, but you can download it from Khronos: https://www.khronos.org/registry/cl/api/1.1/cl.hpp.
This should also be handled by the FindOpenCl.cmake - if not, you will have to write your own, or find one that sets up the include and lib variables properly.
Finally, there is no secret option to fix any of these during installation :)

Podofo build errors

I want to build solution for Visual Studio.
As i know, minumum for it is cmake, zlib, jpeg and freetype.
I build freetype(debug and relise).
Downloaded compiled zlib dll.
(For Visual Studio you will need to build libjpeg with your version of Visual Studio. Download the libjpeg sources from here and unpack them into a working directory. I'll assume you've used C:\Developer\jpeg. Once the sources are unpacked, start a visual studio command prompt and cd into c:\developer\jpeg then run copy jconfig.vc jconfig.h then nmake /f makefile.vc /a) Jpeg done, or i need something more to do with it?
Then i make cmd file:
del cmakecache.txt
set FTDIR=C:\dev\freetype-2.4.5
set FTLIBDIR=C:\dev\freetype-2.4.5\objs\win32\vc2010
set JPEGDIR=C:\dev\jpeg
set ZLIBDIR=C:\developer\zlib128-dll
cmake -G "Visual Studio 10" c:\dev\podofo-0.9.2\ -DCMAKE_INCLUDE_PATH="%FTDIR%\include;%JPEGDIR%\include;%JPEGDIR%;%ZLIBDIR%\include" -DCMAKE_LIBRARY_PATH="%FTLIBDIR%;%FTDIR%\lib;%JPEGDIR%;%JPEGDIR%;%ZLIBDIR%\lib" -DPODOFO_BUILD_SHARED:BOOL=FALSE -DFREETYPE_LIBRARY_NAMES_DEBUG=freetype245MT_D -DFREETYPE_LIBRARY_NAMES_RELEASE=freetype245MT -DCMAKE_BUILD_TYPE=DEBUG
Then i can see that:
-- Looking for strings.h
-- Looking for strings.h - not found
-- Looking for arpa/inet.h
-- Looking for arpa/inet.h - not found
-- Looking for winsock2.h
-- Looking for winsock2.h - found
-- Looking for mem.h
-- Looking for mem.h - not found
-- Looking for ctype.h
-- Looking for ctype.h - found
Maybe problem is this or maybe in jpeg lib.
Instead of using nmake directly, I'd recommend you use cmake-gui for building PoDoFo. Don't write your own build.cmd as this doesn't work in most cases. Note : The method described below uses your method, don't follow it. Use cmake-gui (If you don't know how exactly cmake or nmake works).
Well I will recommend you go to this site and find the references:
Building static podofo with MSVS 2012
Well I guess this should work for Visual Studio 2010. Remember :
Building the prerequisite libraries - This site has also links about how to go on building these libraries. However, I assume you have already built them. However I would recommend building them again according to this tutorial.
Instructions : Do as he says. Don't miss any options regarding preprocessor definitions, runtime libraries and all the parameters same. If you miss anything or do something wrong that will force you to restart from where you started.
Errors : I myself experienced many errors while following the same procedure and this site provides no explanation. Common errors include:
Unresolved externals (either with msvcrt.lib or libcmt.lib). In that case, just go to Linker>Input>Ignore specific libraries and name that library there to just ignore it.
There will be random errors sometimes. I would suggest looking up Stack Overflow itself or MSDN or Google, because after starting off with >2500 errors I was finally able to build a static library.
Last Resort: If everything fails, just contact me (if you are still interested!).

BOOST Version 1.46.1 with Visual Studio 2010 P.E

I'm trying to run some simple examples with Boost and I'm continuously running into this error and I have tried to compile this but I haven't been able to create "libboost_system-vc100-mt-gd-1_46_1.lib".
I keep ending up with this issue:
error LNK1104: cannot open file 'libboost_system-vc100-mt-gd-1_46_1.lib'
Anyone encounter this error before? How do you compile this properly with NMAKE because it keeps telling me it's bulding "boost.regex without ICU / Unicode Support" which is giving it a "fatal error U1073 and tells me it doesn't know how to make "../src/c_regex_traits.cpp".
Sorry if this is a jumble it's just a lot of information that's getting more and more confusing to me.
Your boost is not properly built or installed. Please follow the instruction on how to install boost.
You need to build the boost libraries first.
To do this, open command line & go to boost root eg C:\dev\boost\1_46_1.
Depending on whether you want to build for 64bit or 32bit applications, type
(x64):bjam toolset=msvc address-model=64 variant=debug,release link=static threading=multi runtime-link=static,shared stage
(x86): bjam toolset=msvc variant=debug,release link=static threading=multi runtime-link=static,shared stage
to start compiling. Be patience while boost is building, it takes a lot of time. When building is complete you can find the library files in "stage\lib" folder.
Also note that you can delete the folder "bin.v2" once building is complete.
Now you need to point your VS2010 project to those libraries. Modifying part of mlimber's answer:
In VS2010, right-click on your project, select Properties and then go to Configuration Properties -> Linker -> General. Look for "Additional Library Directories" in the middle of the list, and add C:\Program Files\Boost\boost_1_46_1\lib (or whatever) there.
Another way to do this is the following
In VS2010, right-click on your project, select Properties and then go to Configuration Properties -> VC++ Directories. Look for "Library Directories" in the middle of the list, and add C:\Program Files\Boost\boost_1_46_1\lib (or whatever) there.
Apart from the above, one could also download from
http://sourceforge.net/projects/boost/files/boost-binaries/1.46.1/
the necessary libraries (including the file missing).
While trying to build Pion network library, I ran into a very similar problem since Pion has dependency on Boost library.
My Boost build was built using boostrap and bjam, and not BoostPro.
The error I got was this: LINK : fatal error LNK1104: cannot open file 'boost_thread-vc100-mt-gd-1_46_1.lib'
When I looked at C:\OpenSource\boost_1_46_1\stage\lib directory, I saw every file name started with libboost_ and not boost_. The file boost_thread-vc100-mt-gd-1_46_1.lib was clearly missing. That made me suspicious that not all boost libraries were built by bjam. After a little research, I reran bjam with the option --build-type=complete
Now I noticed that it started creating lib file names starting with boost_. Not to mention, Pion library could now compile successfully.
Hope this adds some clarity to this thread.
Or alternatively to ybungalobill's suggestion use the installer from www.boostpro.com.
In the installer you must just select the boost versions for msvc 10 and after installation update your visual studio include and lib directories in the VS2010 property sheets to point to the boost include and lib directory.
I take it that you used the BoostPro installer, but which library types did you install -- header only, static linking, DLLs, everything?
Assuming you did everything, then the problem is probably that you don't have the path to boost in your library paths. The problematic file name starts with "libboost" which tells me you're trying to use the statically linked version, which is fine. You should add the library path to your Makefile or project settings for all build configurations. It's probably something like C:\Program Files\Boost\boost_1_46_1 (for the newest version on a 32-bit version of Windows).
In VS2010, right-click on your project, select "All Configurations" at the top, then go to Configuration Properties | Linker [or Librarian if you're making a library] | General. Look for "Additional Library Directories" in the middle of the list, and add C:\Program Files\Boost\boost_1_46_1\lib (or whatever) there.
Do that for each project in the solution that uses Boost libraries that are not header-only.
For a Makefile, you'll have to locate the library paths and add Boost to it similarly but by hand.