DIPlib / diplib

Quantitative Image Analysis in C++, MATLAB and Python
https://diplib.org
Apache License 2.0
219 stars 48 forks source link

Build DipLib using Cmake on Windows #16

Closed Dpksrndrn closed 5 years ago

Dpksrndrn commented 5 years ago

Hi,

I am trying to build the DipLib Library to install the PyDip Library. I get the following error while trying to build DipLib using Cmake version 3.13.2 with a Visual Studio 15 2017 Win64 Generator. Even though the compiler version is 19.16, I get the following error message "Your compiler does not support relaxed constexpr functions. You need a compiler with full C++14 support to build DIPlib."

Please find the entire Cmake log below. I would appreciate any help on this.

Thanks

Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.17134.
The C compiler identification is MSVC 19.16.27025.1
The CXX compiler identification is MSVC 19.16.27025.1
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Detecting C compile features
Detecting C compile features - done
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe
Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
PROJECT_VERSION = 3.0.alpha
CMake Error at CMakeLists.txt:42 (message):
  Your compiler does not support relaxed constexpr functions.  You need a
  compiler with full C++14 support to build DIPlib.

Found OpenMP_C: -openmp (found version "2.0") 
Found OpenMP_CXX: -openmp (found version "2.0") 
Found OpenMP: TRUE (found version "2.0")  
Performing Test HAS_PRETTY_FUNCTION
Performing Test HAS_PRETTY_FUNCTION - Failed
Performing Test HAS_128_INT
Performing Test HAS_128_INT - Failed
Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR) 
Looking for strtok_r
Looking for strtok_r - not found
Could NOT find TIFF (missing: TIFF_LIBRARY TIFF_INCLUDE_DIR) 
Could NOT find FFTW3 (missing: FFTW3_INCLUDE_DIR FFTW3_LIBRARY_FFTW3F FFTW3_LIBRARY_FFTW3) 
Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
Found OpenGL: opengl32   
Could NOT find FreeGLUT (missing: FREEGLUT_LIBRARY FREEGLUT_INCLUDE_DIR) 
FreeGLUT not found
Could NOT find GLFW (missing: GLFW_LIBRARY GLFW_INCLUDE_DIR) 
GLFW not found
Found PythonInterp: C:/Users/Deepak.Surendran/Anaconda3/pkgs/python-3.7.0-hea74fb7_0/python.exe (found version "3.7") 
Could NOT find Matlab (missing: Matlab_INCLUDE_DIRS Matlab_MEX_LIBRARY Matlab_MEX_EXTENSION Matlab_ROOT_DIR Matlab_MX_LIBRARY MAIN_PROGRAM) (found version "NOTFOUND")

--------------------------------------
   DIPlib CONFIGURATION REPORT

 * C++ compiler: MSVC
 * Building shared library
 * Library installed to: C:/Program Files (x86)/DIPlib/lib
 * Header files installed to: C:/Program Files (x86)/DIPlib/include
 * Doxygen documentation not configured
 * Using OpenMP for multithreading
 * Stack trace recording enabled
 * Asserts enabled
 * Unicode support enabled
 * Using 64-bit PRNG
 * ICS file IO enabled
 * TIFF file IO disabled
 * Using built-in FFT
 * Unit test code included
 * DIPviewer module not configured
 * DIPviewer Java bindings not configured
 * PyDIP module not configured
 * DIPimage toolbox not configured

--------------------------------------

Configuring incomplete, errors occurred!
See also "C:/Users/Deepak.Surendran/Downloads/DIPlib/SourceClone11/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Deepak.Surendran/Downloads/DIPlib/SourceClone11/CMakeFiles/CMakeError.log".
crisluengo commented 5 years ago

Thanks for the report!

I heard the same thing earlier this week, it seems like CMake is wrong about MSVC's capabilities. It bases those off of a list, rather than testing the compiler for specific features. Last night I made this commit to address the issue, but it's not yet merged into master because I don't have MSCV available myself to test it.

You can safely delete the line in the CMakeLists.txt file that generates the error (line number 42), and you'll be able to compile the library.

If you are familiar with git and willing to help, you could cherry-pick this commit (aabe6029635a3a90208622afd047ac71445b2e13) and try it out.

We would very much appreciate to hear of any other issues you come across!

Dpksrndrn commented 5 years ago

Thanks @crisluengo. That seemed to fix that error, but on subsequent running I am now getting : "CMake Error at dependencies/pybind11/CMakeLists.txt:74 (add_subdirectory): add_subdirectory given source "tests" which is not an existing directory." as an error message. All I am trying to do is to install pydip, would I still need to install diplib or is there a better way to go about this ?

I am relatively new to git so I am not sure if I can be of much help.

Thanks

crisluengo commented 5 years ago

@Dpksrndrn: That is strange. In your CMake configuration, PYBIND11_TEST should be off. Can you see this setting in the CMake program?

Dpksrndrn commented 5 years ago

@erikschuitema : I am not sure what you mean by CMake configuration. When I click on the configure button in the GUI, the program starts to configure, I am not able to change anything in that process. I don't see any other settings in the program

crisluengo commented 5 years ago

@Dpksrndrn: You should see something similar to this: https://www.paraview.org/Wiki/File:Brpv_cmakesetup.png (this is for a different project, it's just an example image I found online). In that list of "Cache Values", do you see PYBIND11_TEST?

crisluengo commented 5 years ago

@Dpksrndrn: I have just pushed a fix for the "Your compiler does not support relaxed constexpr functions" error, and one that should fix this new error too. Please pull the changes and try building again.

Thanks for helping us out!

Dpksrndrn commented 5 years ago

Thank you so much for the fix @crisluengo. I was able to run the install for PyDIP and got the following message on Visual Studio: "1>------ Build started: Project: INSTALL, Configuration: Debug x64 ------ 1>-- Install configuration: "Debug" 1>-- Installing: C:/Users/Deepak.Surendran/Anaconda3/pkgs/python-3.7.0-hea74fb7_0/Lib/site-packages/PyDIP/PyDIP_bin.cp37-win_amd64.pyd 1>-- Installing: C:/Users/Deepak.Surendran/Anaconda3/pkgs/python-3.7.0-hea74fb7_0/Lib/site-packages/PyDIP/PyDIP_py.py 1>-- Installing: C:/Users/Deepak.Surendran/Anaconda3/pkgs/python-3.7.0-hea74fb7_0/Lib/site-packages/PyDIP/init.py ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped =========="

When I try to import the library on Python however, I get a module not found error. Do you think there was an issue in my installation procedure or something else may be wrong?

Ps. I am able to locate the 'init', 'PyDIP_bin.cp37-win_amd64', 'PyDIP_py' files under Python3.7>Lib>site-packages>PyDIP

crisluengo commented 5 years ago

@Dpksrndrn, please try typing this in Python:

import os
os.environ["PATH"] += os.pathsep + "C:/Program Files (x86)/DIPlib/lib"
import PyDIP as dip

Let me know if this works, I'll add a note to the README file.

(Reference: Stack Overflow -- Platform independent way to modify PATH environment variable)

Dpksrndrn commented 5 years ago

I installed the 64Bit version of the library, so I removed the (x86) from your code, but I still cannot seem to get it to work. Are you sure it has nothing to do with PyDIP getting installed in "Debug" configuration? Also, I do not need to use pip at all right ?

Thanks

crisluengo commented 5 years ago

@Dpksrndrn, in your first post is said:

Library installed to: C:/Program Files (x86)/DIPlib/lib

If that is where the library is, than that is the directory you need to add to your PATH. Your file PyDIP_bin.cp37-win_amd64.pyd is a DLL that depends on DIP.dll in that directory. If you installed to a different directory, then fill in the name of that instead.

Yes, don't use pip. This might have something to do with Anaconda, let me see how they handle packages. The instructions I wrote for Windows I tried out with a plain installation of Python 3. This seems to be the main difference of your environment with the one I used.

Dpksrndrn commented 5 years ago

I am sorry for the confusion. I think I was trying to use a different generator to see if that was the source of error. Thank you so much for helping out

Dpksrndrn commented 5 years ago

I don't know if it makes a difference, but I have a DIP.lib , not DIP.dll in the specified directory.

crisluengo commented 5 years ago

Does the CMake configuration report state "Building shared library"? Or does it say "Building static library"? In the former case, there must be a DIP.dll file somewhere. In the latter case, your PyDIP_bin.cp37-win_amd64.pyd file would be self-contained, and not depend on any non-system DLLs.

You can always use the Dependency Walker: open your PyDIP_bin.cp37-win_amd64.pyd file in it, it will tell you what other shared libraries it depends on, and whether the system can find them. This should tell you whether the DIP.dll file is required or not.

Anaconda uses "environments", make sure the right one is activated. I'm not sure how to check this. But within Python, you can type:

import sys
sys.path

This would tell you what directories are on your Python module search path. Make sure that C:/Users/Deepak.Surendran/Anaconda3/pkgs/python-3.7.0-hea74fb7_0/Lib/site-packages/, where PyDIP is installed, is on that path.

Dpksrndrn commented 5 years ago

The CMake Configuration report says "Building Shared Library". When I use the Dependency Walked, I get the following error messages:

Error: At least one required implicit or forwarded dependency was not found. Warning: At least one delay-load dependency module was not found. Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

Yes, I can see the specified path on using those commands

ronligt commented 5 years ago

Could you show us the output of all of the following commands?

First start the Anaconda Prompt and enter:

$ where python
$ python

Then inside python:

>>> import os
>>> os.environ['PATH']
>>> import sys
>>> sys.path

If the PATH variable shows the location with DIP.dll and the sys.path shows the location of the PyDIP package you should be able to import the package:

>>> import PyDIP as dip

You can add the location of DIP.dll directly in the Windows Environment Variables or as described by Cris above inside python. The package location can be added with sys.path.append(<PyDIP-location>)

Dpksrndrn commented 5 years ago

Hi @ronligt and @crisluengo , Thank you so much for your patience and assistance. It seems the issue was the package location was not added. I am able to import the library now.

Dpksrndrn commented 5 years ago

Hi @ronligt, @crisluengo , I was trying to reinstall the module with some of the dependencies installed, but am not able to import the module despite having the files in the correct locations. Here are the screenshots requested before: image

image

image

image

crisluengo commented 5 years ago

Are the new dependencies also in the directories listed by os.environ['PATH']?

For example, if you installed FFTW and DIPlib links to it, then the FFTW DLL needs to be found when importing PyDIP. The FFTW DLL thus must be in a directory listed on the PATH.

The DIPlib/PyDIP installation script does not install any of the dependencies, it assumes they are already properly installed. But under Windows there is an odd definition of "properly installed". I must confess I haven't used Windows very much over the last 15 years or so...

Dpksrndrn commented 5 years ago

@crisluengo, Thanks, I added the DLL's of the dependencies and that seems to have fixed the problem