我正在为学校做一个项目,所以我需要编译它:
gcc hide.c stegano.c -o hide -ansi -pedantic -Wall -Werror
但后来我得到这个错误:
/tmp/ccDME1jC.o: In function `calculate_n':
stegano.c:(.text+0x0): multiple definition of `calculate_n'
/tmp/ccQxPZJu.o:hide.c:(.text+0x0): first defined here
/tmp/ccDME1jC.o: In function `tam_msg':
stegano.c:(.text+0x87): multiple definition of `tam_msg'
/tmp/ccQxPZJu.o:hide.c:(.text+0x87): first defined here
/tmp/ccDME1jC.o: In function `insere_msg':
stegano.c:(.text+0xe1): multiple definition of `insere_msg'
/tmp/ccQxPZJu.o:hide.c:(.text+0xe1): first defined here
/tmp/ccDME1jC.o: In function `copia':
stegano.c:(.text+0x201): multiple definition of `copia'
/tmp/ccQxPZJu.o:hide.c:(.text+0x201): first defined here
/tmp/ccDME1jC.o: In function `esconde_msg':
stegano.c:(.text+0x274): multiple definition of `esconde_msg'
/tmp/ccQxPZJu.o:hide.c:(.text+0x274): first defined here
collect2: ld returned 1 exit status
程序代码是这样的,我认为错误可能在包含中,所以我隐藏了实际代码:
程序 hide.c 是这样的:
#include <stdio.h>
#include <stdlib.h>
#include "stegano.c"
//code//
然后它调用 stegano.c,其中包含 hide.c 中使用的所有实际函数:
#include <stdio.h>
#include <stdlib.h>
#include "stegano.h"
//code//
以及头文件stegano.h:
#include <stdio.h>
#include <stdlib.h>
#define MAX 100
typedef unsigned char Byte;
void calculate_n(char name[MAX], int* n, int* x);
int tam_msg(char name[MAX]);
void insere_msg(int size, char name[MAX], Byte* v);
void copia(Byte* v1, Byte *v2, int size);
void esconde_msg(Byte* msg, char name1[MAX], char name2[MAX]);
感谢您的帮助!