Answer the question
In order to leave comments, you need to log in
Why does an undefined reference error occur?
In general, such a thing, you need to build a library of configuration files for the test, but during the build process an error occurs that the assembler cannot find implementations of functions in * .c files.
https://github.com/vstakhov/libucl Actually the project itself.
I downloaded and installed cygwin with the make package to build according to Makefile.w32, then I will give the build log:
$ export CC=gcc && make -f Makefile.w32
gcc -o .obj/ucl_hash.o -O2 -fPIC -Wall -W -Wno-unused-parameter -Wno-pointer-sign -I./include -I./ uthash -I./src -I./klib -c src/ucl_hash.c
gcc -o .obj/ucl_util.o -O2 -fPIC -Wall -W -Wno-unused-parameter -Wno-pointer-sign -I. /include -I./uthash -I./src -I./klib -c src/ucl_util.c
src/ucl_util.c: In function 'ucl_include_file':
src/ucl_util.c:1253:9: warning: unused variable 'i' [-Wunused-variable]
size_t i;
^
src/ucl_util.c:1252:7: warning: unused variable 'glob_pattern' [-Wunused-variable]
char glob_pattern[PATH_MAX];
^~~~~~~~~~~~
src/ucl_util.c:1251:6: warning: unused variable 'cnt'
^~~
src/ucl_util.c:1250:7: warning: unused variable 'need_glob' [-Wunused-variable]
bool need_glob = false;
^~~~~~~~~
src/ucl_util.c:1249:34: warning: unused variable 'end' [-Wunused-variable]
const unsigned char *p = data, *end = data + len;
^~~
src/ucl_util.c:1249:23: warning: unused variable 'p' [-Wunused-variable]
const unsigned char *p = data, *end = data + len;
^
gcc -o .obj/ucl_parser.o -O2 -fPIC -Wall -W -Wno-unused-parameter -Wno-pointer-sign -I./include -I./uthash -I./src -I./klib -c src/ucl_parser.c
gcc -o .obj/ucl_emitter.o -O2 -fPIC -Wall -W -Wno-unused-parameter -Wno-pointer-sign -I./include -I./uthash -I./src -I./klib - c src/ucl_emitter.c
gcc -o .obj/ucl_emitter_utils.o -O2 -fPIC -Wall -W -Wno-unused-parameter -Wno-pointer-sign -I./include -I./uthash -I./src -I./klib -c src/ucl_emitter_utils.c
src/ucl_emitter_utils.c: In function 'ucl_utstring_append_int':
src/ucl_emitter_utils.c:200:26: warning: unknown conversion type character 'j' in format [-Wformat=]
utstring_printf (buf, "%jd", (intmax_t)val);
^
src/ucl_emitter_utils.c:200:24: warning: too many arguments for format [-Wformat-extra-args]
utstring_printf (buf, "%jd", (intmax_t)val);
^~~~~
src/ucl_emitter_utils.c: In function 'ucl_file_append_int':
src/ucl_emitter_utils.c:254:17: warning: unknown conversion type character 'j' in format [-Wformat=]
fprintf (fp, "%jd", (intmax_t) val);
^
src/ucl_emitter_utils.c:254:15: warning: too many arguments for format [-Wformat-extra-args]
fprintf (fp, "%jd", (intmax_t)val);
^~~~~
src/ucl_emitter_utils.c: In function 'ucl_fd_append_int':
src/ucl_emitter_utils.c:328:39: warning: unknown conversion type character 'j' in format [-Wformat=]
snprintf (intbuf, sizeof (intbuf ), "%jd", (intmax_t)val);
^
src/ucl_emitter_utils.c:328:37: warning: too many arguments for format [-Wformat-extra-args]
snprintf (intbuf, sizeof (intbuf), "%jd", (intmax_t)val);
^~~~~
gcc -o .obj/ucl_schema.o -O2 -fPIC -Wall -W -Wno-unused-parameter -Wno-pointer-sign -I./include -I./uthash -I./src - I./klib -c src/ucl_schema.c
In file included from src/ucl_schema.c:28:0:
src/tree.h:154:36: warning: 'TREE_REMOVE_ucl_compare_node_link' defined but not used [-Wunused-function]
static struct node *_HU_FUNCTION(TREE_REMOVE_##node##_##field) \
^
src/tree.h:49:56: note: in definition of macro '_HU_FUNCTION'
^
src/ucl_schema.c:423:1: note: in expansion of macro 'TREE_DEFINE'
TREE_DEFINE(ucl_compare_node, link)
^~~~~~~~~~~
gcc -shared -o .obj/libucl.dll .obj /ucl_hash.o .obj/ucl_util.o .obj/ucl_parser.o .obj/ucl_emitter.o .obj/ucl_emitter_utils.o .obj/ucl_schema.o
.obj/ucl_parser.o:ucl_parser.c:(.text+0x4554 ): undefined reference to `ucl_parse_csexp'
.obj/ucl_parser.o:ucl_parser.c:(.text+0x4565): undefined reference to `ucl_parse_msgpack'
.obj/ucl_emitter.o:ucl_emitter.c:(.text+0x63): undefined reference to `ucl_emitter_print_key_msgpack'
.obj/ucl_emitter.o:ucl_emitter.c:(.text+0x86): undefined reference to `ucl_emitter_print_string_msgpack'
.obj/ucl_emitter.o:ucl_emitter.c:(.text+0x92): undefined reference to ` ucl_emitter_print_key_msgpack
'
/ucl_emitter.o:ucl_emitter.c:(.text+0xa6): undefined reference to `ucl_emitter_print_key_msgpack'
.obj/ucl_emitter.o:ucl_emitter.c:(.text+0xb9): undefined reference to `ucl_emitter_print_object_msgpack'
.obj/ucl_emitter .o:ucl_emitter.c:(.text+0x111): undefined reference to ` ucl_emitter_print_key_msgpack
'
:ucl_emitter.c:(.text+0x171): undefined reference to `ucl_emitter_print_key_msgpack'
.obj/ucl_emitter.o:ucl_emitter.c:(.text+0x189): undefined reference to ` ucl_emitter_print_int_msgpack
'
/ucl_emitter.o:ucl_emitter.c:(.text+0x1a9): undefined reference to `ucl_emitter_print_double_msgpack'
.obj/ucl_emitter.o:ucl_emitter.c:(.text+0x1b5): undefined reference to `ucl_emitter_print_key_msgpack'
.obj/ucl_emitter .o:ucl_emitter.c:(.text+0x1d4): undefined reference to ` ucl_emitter_print_binary_string_msgpack
'
:ucl_emitter.c:(.text+0x1f8): undefined reference to `ucl_emitter_print_bool_msgpack'
.obj/ucl_emitter.o:ucl_emitter.c:(.text+0x1c): undefined reference to `ucl_emitter_print_array_msgpack'
.obj/ucl_emitter.o:ucl_emitter.c:(.text+0x2c): undefined reference to `ucl_emitter_print_object_msgpack'
collect2. exe: error: ld returned 1 exit status
make: *** [Makefile.w32:43: .obj/libucl.dll] Error 1
$ export CC=gcc && make -f Makefile.w32
gcc -L.obj -lucl -shared -o .obj/libucl.dll .obj/ucl_hash.o .obj/ucl_util.o .obj/ucl_parser.o .obj/ ucl_emitter.o .obj/ucl_emitter_utils.o .obj/ucl_schema.o
.obj/libucl.dll: file not recognized: File truncated
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile.w32:43 : .obj/libucl.dll] Error 1
Answer the question
In order to leave comments, you need to log in
Typically, this error occurs when major changes have been made to the program code (or, as a rule, new files have been removed or added to the project). Just delete the compiled project folder and recompile. And then the error should disappear. Such a folder is usually located in the same place as the folder with the project itself. The name, of course, may vary, but usually looks something like this: build- Project_name -Desktop_Qt_ 5_11_1 _MinGW_32bit - Debug. This is the folder that needs to be deleted.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question