c - 如何修改我的 makefile 以允许我包含?
问题描述
我正在用 C 修改一个示例 btstack 程序。Btstack 包含一个用于移植到树莓派的生成文件。我需要在后台运行一个计时器,而其他事情正在运行,所以我试图修补 pthreads。我已经使用“sudo apt-get ....”安装了该库,并将其包含在我的 .c 文件中。当我尝试编译时,我收到以下错误(尽管与其他错误不同,它是灰色文本而不是红色):
/usr/bin/ld: le_data_channel_server.o: undefined reference to symbol 'pthread_create@@GLIBC_2.4'
/usr/bin/ld: //lib/arm-linux-gnueabihf/libpthread.so.0: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [../../example/Makefile.inc:502: le_data_channel_server] Error 1
以下是makefile的内容:
# Makefile for Raspberry Pi
BTSTACK_ROOT ?= ../..
CORE += \
btstack_chipset_bcm.c \
btstack_chipset_bcm_download_firmware.c \
btstack_control_raspi.c \
btstack_link_key_db_tlv.c \
btstack_run_loop_posix.c \
btstack_tlv_posix.c \
btstack_uart_posix.c \
btstack_slip.c \
hci_dump_posix_fs.c \
hci_transport_h4.c \
hci_transport_h5.c \
le_device_db_tlv.c \
main.c \
wav_util.c \
btstack_stdin_posix.c \
raspi_get_model.c \
rijndael.c
# examples
include ${BTSTACK_ROOT}/example/Makefile.inc
# use (cross)compiler for Raspi
CC = arm-linux-gnueabihf-gcc
CFLAGS += -g -Wall -Werror \
-I$(BTSTACK_ROOT)/platform/embedded \
-I$(BTSTACK_ROOT)/platform/posix \
-I$(BTSTACK_ROOT)/chipset/bcm \
-I${BTSTACK_ROOT}/3rd-party/tinydir \
-I${BTSTACK_ROOT}/3rd-party/rijndael
# add 'real time' lib for clock_gettime
LDFLAGS += -lrt
VPATH += ${BTSTACK_ROOT}/3rd-party/rijndael
VPATH += ${BTSTACK_ROOT}/platform/posix
VPATH += ${BTSTACK_ROOT}/platform/embedded
VPATH += ${BTSTACK_ROOT}/chipset/bcm
EXAMPLES = ${EXAMPLES_GENERAL} ${EXAMPLES_CLASSIC_ONLY} ${EXAMPLES_LE_ONLY} ${EXAMPLES_DUAL_MODE}
EXAMPLES += pan_lwip_http_server
# use pkg-config for portaudio
# CFLAGS += $(shell pkg-config portaudio-2.0 --cflags) -DHAVE_PORTAUDIO
# LDFLAGS += $(shell pkg-config portaudio-2.0 --libs)
# hard coded flags for portaudio in /usr/local/lib
# CFLAGS += -I/usr/local/include -DHAVE_PORTAUDIO
# LDFLAGS += -L/sw/lib -lportaudio -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit -Wl,-framework,Carbon
all: ${EXAMPLES}
基本上,我应该在 makefile 中修改/添加什么,以允许我使用“make”命令在 rpi 命令行中编译程序?
编辑:MFisherKDX 的解决方案有效。我添加
LDFLAGS += -lpthread
到makefile。
解决方案
推荐阅读
- flutter - 在flutter应用程序中从显示带有加载小部件的黑屏调用时如何停止setState?
- postgresql - 如何使用标签标记变更集或变更日志文件 - webdevops/liquibase
- grails - 找不到构造函数“java.lang.String”的参数 0
- java - 如何确保 Java 线程永远不会运行无限循环?
- java - 如何在java中按右移?
- python - 为什么使用 while 循环可以使程序工作,但我原来的 for 循环不起作用?(DNA pset6)
- javascript - 查找最后一次说出一个词
- android - 无法解决 response.body().string() 的问题
- jupyter-notebook - Jupyter 中单元格之间的乳胶方程数重置为 1
- node.js - “npm install”安装不熟悉的文件