有两种常用的解决方法可以不使用完整路径包含库:
GCC和Clang(Linux):
gcc -I /path/to/library -o output_file source_file.c
Visual Studio(Windows):
Makefile:
CC = gcc
CFLAGS = -I /path/to/library
target: source_file.c
$(CC) $(CFLAGS) -o output_file source_file.c
CMakeLists.txt:
cmake_minimum_required(VERSION 3.10)
project(MyProject)
include_directories(/path/to/library)
add_executable(output_file source_file.c)
使用这些方法,你就可以在代码中使用相对路径来包含库,而不是完整路径。
下一篇:不使用Web API的主动通知