【发布时间】:2020-12-08 11:02:54
【问题描述】:
我正在尝试编译一个包含不同模块(.h 文件)的项目,所以我使用的是makefile。我添加了一个名为semaphore_v2.h 的新模块,我将它包含在另一个名为connection.h 的模块中。 connection.h 包含在主进程所在的 jack.c 中。使用make 命令编译时,出现以下错误:
似乎尽管我包含了该模块,但它并没有跟踪 semaphore_v2.h 模块的引用,我在这里找不到问题。怎么了?
makefile:
all: compilation
jack.o: jack.c
gcc -c jack.c -Wall -Wextra
semaphore_v2.o: semaphore_v2.c semaphore_v2.h
gcc -c semaphore_v2.c -Wall -Wextra
files.o: files.c files.h
gcc -c files.c -Wall -Wextra
connection.o: connection.c connection.h
gcc -c connection.c -Wall -Wextra
compilation: jack.o files.o connection.o
gcc jack.o connection.o files.o -o jack -Wall -Wextra -lpthread
connection.h
#ifndef _CONNECTION_H_
#define _CONNECTION_H_
#include <unistd.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <time.h>
#include "files.h"
#include <ctype.h>
#include <pthread.h>
#include <sys/wait.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include "semaphore_v2.h"
typedef struct {
int socketfd;
int memid;
semaphore *sinc;
}thread_input;
...
jack.c
#include <signal.h>
#include "connection.h"
...
【问题讨论】:
标签: c linux compilation