webstack / mbtools

Modbus tools
BSD 3-Clause "New" or "Revised" License
34 stars 13 forks source link

"undefined reference" while building #4

Open ZupoLlask opened 8 years ago

ZupoLlask commented 8 years ago

Dear @stephane,

I'm trying to buid mbtools but I'm getting this error while doing make. Latest libmodbus v3.1.4 is installed and I'm using Linux Mint 18.

Thanks.

XS36V4 mbtools # make
make  all-recursive
make[1]: Entering directory '/home/halves/Tools/mbtools'
Making all in src
make[2]: Entering directory '/home/halves/Tools/mbtools/src'
  CC       chrono.o
  CC       daemon.o
  CC       option.o
  CC       keyfile.o
  CC       output.o
  CC       collect.o
  CCLD     mbcollect
collect.o: In function `collect_poll':
/home/halves/Tools/mbtools/src/collect.c:284: undefined reference to `modbus_connect'
/home/halves/Tools/mbtools/src/collect.c:271: undefined reference to `modbus_new_tcp'
/home/halves/Tools/mbtools/src/collect.c:277: undefined reference to `modbus_set_debug'
/home/halves/Tools/mbtools/src/collect.c:278: undefined reference to `modbus_set_error_recovery'
/home/halves/Tools/mbtools/src/collect.c:281: undefined reference to `modbus_set_slave'
/home/halves/Tools/mbtools/src/collect.c:287: undefined reference to `modbus_strerror'
/home/halves/Tools/mbtools/src/collect.c:287: undefined reference to `g_log'
/home/halves/Tools/mbtools/src/collect.c:297: undefined reference to `g_get_current_time'
/home/halves/Tools/mbtools/src/collect.c:342: undefined reference to `modbus_read_registers'
/home/halves/Tools/mbtools/src/collect.c:339: undefined reference to `g_print'
/home/halves/Tools/mbtools/src/collect.c:319: undefined reference to `modbus_set_slave'
/home/halves/Tools/mbtools/src/collect.c:321: undefined reference to `modbus_strerror'
/home/halves/Tools/mbtools/src/collect.c:321: undefined reference to `g_log'
/home/halves/Tools/mbtools/src/collect.c:378: undefined reference to `modbus_close'
/home/halves/Tools/mbtools/src/collect.c:379: undefined reference to `modbus_free'
/home/halves/Tools/mbtools/src/collect.c:344: undefined reference to `modbus_strerror'
/home/halves/Tools/mbtools/src/collect.c:344: undefined reference to `g_log'
/home/halves/Tools/mbtools/src/collect.c:347: undefined reference to `modbus_close'
/home/halves/Tools/mbtools/src/collect.c:330: undefined reference to `modbus_connect'
/home/halves/Tools/mbtools/src/collect.c:333: undefined reference to `modbus_strerror'
/home/halves/Tools/mbtools/src/collect.c:333: undefined reference to `g_log'
/home/halves/Tools/mbtools/src/collect.c:301: undefined reference to `g_print'
/home/halves/Tools/mbtools/src/collect.c:306: undefined reference to `g_log'
/home/halves/Tools/mbtools/src/collect.c:310: undefined reference to `g_print'
/home/halves/Tools/mbtools/src/collect.c:312: undefined reference to `g_print'
/home/halves/Tools/mbtools/src/collect.c:273: undefined reference to `modbus_strerror'
/home/halves/Tools/mbtools/src/collect.c:256: undefined reference to `g_log'
/home/halves/Tools/mbtools/src/collect.c:254: undefined reference to `modbus_new_rtu'
/home/halves/Tools/mbtools/src/collect.c:260: undefined reference to `modbus_set_debug'
/home/halves/Tools/mbtools/src/collect.c:262: undefined reference to `modbus_connect'
/home/halves/Tools/mbtools/src/collect.c:264: undefined reference to `modbus_strerror'
/home/halves/Tools/mbtools/src/collect.c:372: undefined reference to `modbus_close'
/home/halves/Tools/mbtools/src/collect.c:373: undefined reference to `modbus_free'
/home/halves/Tools/mbtools/src/collect.c:256: undefined reference to `modbus_strerror'
collect.o: In function `sigint_stop':
/home/halves/Tools/mbtools/src/collect.c:36: undefined reference to `modbus_close'
collect.o: In function `collect_listen_output':
/home/halves/Tools/mbtools/src/collect.c:63: undefined reference to `g_print'
collect.o: In function `collect_listen_rtu':
/home/halves/Tools/mbtools/src/collect.c:88: undefined reference to `modbus_new_rtu'
/home/halves/Tools/mbtools/src/collect.c:94: undefined reference to `modbus_set_debug'
/home/halves/Tools/mbtools/src/collect.c:95: undefined reference to `modbus_connect'
/home/halves/Tools/mbtools/src/collect.c:101: undefined reference to `modbus_set_slave'
/home/halves/Tools/mbtools/src/collect.c:103: undefined reference to `modbus_mapping_new'
/home/halves/Tools/mbtools/src/collect.c:109: undefined reference to `modbus_get_header_length'
/home/halves/Tools/mbtools/src/collect.c:111: undefined reference to `modbus_receive'
/home/halves/Tools/mbtools/src/collect.c:119: undefined reference to `modbus_mapping_free'
/home/halves/Tools/mbtools/src/collect.c:120: undefined reference to `modbus_close'
/home/halves/Tools/mbtools/src/collect.c:121: undefined reference to `modbus_free'
/home/halves/Tools/mbtools/src/collect.c:113: undefined reference to `modbus_reply'
/home/halves/Tools/mbtools/src/collect.c:97: undefined reference to `modbus_strerror'
/home/halves/Tools/mbtools/src/collect.c:90: undefined reference to `g_log'
/home/halves/Tools/mbtools/src/collect.c:90: undefined reference to `modbus_strerror'
/home/halves/Tools/mbtools/src/collect.c:105: undefined reference to `modbus_strerror'
collect.o: In function `collect_listen_tcp':
/home/halves/Tools/mbtools/src/collect.c:137: undefined reference to `modbus_new_tcp'
/home/halves/Tools/mbtools/src/collect.c:143: undefined reference to `modbus_set_debug'
/home/halves/Tools/mbtools/src/collect.c:145: undefined reference to `modbus_mapping_new'
/home/halves/Tools/mbtools/src/collect.c:152: undefined reference to `modbus_tcp_listen'
/home/halves/Tools/mbtools/src/collect.c:163: undefined reference to `modbus_get_header_length'
/home/halves/Tools/mbtools/src/collect.c:214: undefined reference to `modbus_reply'
/home/halves/Tools/mbtools/src/collect.c:211: undefined reference to `modbus_set_socket'
/home/halves/Tools/mbtools/src/collect.c:212: undefined reference to `modbus_receive'
/home/halves/Tools/mbtools/src/collect.c:204: undefined reference to `g_print'
/home/halves/Tools/mbtools/src/collect.c:235: undefined reference to `modbus_mapping_free'
/home/halves/Tools/mbtools/src/collect.c:239: undefined reference to `modbus_free'
/home/halves/Tools/mbtools/src/collect.c:220: undefined reference to `g_print'
/home/halves/Tools/mbtools/src/collect.c:139: undefined reference to `modbus_strerror'
/home/halves/Tools/mbtools/src/collect.c:147: undefined reference to `g_log'
/home/halves/Tools/mbtools/src/collect.c:154: undefined reference to `modbus_strerror'
/home/halves/Tools/mbtools/src/collect.c:154: undefined reference to `g_log'
/home/halves/Tools/mbtools/src/collect.c:147: undefined reference to `modbus_strerror'
collect.o: In function `main':
/home/halves/Tools/mbtools/src/collect.c:456: undefined reference to `g_print'
/home/halves/Tools/mbtools/src/collect.c:434: undefined reference to `g_print'
/home/halves/Tools/mbtools/src/collect.c:428: undefined reference to `g_print'
/home/halves/Tools/mbtools/src/collect.c:460: undefined reference to `g_print'
/home/halves/Tools/mbtools/src/collect.c:408: undefined reference to `modbus_strerror'
/home/halves/Tools/mbtools/src/collect.c:408: undefined reference to `g_log'
chrono.o: In function `new_date_time_string':
/home/halves/Tools/mbtools/src/chrono.c:17: undefined reference to `g_malloc'
chrono.o: In function `print_date_time':
/home/halves/Tools/mbtools/src/chrono.c:30: undefined reference to `g_print'
/home/halves/Tools/mbtools/src/chrono.c:31: undefined reference to `g_free'
option.o: In function `option_new':
/home/halves/Tools/mbtools/src/option.c:11: undefined reference to `g_slice_alloc'
option.o: In function `option_free':
/home/halves/Tools/mbtools/src/option.c:40: undefined reference to `g_free'
/home/halves/Tools/mbtools/src/option.c:41: undefined reference to `g_free'
/home/halves/Tools/mbtools/src/option.c:42: undefined reference to `g_free'
/home/halves/Tools/mbtools/src/option.c:43: undefined reference to `g_free'
/home/halves/Tools/mbtools/src/option.c:44: undefined reference to `g_free'
option.o:/home/halves/Tools/mbtools/src/option.c:45: more undefined references to `g_free' follow
option.o: In function `option_free':
/home/halves/Tools/mbtools/src/option.c:46: undefined reference to `g_slice_free1'
option.o: In function `option_parse_mode':
/home/halves/Tools/mbtools/src/option.c:131: undefined reference to `g_log'
option.o: In function `option_parse':
/home/halves/Tools/mbtools/src/option.c:84: undefined reference to `g_malloc_n'
/home/halves/Tools/mbtools/src/option.c:89: undefined reference to `g_option_context_new'
/home/halves/Tools/mbtools/src/option.c:90: undefined reference to `g_option_context_add_main_entries'
/home/halves/Tools/mbtools/src/option.c:92: undefined reference to `g_option_context_parse'
/home/halves/Tools/mbtools/src/option.c:93: undefined reference to `g_option_context_free'
/home/halves/Tools/mbtools/src/option.c:94: undefined reference to `g_free'
/home/halves/Tools/mbtools/src/option.c:97: undefined reference to `g_log'
/home/halves/Tools/mbtools/src/option.c:102: undefined reference to `g_free'
/home/halves/Tools/mbtools/src/option.c:102: undefined reference to `g_free'
/home/halves/Tools/mbtools/src/option.c:106: undefined reference to `g_file_test'
/home/halves/Tools/mbtools/src/option.c:108: undefined reference to `g_file_test'
/home/halves/Tools/mbtools/src/option.c:109: undefined reference to `g_strdup'
/home/halves/Tools/mbtools/src/option.c:107: undefined reference to `g_strdup'
option.o: In function `option_set_undefined':
/home/halves/Tools/mbtools/src/option.c:183: undefined reference to `g_strdup'
/home/halves/Tools/mbtools/src/option.c:186: undefined reference to `g_strdup'
/home/halves/Tools/mbtools/src/option.c:176: undefined reference to `g_strdup'
option.o:/home/halves/Tools/mbtools/src/option.c:167: more undefined references to `g_strdup' follow
keyfile.o: In function `keyfile_set_integer':
/home/halves/Tools/mbtools/src/keyfile.c:209: undefined reference to `g_key_file_get_integer'
keyfile.o: In function `keyfile_parse':
/home/halves/Tools/mbtools/src/keyfile.c:24: undefined reference to `g_key_file_new'
/home/halves/Tools/mbtools/src/keyfile.c:26: undefined reference to `g_key_file_load_from_file'
/home/halves/Tools/mbtools/src/keyfile.c:75: undefined reference to `g_key_file_get_groups'
/home/halves/Tools/mbtools/src/keyfile.c:99: undefined reference to `g_slice_alloc'
/home/halves/Tools/mbtools/src/keyfile.c:110: undefined reference to `g_key_file_get_integer'
/home/halves/Tools/mbtools/src/keyfile.c:129: undefined reference to `g_strdup_printf'
/home/halves/Tools/mbtools/src/keyfile.c:132: undefined reference to `g_key_file_get_integer_list'
/home/halves/Tools/mbtools/src/keyfile.c:134: undefined reference to `g_key_file_get_integer_list'
/home/halves/Tools/mbtools/src/keyfile.c:137: undefined reference to `g_key_file_get_string_list'
/home/halves/Tools/mbtools/src/keyfile.c:161: undefined reference to `g_print'
/home/halves/Tools/mbtools/src/keyfile.c:166: undefined reference to `g_print'
/home/halves/Tools/mbtools/src/keyfile.c:164: undefined reference to `g_print'
/home/halves/Tools/mbtools/src/keyfile.c:168: undefined reference to `g_print'
/home/halves/Tools/mbtools/src/keyfile.c:179: undefined reference to `g_key_file_free'
/home/halves/Tools/mbtools/src/keyfile.c:94: undefined reference to `g_log'
/home/halves/Tools/mbtools/src/keyfile.c:177: undefined reference to `g_strfreev'
/home/halves/Tools/mbtools/src/keyfile.c:124: undefined reference to `g_strndup'
/home/halves/Tools/mbtools/src/keyfile.c:127: undefined reference to `g_strdup_printf'
/home/halves/Tools/mbtools/src/keyfile.c:22: undefined reference to `g_print'
/home/halves/Tools/mbtools/src/keyfile.c:66: undefined reference to `g_key_file_get_boolean'
/home/halves/Tools/mbtools/src/keyfile.c:32: undefined reference to `g_key_file_get_string'
/home/halves/Tools/mbtools/src/keyfile.c:34: undefined reference to `g_free'
/home/halves/Tools/mbtools/src/keyfile.c:60: undefined reference to `g_key_file_get_boolean'
/home/halves/Tools/mbtools/src/keyfile.c:113: undefined reference to `g_key_file_get_string'
/home/halves/Tools/mbtools/src/keyfile.c:117: undefined reference to `g_key_file_get_integer'
/home/halves/Tools/mbtools/src/keyfile.c:159: undefined reference to `g_print'
/home/halves/Tools/mbtools/src/keyfile.c:145: undefined reference to `g_log'
/home/halves/Tools/mbtools/src/keyfile.c:52: undefined reference to `g_key_file_get_string'
/home/halves/Tools/mbtools/src/keyfile.c:141: undefined reference to `g_log'
/home/halves/Tools/mbtools/src/keyfile.c:63: undefined reference to `g_key_file_get_string'
/home/halves/Tools/mbtools/src/keyfile.c:27: undefined reference to `g_key_file_free'
/home/halves/Tools/mbtools/src/keyfile.c:57: undefined reference to `g_key_file_get_string'
/home/halves/Tools/mbtools/src/keyfile.c:40: undefined reference to `g_key_file_get_string'
/home/halves/Tools/mbtools/src/keyfile.c:45: undefined reference to `g_key_file_get_string'
/home/halves/Tools/mbtools/src/keyfile.c:115: undefined reference to `g_strdup'
keyfile.o: In function `keyfile_server_free':
/home/halves/Tools/mbtools/src/keyfile.c:190: undefined reference to `g_free'
/home/halves/Tools/mbtools/src/keyfile.c:191: undefined reference to `g_free'
/home/halves/Tools/mbtools/src/keyfile.c:192: undefined reference to `g_free'
/home/halves/Tools/mbtools/src/keyfile.c:193: undefined reference to `g_free'
/home/halves/Tools/mbtools/src/keyfile.c:194: undefined reference to `g_strfreev'
/home/halves/Tools/mbtools/src/keyfile.c:197: undefined reference to `g_slice_free1'
output.o: In function `output_connect':
/home/halves/Tools/mbtools/src/output.c:25: undefined reference to `g_print'
/home/halves/Tools/mbtools/src/output.c:36: undefined reference to `g_print'
output.o: In function `output_write':
/home/halves/Tools/mbtools/src/output.c:80: undefined reference to `g_malloc_n'
/home/halves/Tools/mbtools/src/output.c:91: undefined reference to `modbus_get_float_dcba'
/home/halves/Tools/mbtools/src/output.c:95: undefined reference to `g_strdup_printf'
/home/halves/Tools/mbtools/src/output.c:99: undefined reference to `g_strdup_printf'
/home/halves/Tools/mbtools/src/output.c:105: undefined reference to `g_strjoinv'
/home/halves/Tools/mbtools/src/output.c:116: undefined reference to `g_free'
/home/halves/Tools/mbtools/src/output.c:118: undefined reference to `g_free'
/home/halves/Tools/mbtools/src/output.c:119: undefined reference to `g_free'
/home/halves/Tools/mbtools/src/output.c:93: undefined reference to `modbus_get_float'
/home/halves/Tools/mbtools/src/output.c:86: undefined reference to `g_strdup_printf'
/home/halves/Tools/mbtools/src/output.c:105: undefined reference to `g_strjoinv'
/home/halves/Tools/mbtools/src/output.c:111: undefined reference to `g_print'
collect2: error: ld returned 1 exit status
Makefile:380: recipe for target 'mbcollect' failed
make[2]: *** [mbcollect] Error 1
make[2]: Leaving directory '/home/halves/Tools/mbtools/src'
Makefile:375: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/halves/Tools/mbtools'
Makefile:316: recipe for target 'all' failed
make: *** [all] Error 2
stephane commented 8 years ago

You didn't had properly installed libmodbus and glib libraries on your system but I'm surprised ./autogen.sh doesn't complain about that.

To ensure everything is properly installed, you can check the output of: pkg-config libmodbus --libs

ZupoLlask commented 8 years ago

Output of pkg-config:

XS36V4 mbtools # pkg-config libmodbus --libs
-L/usr/local/lib -lmodbus

I'm getting the same "undefined reference" error...

stephane commented 8 years ago

Did you run ldconfig?

ZupoLlask commented 8 years ago

Yes I did and the result is the same.

What puzzles me is the fact that neither ./autogen.sh nor ./configure complains about anything being wrong or missing.

ZupoLlask commented 8 years ago
XS36V4 mbtools # ldconfig -p | grep modbus
        libmodbus.so.5 (libc6,x86-64) => /usr/local/lib/libmodbus.so.5
        libmodbus.so (libc6,x86-64) => /usr/local/lib/libmodbus.so
ZupoLlask commented 8 years ago

@stephane,

Do you have any other idea to tackle this issue?

tkuehne71 commented 7 years ago

I have exactly the same issue. I compiled and installed libmodbus 3.1.4, and I'm using ubuntu 16.04.1 LTS.