jdblair / sunspec

Sunspec Reference Implementation and Test Tool
Other
21 stars 5 forks source link

Compilation under cygwin #11

Closed phaebz closed 10 years ago

phaebz commented 10 years ago

Although cygwin is not supported officially, are the following errors/warnings related to my (gcc) compiler, the modbus library (compiled in the same environment) or the .c files?

$ make
make -C src all
make[1]: Entering directory '/cygdrive/d/sunspec/src'
cc -std=gnu99 -g -DDEBUG -DYY_NO_INPUT -DSUNS_MODELPATH=""\"/usr/local/lib/suns/models\""" -Wall -I/usr/local/include/modbus   -I ../lib   -c -o suns_app.o suns_app.c
suns_app.c: In function ‘suns_init_modbus’:
suns_app.c:510:5: warning: passing argument 2 of ‘modbus_set_response_timeout’ makes integer from pointer without a cast [enabled by default]
     modbus_set_response_timeout(app->mb_ctx, &timeout);
     ^
In file included from suns_app.c:48:0:
/usr/local/include/modbus/modbus.h:188:16: note: expected ‘uint32_t’ but argument is of type ‘struct timeval *’
 MODBUS_API int modbus_set_response_timeout(modbus_t *ctx, uint32_t to_sec, uint32_t to_usec);
                ^
suns_app.c:510:5: error: too few arguments to function ‘modbus_set_response_timeout’
     modbus_set_response_timeout(app->mb_ctx, &timeout);
     ^
In file included from suns_app.c:48:0:
/usr/local/include/modbus/modbus.h:188:16: note: declared here
 MODBUS_API int modbus_set_response_timeout(modbus_t *ctx, uint32_t to_sec, uint32_t to_usec);
                ^
<builtin>: recipe for target 'suns_app.o' failed
make[1]: *** [suns_app.o] Error 1
make[1]: Leaving directory '/cygdrive/d/sunspec/src'
Makefile:40: recipe for target 'all' failed
make: *** [all] Error 2

Any hints are much appreciated.

jdblair commented 10 years ago

I suspect this is being caused by a change in the libmodbus library. What version of libmodbus are you using? The last version I've tested with is version 3.0.3.

It could either be that you're using an older version of libmodbus, or this function prototype has changed since version 3.0.3.

On Wed, 2014-01-22 at 05:48 -0800, phaebz wrote:

Although cygwin is not supported officially, are the following errors/warnings related to my (gcc) compiler, the modbus library (compiled in the same environment) or the .c files?

$ make make -C src all make[1]: Entering directory '/cygdrive/d/sunspec/src' cc -std=gnu99 -g -DDEBUG -DYY_NO_INPUT -DSUNS_MODELPATH=""\"/usr/local/lib/suns/models\""" -Wall -I/usr/local/include/modbus -I ../lib -c -o suns_app.o suns_app.c suns_app.c: In function ‘suns_init_modbus’: suns_app.c:510:5: warning: passing argument 2 of ‘modbus_set_response_timeout’ makes integer from pointer without a cast [enabled by default] modbus_set_response_timeout(app->mb_ctx, &timeout); ^ In file included from suns_app.c:48:0: /usr/local/include/modbus/modbus.h:188:16: note: expected ‘uint32t’ but argument is of type ‘struct timeval ’ MODBUS_API int modbus_set_response_timeout(modbus_t ctx, uint32_t to_sec, uint32_t to_usec); ^ suns_app.c:510:5: error: too few arguments to function ‘modbus_set_response_timeout’ modbus_set_response_timeout(app->mb_ctx, &timeout); ^ In file included from suns_app.c:48:0: /usr/local/include/modbus/modbus.h:188:16: note: declared here MODBUS_API int modbus_set_response_timeout(modbus_t ctx, uint32_t to_sec, uint32_t to_usec); ^

: recipe for target 'suns_app.o' failed make[1]: *_\* [suns_app.o] Error 1 make[1]: Leaving directory '/cygdrive/d/sunspec/src' Makefile:40: recipe for target 'all' failed make: **\* [all] Error 2 Any hints are much appreciated. — Reply to this email directly or view it on GitHub.
phaebz commented 10 years ago

Thanks for your answer, I tried just now with libmodbus 3.0.3 (was using latest dev). Now I am getting another error (attached at the end). It seems that tm_gmtoff of tm_time is missing. I read up on it and it seems as if it has to do with libc on cygwin[1]. After also reading [2] I fear for the worst: This is a Windows limitation. FWIW, I am on GMT+1.

[1] http://groups.yahoo.com/neo/groups/iolanguage/conversations/topics/9710 [2] http://stackoverflow.com/questions/15667253/dealing-with-daylight-savings-time-c

$ make
cc -std=gnu99 -g -DDEBUG -DYY_NO_INPUT -DSUNS_MODELPATH=""\"/usr/local/lib/suns/models\""" -Wall -I/usr/local/include/modbus   -I ../lib   -c -o suns_app.o suns_app.c
cc -std=gnu99 -g -DDEBUG -DYY_NO_INPUT -DSUNS_MODELPATH=""\"/usr/local/lib/suns/models\""" -Wall -I/usr/local/include/modbus   -I ../lib   -c -o suns_output.o suns_output.c
suns_output.c: In function ‘value_output_sql_string’:
suns_output.c:857:5: warning: implicit declaration of function ‘string_escape_sql’ [-Wimplicit-function-declaration]
     string_escape_sql(v->value.s, tmp, len);
     ^
