Migration of Perl Code to Windows: Missing Udunits Package?

半腔热情 提交于 2019-12-12 04:56:16

问题


We have some very old Perl scripts doing some database work; the scripts run in a Linux environment, which is going obsolete. One Perl script with .pl loads a package (with .pm extension); the .pm file has code like:

use UDUNITS;

My development environment is a Windows machine with ActivePerl 5.2 installed. I think I am able to load other Packages fine except I can't find the UDUNITS package in a Windows binary.

There IS a way to compile UDUNITS2 package, per http://fossies.org/linux/udunits/udunits2.html#Windows but I am unable to compile using CMake--getting errors. My first time with CMake.

So what are my options? I don't want to develop on Linux because I don't have the expertise; and also I think going past the UDUNITS problem may be all I need in Windows.

Thanks!

Update I used command line way now: cmake CC="C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\cl.exe" CXX="C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\cl.exe" -DEXPAT_LIBRARY=c:\expat32\Bin\libexpat.dll .. and I can see that 'configuring done' and 'generating done' but also a message like CUNIT not found. Build files are written to a folder; but where is the DLL? I am quite new to this so sorry if too simple questions.


回答1:


Are you able to use the CPAN versions of UDUNITS2 as a drop in replacement? There look to be two:

https://metacpan.org/pod/Physics::Udunits2

https://metacpan.org/pod/Alien::UDUNITS2




回答2:


What do you really want to do? What do you really need? because there are pure perl alternatives

  • Math::Calc::Units - Human-readable unit-aware calculator
  • Physics::Unit - Manipulate physics units and dimensions
  • DateTime - A date and time object for Perl
  • http://perl.plover.com/units/units
  • XML::LibXML / XML::Twig ... because udunits2-derived.xml



回答3:


Never mind, with good folks' help from Github (as seen at: https://github.com/Unidata/UDUNITS-2/issues/18 ), I am now able to compile using the following: 1) Downloaded from Source Forge the Expat 32 library into c:\expat32

2) Downloaded the UDUNITS2 from https://github.com/Unidata/UDUNITS-2 and unzipped on a local folder.

3) Downloaded and Installed CMake 3.2 with command line options

4) Ran the following two commands from within a newly created 'build' folder inside the unzipped folder from step #2:

cmake .. -DCMAKE_PREFIX_PATH=c:\expat32 -G "Visual Studio 11" -DEXPAT_INCLUDE_DIR=C:\expat32\Source\lib -DEXPAT_LIBRARY=c:\expat32\Bin\libexpat.lib

cmake --build . --config Release 

and now I can see udunits2.dll inside: UDUNITS-2-master\build\lib\Release

folder. Now, I need to figure out how to use this DLL inside my PERL script...

Thank you all for the help!



来源:https://stackoverflow.com/questions/29657170/migration-of-perl-code-to-windows-missing-udunits-package

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!