Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation problem #18

Open
inzhevatkin opened this issue Oct 1, 2019 · 20 comments
Open

Compilation problem #18

inzhevatkin opened this issue Oct 1, 2019 · 20 comments

Comments

@inzhevatkin
Copy link

Hello.
I want to compile code for using in python project in Windows 10. I work in msys command shell.

  1. I downloaded scattnlay project.
  2. Run python -m pip install numpy command. Output is 'Successfully installed numpy-1.17.2'.
  3. Run make ext command.
    Output:
    '/c/Users/konstantin/AppData/Local/Programs/Python/Python37-32/python.exe' setup.py build_ext --inplace
    Traceback (most recent call last):
    File "setup.py", line 44, in
    import pybind11 as pb
    ModuleNotFoundError: No module named 'pybind11'
    make: *** [ext] Error 1
  4. Run pip install pybind11 command. Output is 'Successfully installed pybind11-2.4.2'.
  5. Run make ext command.
    Output:
    '/c/Users/konstantin/AppData/Local/Programs/Python/Python37-32/python.exe' setup.py build_ext --inplace
    running build_ext
    building 'scattnlay_dp' extension
    error: Unable to find vcvarsall.bat
    make: *** [ext] Error 1

Could you help me. Maybe I made mistakes in the earlier steps. And I have no idea about installing python-all-dev and python-numpy-dev. Is it enough to call a command python -m pip install numpy?

I also tried to install packege python-scattnlay (v. 2.2) in Pycharm project. But error occured (error: Microsoft Visual C++ 14.0 is required). Is it possible to avoid installation Microsoft Visual C++ 14.0 if I have gcc compiler.

Thank you in advance.

@kostyfisik
Copy link
Collaborator

I have no Windows box to check, may be @ovidiopr can comment on this.

@ovidiopr
Copy link
Owner

ovidiopr commented Oct 1, 2019 via email

@kostyfisik
Copy link
Collaborator

Or you can check online Mie calculator based on Scattnlay (I have exposed only small part of API, however, it can be handy for simple computations) https://physics.ifmo.ru/mie/

@kostyfisik
Copy link
Collaborator

Or you can also try MinGW http://www.mingw.org/ I have no experience with it, but I know that it is a popular alternative to Visual C++. You may also check https://kezunlin.me/post/8b9c051d/ (it is about building with pybind11 on windows, and we use pybind11 to interface C++ and Python code).

@inzhevatkin
Copy link
Author

Thanks for the quick response.
Thanks for the valuable advices.

I did not write right away, but I am using MinGw and plan to compile it using the gcc or g++ built-in compiler.

I want to find electrical field in space with Scattnlay project and I understood that API https://physics.ifmo.ru/mie/ has not this such an opportunity or functionality. But this advice is very valuable for future tasks.

I understand that the Makefie in the project is not intended for assembly in Windows. Is it so?

I will try to read in more detail the links that you advised.

@kostyfisik
Copy link
Collaborator

kostyfisik commented Oct 2, 2019 via email

@inzhevatkin
Copy link
Author

Hello.

I have not yet succeeded with the make ext command.
My latest achievement is the following:

  1. Run make ext command.
    Output:
    '/c/Users/konstantin/AppData/Local/Programs/Python/Python37-32/python.exe' setup.py build_ext --inplace
    running build_ext
    Traceback (most recent call last):
    File "setup.py", line 81, in
    extra_compile_args=['-std=c++11', '-DMULTI_PRECISION=100'])]
    File "c:\Users\konstantin\AppData\Local\Programs\Python\Python37-32\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
    File "c:\Users\konstantin\AppData\Local\Programs\Python\Python37-32\lib\distutils\dist.py", line 966, in run_commands
    self.run_command(cmd)
    File "c:\Users\konstantin\AppData\Local\Programs\Python\Python37-32\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
    File "c:\Users\konstantin\AppData\Local\Programs\Python\Python37-32\lib\distutils\command\build_ext.py", line 309, in run
    force=self.force)
    File "c:\Users\konstantin\AppData\Local\Programs\Python\Python37-32\lib\distutils\ccompiler.py", line 1031, in new_compiler
    return klass(None, dry_run, force)
    File "c:\Users\konstantin\AppData\Local\Programs\Python\Python37-32\lib\distutils\cygwinccompiler.py", line 282, in init
    CygwinCCompiler.init (self, verbose, dry_run, force)
    File "c:\Users\konstantin\AppData\Local\Programs\Python\Python37-32\lib\distutils\cygwinccompiler.py", line 157, in init
    self.dll_libraries = get_msvcr()
    File "c:\Users\konstantin\AppData\Local\Programs\Python\Python37-32\lib\distutils\cygwinccompiler.py", line 86, in get_msvcr
    raise ValueError("Unknown MS Compiler version %s " % msc_ver)
    ValueError: Unknown MS Compiler version 1916
    make: *** [ext] Error 1

I can't tell python distutils to use mingw.

