cmakefilecompiler-errors

Undefined symbols for architecture - strange message


When I compile I get a set of strange errors. This is what i compile with first. (This is generated from my makeFile.)

gcc -Wall -g -std=gnu99 -pedantic -c error.c -o error.o
gcc -Wall -g -std=gnu99 -pedantic -c agent.c -o agent.o
gcc -Wall -g -std=gnu99 -pedantic -c io.c -o io.o
gcc -Wall -g -std=gnu99 -pedantic -c map.c -o map.o

Then it comes down to linking it all together with my handler; I use this:

gcc -Wall -g -std=gnu99 -pedantic error.o agent.o io.o map.o handler.c -o handler

and it outputs a message that I cant find info about. Any ideas?

Undefined symbols for architecture x86_64:
    "_m", referenced from:
    _print_map in io.o
    _read_map in io.o
    _check_row in map.o
    _get_start_pos in map.o
    _move_one_step in map.o
    _displayMoveOnMap in map.o
    _reset_map in map.o
    ...
    (maybe you meant: _reset_map, _move_one_step , _print_map , _read_map , _main )

I think it's just a little Makefile tweak but I can't find much on these errors.


Solution

  • Sounds like you've got an extern m (I don't know what type, or even if it is a function) in both io.c and map.c, but not defining it anywhere. I'd look for the extern declaration in map.h, although that's just a guess.