tomojitakasu / RTKLIB

2.56k stars 1.63k forks source link

Compiling str2str on Windows #694

Open coalcandy opened 2 years ago

coalcandy commented 2 years ago

Hi! Sorry for this (probably) noob question, I've tried a lot of things, but haven't managed to compile str2str on Windows. I have tested out strsvr and now I want to harness this power from the command line.

  1. When using >> vi makefile as suggested in the manual, from Cygwin64 I get

$ vi makefile E1187: Failed to source defaults.vim Press ENTER or type command to continue

If I press enter, the makefile is opened, but I can't do anything with it, except replace text.

  1. I also tried using GNU Make

    $ make cc -c -Wall -O3 -ansi -pedantic -Wno-unused-but-set-variable -I../../../src -DENAGLO -DENAGAL -DENAQZS -DENACMP -DTRACE -DNFREQ=3 -DNEXOBS=3 -g ../str2str.c ../str2str.c:26:19: warning: ‘rcsid’ defined but not used [-Wunused-const-variable=] 26 | static const char rcsid[]="$Id:$"; | ^~~~~ cc -c -Wall -O3 -ansi -pedantic -Wno-unused-but-set-variable -I../../../src -DENAGLO -DENAGAL -DENAQZS -DENACMP -DTRACE -DNFREQ=3 -DNEXOBS=3 -g ../../../src/stream.c ../../../src/stream.c: In function ‘readfile’: ../../../src/stream.c:628:5: error: unknown type name ‘fd_set’ 628 | fd_set rs; | ^~ ../../../src/stream.c:639:9: warning: implicit declaration of function ‘FD_ZERO’ [-Wimplicit-function-declaration] 639 | FD_ZERO(&rs); FD_SET(0,&rs); | ^~~ ../../../src/stream.c:639:23: warning: implicit declaration of function ‘FD_SET’ [-Wimplicit-function-declaration] 639 | FD_ZERO(&rs); FD_SET(0,&rs); | ^~ ../../../src/stream.c:640:14: warning: implicit declaration of function ‘select’ [-Wimplicit-function-declaration] 640 | if (!select(1,&rs,NULL,NULL,&tv)) return 0; | ^~ ../../../src/stream.c: In function ‘accept_nb’: ../../../src/stream.c:834:5: error: unknown type name ‘fd_set’ 834 | fd_set rs; | ^~ ../../../src/stream.c: In function ‘connect_nb’: ../../../src/stream.c:856:5: error: unknown type name ‘fd_set’ 856 | fd_set rs,ws; | ^~ ../../../src/stream.c: In function ‘recv_nb’: ../../../src/stream.c:874:5: error: unknown type name ‘fd_set’ 874 | fd_set rs; | ^~ ../../../src/stream.c: In function ‘send_nb’: ../../../src/stream.c:884:5: error: unknown type name ‘fd_set’ 884 | fd_set ws; | ^~ At top level: ../../../src/stream.c:64:19: warning: ‘rcsid’ defined but not used [-Wunused-const-variable=] 64 | static const char rcsid[]="$Id$"; | ^~~~~ make: *** [makefile:22: stream.o] Error 1

The manual suggests making edits to the makefile to suit the platform. I would be very thankful for some pointers on how to figure out what edits I need to do. Thanks in advance!

DanielMamaev commented 6 months ago

Hi. I managed to do it the following way.

  1. I downloaded and installed gcc-11.3.0-64.exe . From this site http://www.equation.com/servlet/equation.cmd?fa=fortran After installation, I checked that it works. gcc --version

  2. After that, I made the following changes to the makefile. Path to makefile RTKLIB_2.4.3_b34\app\consapp\str2str\gcc\makefile.

CC = gcc

OPTION = -DENAGLO -DENAGAL -DENAQZS -DENACMP -DENAIRN -DTRACE -DNFREQ=5 -DNEXOBS=3 -DSVR_REUSEADDR -DWIN32

LDLIBS  = -lm -lpthread -lwinmm -lws2_32
  1. Make sure that there are no files in the gcc folder except the makefile.
  2. Run make
alex-skyfora commented 1 month ago

Hi Daniel, I am trying to compile str2str on Windows following your instructions, but it fails with this error:

$ make
gcc -c -Wall -O3 -ansi -pedantic -Wno-unused-but-set-variable -I../../../../src -DENAGLO -DENAGAL -DENAQZS -DENACMP -DENAIRN -DTRACE -DNFREQ=5 -DNEXOBS=3 -DSVR_REUSEADDR -DWIN32  -g ../str2str.c
../str2str.c: In function 'main':
../str2str.c:301:12: error: 'SIGHUP' undeclared (first use in this function)
  301 |     signal(SIGHUP ,SIG_IGN);
      |            ^~~~~~
../str2str.c:301:12: note: each undeclared identifier is reported only once for each function it appears in
../str2str.c:302:12: error: 'SIGPIPE' undeclared (first use in this function); did you mean 'SIGFPE'?
  302 |     signal(SIGPIPE,SIG_IGN);
      |            ^~~~~~~
      |            SIGFPE
make: *** [makefile:23: str2str.o] Error 1

Any idea what might be the issue?

Here are my make and gcc versions:

make

$ make --version
GNU Make 4.3
This program is built by Equation Solution <http://www.Equation.com>.
Copyright (C) 1988-2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

gcc

$ gcc --version
gcc.exe (GCC) 12.3.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I have also attached the makefile.txt (as .txt to be able to attach it in this text box).

any help is really appreciated, thanks!

EDIT

I fixed the issue by changing lines 299-303 of str2str.c:

    signal(SIGTERM,sigfunc);
    signal(SIGINT ,sigfunc);
    #ifdef __unix__
    signal(SIGHUP ,SIG_IGN);
    signal(SIGPIPE,SIG_IGN);
    #endif

Everything works fine now!

DanielMamaev commented 1 month ago

@alex-skyfora , ops, my bad. I'm so sorry. I forgot about it. Your corrections are correct😅👍