I also wanted to inform you that I use code from master branch and I tried to compile project on my laptop with make standalone command and I found some problems:

  1. Makefile has line PYTHON='which python3'. In my case I have to use exact path to python.exe.
  2. I run make standalone command.
    Output:
    make: *** No rule to make target /c/Users/konstantin/YandexDisk/Mie/scattnlay-master/scattnlay-master-original/src/nmie-impl.hpp', needed by scattnlay'. Stop.
    There is no file (nmie-impl.hpp) in the project.
  3. I deleted $(SRCDIR)/nmie-impl.hpp in Makefile and compiled with make standalone command.
    Output:
    g++ -DNDEBUG -O2 -Wall -std=c++11 /c/Users/konstantin/YandexDisk/Mie/scattnlay-master/scattnlay-master-original/src/nearfield.cc /c/Users/konstantin/YandexDisk/Mie/scattnlay-master/scattnlay-master-original/src/nmie.cc -lm -o fieldnlay
    In file included from c:/Users/konstantin/YandexDisk/Mie/scattnlay-master/scattnlay-master-original/src/nearfield.cc:43:
    c:/Users/konstantin/YandexDisk/Mie/scattnlay-master/scattnlay-master-original/src/nmie.hpp:40:10: fatal error: boost/math/constants/constants.hpp: No such file or directory
    #include <boost/math/constants/constants.hpp>
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    In file included from c:/Users/konstantin/YandexDisk/Mie/scattnlay-master/scattnlay-master-original/src/nmie.cc:48:
    c:/Users/konstantin/YandexDisk/Mie/scattnlay-master/scattnlay-master-original/src/nmie.hpp:40:10: fatal error: boost/math/constants/constants.hpp: No such file or directory
    #include <boost/math/constants/constants.hpp>
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    make: *** [fieldnlay] Error 1_
  4. I deleted scattnlay-mp fieldnlay-mp in Makefile and #include <boost/math/constants/constants.hpp> in nmie.hpp. At the moment I will deal with the project without a library if possible.
    No errors occurred.
    Output:
    g++ -DNDEBUG -O2 -Wall -std=c++11 /c/Users/konstantin/YandexDisk/Mie/scattnlay-master/scattnlay-master-original/src/farfield.cc /c/Users/konstantin/YandexDisk/Mie/scattnlay-master/scattnlay-master-original/src/nmie.cc -lm -o scattnlay
    g++ -DNDEBUG -O2 -Wall -std=c++11 /c/Users/konstantin/YandexDisk/Mie/scattnlay-master/scattnlay-master-original/src/nearfield.cc /c/Users/konstantin/YandexDisk/Mie/scattnlay-master/scattnlay-master-original/src/nmie.cc -lm -o fieldnlay

    In project folder I have fieldnlay.exe and scattnlay.exe.

Can I use this file to calculate the electrical field? In the examples I saw only scattnlay functions from python library.
I apologize for the long comment.

@kostyfisik
Copy link
Collaborator

kostyfisik commented Oct 4, 2019 via email

@inzhevatkin
Copy link
Author

Yes, I have the same output:
Invalid argument: Insufficient parameters.
Usage: fieldnlay.exe -l Layers x1 m1.r m1.i [x2 m2.r m2.i ...] -p xi xf nx yi yf ny zi zf nz [-c comment].

For test I tried to run command fieldnlay.exe -l Layers 10 1.01 0 -p -5 5 1 -5 5 1 -5 5 1.
Error occurred in line L = std::stoi(arg); in nearfield.cc, arg was "Layers" and it threw an exception. I deleted this line and manually defined L = 1. It outputs field values to consol. Perfect! Thank you!

Logically, the variable L should store the number of layers, but I did not understand how this is implemented programmatically. Maybe I didn’t understand something. In my case, I need a homogeneous sphere without layers.

I just still did not catch how to do it:

I would propose to try to install python package (python-scattnlay), as
soon as it is much more convenient to calculate near-field using python
interface. At least calling scattnlay from python is a default way I use
it.

@ovidiopr
Copy link
Owner

ovidiopr commented Oct 4, 2019 via email

@ovidiopr
Copy link
Owner

ovidiopr commented Oct 4, 2019 via email

@ovidiopr
Copy link
Owner

ovidiopr commented Oct 4, 2019 via email

@ovidiopr
Copy link
Owner

ovidiopr commented Oct 4, 2019 via email

@inzhevatkin
Copy link
Author

Thank you very much I will try to do what you advised.

@ovidiopr
Copy link
Owner

ovidiopr commented Oct 4, 2019 via email

@inzhevatkin
Copy link
Author

I tried this:

fieldnlay.exe -l 10 1.01 0 -p -5 5 1 -5 5 1 -5 5 1

It doesn't work in my case. It returns:
Invalid argument: Unfinished layer!
Insufficient parameters.

@ovidiopr
Copy link
Owner

ovidiopr commented Oct 4, 2019 via email

@inzhevatkin
Copy link
Author

I suspect that some parameters were missing. An example of the command line when everything is OK in the calculation fields:
fieldnlay.exe -l 1 10 1.01 0 -p -5 5 1 -5 5 1 -5 5 1

@ovidiopr
Copy link
Owner

ovidiopr commented Oct 7, 2019 via email

@kostyfisik
Copy link
Collaborator

@ovidiopr May be we need provide a copy of needed boost files, as soon as we really need just a tiny part of boostlib...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants