0

Need help with pset5's unload fuction. I'm trying to use recursion.

When I compile, I'm getting:

clang: error: linker command failed with exit code 1 (use -v to see invocation)

Here's my code. I'm not sure if it's my syntax or my logic (or both!). Any help you can give is appreciated.

XXXX

****EDIT*** Here is the full error message:

lieberscott@ide50:~/workspace/pset5 $ make speller
clang -ggdb3 -O0 -Qunused-arguments -std=c11 -Wall -Werror   -c -o speller.o speller.c
clang -ggdb3 -O0 -Qunused-arguments -std=c11 -Wall -Werror   -c -o dictionary.o dictionary.c
clang -ggdb3 -O0 -Qunused-arguments -std=c11 -Wall -Werror -o speller speller.o dictionary.o 
dictionary.o: In function `unloader':
/home/ubuntu/workspace/pset5/./dictionary.h:80: multiple definition of `unloader'
speller.o:/home/ubuntu/workspace/pset5/./dictionary.h:80: first defined here
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [speller] Error 1

****EDIT 2****

Editing to delete my code. Just needed to move my code from dictionary.h to dictionary.c.

1

Did you make dictionary or make speller? The latter is correct, the former will produce the error you saw, along with about 20 relocation errors. This almost certainly has nothing to do with your code and all to do with how you tried to build the executable.

Part of this lesson is understanding how to build a project using multiple source code files and a makefile with rules to build the target.

[EDIT: post update]

The error is quite literal. The unloader() function is defined in two different locations. Without seeing full code, I can't tell where, but it should be easy enough to find.

Also, it looks like you've placed the code for unloader() in the dictionary.h file. If true, the code should be moved to the .c file. Only the signature line should appear in the .h file. Placing any actual code blocks in a .h file is a bad practice.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

2
  • Thank you for your response but I am using make speller. I've edited my original post to show the entire error message, maybe that will give more clues? – Scott Sep 18 '16 at 2:52
  • That was it. Thank you! – Scott Sep 18 '16 at 11:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .