C compile: collect2: error: ld retornou 1 status de saída
Eu tentei procurar esse bug online, mas todas as postagens são para C ++.
Esta é a mensagem:
test1.o: em funçãoReadDictionary': /home/johnny/Desktop/haggai/test1.c:13: undefined reference to
CreateDictionary 'collect2: erro: ld retornou 1 status de saída make: *** [test1] Erro 1
código super simples e não consigo entender qual é o problema
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dict.h"
#include "hash.h"
pHash ReadDictionary() {
/* This function reads a dictionary line by line from the standard input. */
pHash dictionary;
char entryLine[100] = "";
char *word, *translation;
dictionary = CreateDictionary();
while (scanf("%s", entryLine) == 1) { // Not EOF
word = strtok(entryLine, "=");
translation = strtok(NULL, "=");
AddTranslation(dictionary, word, translation);
}
return dictionary;
}
int main() {
pHash dicti;
...
agora este é o cabeçalho dict.h
#ifndef _DICT_H_
#define _DICT_H_
#include "hash.h"
pHash CreateDictionary();
...
#endif
e aqui está o dict.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hash.h"
#include "dict.h"
pHash CreateDectionary()
{
pHash newDict;
newDict= HashCreate(650, HashWord, PrintEntry, CompareWords, GetEntryKey, DestroyEntry);
return newDict;
}
e se você quiser verificar hash.h
#ifndef _HASH_H_
#define _HASH_H_
//type defintions//
typedef enum {FAIL = 0, SUCCESS} Result;
typedef enum {SAME = 0, DIFFERENT} CompResult;
typedef struct _Hash Hash, *pHash;
typedef void* pElement;
typedef void* pKey;
//function types//
typedef int (*HashFunc) (pKey key, int size);
typedef Result (*PrintFunc) (pElement element);
typedef CompResult (*CompareFunc) (pKey key1, pKey key2);
typedef pKey (*GetKeyFunc) (pElement element);
typedef void (*DestroyFunc)(pElement element);
...
//interface functions//
#endif
Talvez seja mais fácil se eu lhe der os arquivos aqui?
De qualquer forma, ficarei feliz em receber dicas de como entender o problema