suns_output.c: In function ‘value_output_csv_string’:
suns_output.c:948:5: warning: implicit declaration of function ‘string_escape_cstyle’ [-Wimplicit-function-declaration]
     string_escape_cstyle(v->value.s, tmp, len);
     ^
suns_output.c: In function ‘value_output_xml_string’:
suns_output.c:1045:5: warning: implicit declaration of function ‘string_escape_xml’ [-Wimplicit-function-declaration]
     return string_escape_xml(v->value.s, buf, len);
     ^
cc -std=gnu99 -g -DDEBUG -DYY_NO_INPUT -DSUNS_MODELPATH=""\"/usr/local/lib/suns/models\""" -Wall -I/usr/local/include/modbus   -I ../lib   -c -o suns_host_parser.o suns_host_parser.c
cc -std=gnu99 -g -DDEBUG -DYY_NO_INPUT -DSUNS_MODELPATH=""\"/usr/local/lib/suns/models\""" -Wall -I/usr/local/include/modbus   -I ../lib   -c -o suns_host.o suns_host.c
cc -std=gnu99 -g -DDEBUG -DYY_NO_INPUT -DSUNS_MODELPATH=""\"/usr/local/lib/suns/models\""" -Wall -I/usr/local/include/modbus   -I ../lib   -c -o suns_lang.tab.o suns_lang.tab.c
cc -std=gnu99 -g -DDEBUG -DYY_NO_INPUT -DSUNS_MODELPATH=""\"/usr/local/lib/suns/models\""" -Wall -I/usr/local/include/modbus   -I ../lib   -c -o suns_lang.yy.o suns_lang.yy.c
suns_lang.l: In function ‘yylex’:
suns_lang.l:69:21: warning: implicit declaration of function ‘string_trim_quotes’ [-Wimplicit-function-declaration]
                     yylval.string = string_trim_quotes(strdup(yytext));
                     ^
suns_lang.l:69:35: warning: assignment makes pointer from integer without a cast [enabled by default]
                     yylval.string = string_trim_quotes(strdup(yytext));
                                   ^
suns_lang.l:73:35: warning: assignment makes pointer from integer without a cast [enabled by default]
                     yylval.string = string_trim_quotes(strdup(yytext));
                                   ^
make -C ../lib libtrx
make[1]: Entering directory '/cygdrive/d/sunspec/lib'
make -C trx libtrx.a
make[2]: Entering directory '/cygdrive/d/sunspec/lib/trx'
Makefile:43: buffer.d: No such file or directory
Makefile:43: debug.d: No such file or directory
Makefile:43: list.d: No such file or directory
Makefile:43: string.d: No such file or directory
Makefile:43: date.d: No such file or directory
generated date.d
generated string.d
generated list.d
generated debug.d
generated buffer.d
cc -g -Wall -DDEBUG -DLIST_SHUFFLE   -c -o buffer.o buffer.c
buffer.c: In function ‘buffer_info’:
buffer.c:134:5: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=]
     printf("  current size = %ld\n", buffer_len(buf));
     ^
buffer.c:134:5: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=]
buffer.c:135:5: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=]
     printf("  space left =   %ld\n", buffer_space(buf));
     ^
buffer.c:135:5: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 2 has type ‘int’ [-Wformat=]
cc -g -Wall -DDEBUG -DLIST_SHUFFLE   -c -o debug.o debug.c
cc -g -Wall -DDEBUG -DLIST_SHUFFLE   -c -o list.o list.c
cc -g -Wall -DDEBUG -DLIST_SHUFFLE   -c -o string.o string.c
string.c: In function ‘string_parse_decimal_long’:
string.c:260:5: warning: implicit declaration of function ‘string_decompose_decimal’ [-Wimplicit-function-declaration]
     if (string_decompose_decimal(buf, base_str, BUFFER_SIZE, exp) < 0)
     ^
cc -g -Wall -DDEBUG -DLIST_SHUFFLE   -c -o date.o date.c
date.c: In function ‘date_parse_rfc3339_tm’:
date.c:427:12: error: ‘struct tm’ has no member named ‘tm_gmtoff’
     tm_time->tm_gmtoff = ((zone_hour * 3600) + (zone_min * 60)) * zone_sign;
            ^
date.c: In function ‘date_parse_rfc3339_to_unixtime_z’:
date.c:457:24: error: ‘struct tm’ has no member named ‘tm_gmtoff’
     tm_gmtoff = tm_time.tm_gmtoff;
                        ^
<builtin>: recipe for target 'date.o' failed
make[2]: *** [date.o] Error 1
make[2]: Leaving directory '/cygdrive/d/sunspec/lib/trx'
Makefile:47: recipe for target 'trx/libtrx.a' failed
make[1]: *** [trx/libtrx.a] Error 2
make[1]: Leaving directory '/cygdrive/d/sunspec/lib'
Makefile:119: recipe for target '../lib/trx/libtrx.a' failed
make: *** [../lib/trx/libtrx.a] Error 2
phaebz commented 10 years ago

Never mind, I compiled it on a debian virtualenv guest and used port forwarding for testing. I'll close this, since I do not think you even want to support building it under windows...