Bill-Gray / lunar

Basic astronomical functions
https://www.projectpluto.com/source.htm
GNU General Public License v2.0
93 stars 46 forks source link

Building problem. #2

Open Anandir opened 6 years ago

Anandir commented 6 years ago

Hi :-)! I'm trying to build the library on a Windows 10 machine with Visual Studio 2017 Build Tools and I've this error:

C:\Users\me\Projects\Find_Orb_Build\lunar>nmake -f lunar.mak BITS_32=Y DLL=Y

Microsoft (R) Program Maintenance Utility Version 14.14.26433.0
Copyright (C) Microsoft Corporation.  All rights reserved.

        cl -c -nologo -W3 -Ox -MT -D_CRT_SECURE_NO_WARNINGS -EHsc -LD -DNDEBUG astcheck.cpp
astcheck.cpp
astcheck.cpp(134): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
astcheck.cpp(448): error C2084: function 'int snprintf(char *const ,const size_t,const char *const ,...)' already has a body
C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt\stdio.h(1940): note: see previous definition of 'snprintf'
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.14.26428\bin\HostX86\x64\cl.EXE"' : return code '0x2'
Stop.

C:\Users\me\Projects\Find_Orb_Build\lunar>

The only solution I've found is to comment out your snprintf reimplementation, but it's not a smart move and I would like to keep the code. Do you know if there are walkaroud/fixes over this? Thanks a lot in advance and thanks a lot for your outstanding work!

mkruzynski commented 6 years ago

I think I have similar problem. Checked with Ubuntu 12.04 LTS and Ubuntu 17.10.


~/find_orb/lunar$ make install
mkdir -p ~/include
cp afuncs.h   ~/include
cp cgi_func.h ~/include
cp comets.h   ~/include
cp date.h     ~/include
cp get_bin.h  ~/include
cp lunar.h    ~/include
cp mpc_func.h ~/include
cp showelem.h ~/include
cp vislimit.h ~/include
cp watdefs.h  ~/include
mkdir -p ~/lib
cp liblunar.a ~/lib
mkdir -p /home/users/mkruzynski/bin
cp astcheck /home/users/mkruzynski/bin
cp: cannot stat `astcheck': No such file or directory
make: *** [install] Error 1```
Anandir commented 6 years ago

Hi @mkruzynski :-)! I've successfully build the library on Windows with a Cygwin/Msys2 environment, with a build procedure like a Linux environment. To do that I've follow those instructions: https://projectpluto.com/find_sou.htm . Have you read it?

Bill-Gray commented 6 years ago

Hi @Anandir , Thanks for catching this bug. Quick, temporary workaround until I post a real fix: change line 134 to read record_length = (int)strlen( buff); (or you can just ignore the casting warning), and line 432 to read #if defined(_MSC_VER) && _MSC_VER < 1900 This will ensure that a new snprintf is included as needed (only for elderly MSVCs), instead of just being added all the time. See easter.cpp for an example. I say "quick, temporary workaround" because I really ought to make one snprintf() in one file, instead of having copies of it in easter.cpp, astcheck.cpp, and tables.cpp. That's rather embarrassing.

Bill-Gray commented 6 years ago

Hi @mkruzynski , Try a make astcheck and then a make install. I should document that better; it's a little hidden at present (you aren't the only one to have mentioned this issue). Thanks for the nudge on this.

Anandir commented 6 years ago

Thanks @Bill-Gray for you reply! Regarding the conversion warning (astcheck.cpp(134): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data) I will ignore it basically. Thanks a lot for the fix. After the fix I've got this error:

C:\Users\me\Projects\Find_Orb_Build\lunar>nmake -f lunar.mak BITS_32=Y

Microsoft (R) Program Maintenance Utility Version 14.14.26433.0
Copyright (C) Microsoft Corporation.  All rights reserved.

        link /nologo    astcheck.obj eart2000.obj mpcorb.obj lunar.lib
astcheck.obj : error LNK2019: unresolved external symbol extract_date_from_mpc_report referenced in function "int __cdecl get_mpc_data(char const *,double *,double *,double *)" (?get_mpc_data@@YAHPEBDPEAN11@Z)
astcheck.obj : error LNK2019: unresolved external symbol get_ra_dec_from_mpc_report referenced in function "int __cdecl get_mpc_data(char const *,double *,double *,double *)" (?get_mpc_data@@YAHPEBDPEAN11@Z)
astcheck.obj : error LNK2019: unresolved external symbol "int __cdecl extract_sof_data(struct elements *,char const *,char const *)" (?extract_sof_data@@YAHPEAUelements@@PEBD1@Z) referenced in function "struct AST_DATA * __cdecl compute_day_data(long)" (?compute_day_data@@YAPEAUAST_DATA@@J@Z)
astcheck.exe : fatal error LNK1120: 3 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.14.26428\bin\HostX86\x64\link.EXE"' : return code '0x460'
Stop.

C:\Users\me\Projects\Find_Orb_Build\lunar>

But I've fixed it adding those lines to the lunar.def file:

   extract_date_from_mpc_report           @91
   get_ra_dec_from_mpc_report             @92
   extract_sof_data                       @93
   lat_alt_to_parallax                    @94

I hope that this can help!

Bill-Gray commented 6 years ago

Hi @Anandir - I've not actually been near a Windows machine lately. But based on your report, I've committed the fixes for the casting error and duplicate snprintf(), added your lines to lunar.def, and added several more for other functions that really ought to be exported. Eventually, I hope to add an snprintf.cpp and push that code into a separate file. But that can wait.