1

I want to build a c program with a custom makefile. The libs folder is in the parent folder and is linked in the makefie via LD flags (no global installation). When I build the program (a decoder) I receive neither errors nor warnings but the message:

-------------- Build: Debug in KIS01b (compiler: GNU GCC Compiler)---------------

Running command: make -f Makefile.mak Debug
gcc -o KIS01b KIS01b.o -L../libs/lib -lm
Undefined symbols for architecture x86_64:
"_av_frame_alloc", referenced from:
  _main in KIS01b.o
"_av_frame_free", referenced from:
  _main in KIS01b.o
"_av_free", referenced from:
  _main in KIS01b.o
"_av_freep", referenced from:
  _decode in KIS01b.o
"_av_get_channel_layout_nb_channels", referenced from:
  _decode in KIS01b.o
"_av_malloc", referenced from:
  _decode in KIS01b.o
"_av_packet_alloc", referenced from:
  _main in KIS01b.o
"_av_packet_free", referenced from:
  _main in KIS01b.o
"_av_parser_close", referenced from:
  _main in KIS01b.o
"_av_parser_init", referenced from:
  _main in KIS01b.o
"_av_parser_parse2", referenced from:
  _main in KIS01b.o
"_avcodec_alloc_context3", referenced from:
  _main in KIS01b.o
"_avcodec_find_decoder", referenced from:
  _main in KIS01b.o
"_avcodec_free_context", referenced from:
  _main in KIS01b.o
"_avcodec_open2", referenced from:
  _main in KIS01b.o
"_avcodec_receive_frame", referenced from:
  _decode in KIS01b.o
"_avcodec_register_all", referenced from:
  _main in KIS01b.o
"_avcodec_send_packet", referenced from:
  _decode in KIS01b.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [KIS01b] Error 1
Process terminated with status 2 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

Here the makefile

CC = gcc
CFLAGS = -c -Wall -I../libs/include
LDFLAGS = -L../libs/lib -lm

all: Release

Debug: CFLAGS += -g
Debug: KIS01b

Release: KIS01b

KIS01b: KIS01b.o
$(CC) -o KIS01b KIS01b.o $(LDFLAGS)

KIS01b.o: KIS01b.c
$(CC) $(CFLAGS) KIS01b.c -o KIS01b.o

clean:
rm -f KIS01b.o KIS01b

And the c code is the one from this link: https://libav.org/documentation/doxygen/master/decode__audio_8c_source.html

Do you have any idea what could go wrong?

  • it seems like you have a library-devel.i686 installed but library-devel.x86_64 not installed which is required to build this program – Aurangzeb Jul 24 '19 at 06:07
  • Symbols `_av*` are most likely from `libav` library, but I see not linking with that library in your Makefile. – Tsyvarev Jul 24 '19 at 13:28
  • 1
    Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Tsyvarev Jul 24 '19 at 13:29

0 Answers0