当前位置:网站首页>Makefile specifies the path of the library file loaded when the program runs
Makefile specifies the path of the library file loaded when the program runs
2022-07-27 16:02:00 【xhoufei2010】
1 Problem description
Program runtime , Prompt library not found .
reason : The default library path to run and load is /usr/lib
2 resolvent
2.1 Method 1 , Set up PATH environment variable
How to join these paths ? With PATH Variables, for example .
One way is : Directly under the command line :
PATH="PATH:/path/to/your/bin:/another/path/to/bin”
$ export PATH
The advantage of this method is convenience , Immediate effect , The disadvantage is to put the current session or shell It will fail after it is closed , I have to run it again next time .
2.2 Method 2 , modify makefile, Specify the path directly
The other way is :makefile Add the library file path of the running program
LDFLAGS+= -Wl,-Bstatic -lbt
LDFLAGS+= -Wl,-rpath=/opt/lib/
LDDIR+=-Lhost/libbt/lib
CC=/opt/toolchain/arm-2012.03/bin/arm-none-linux-gnueabi-gcc
Compile instructions :
(CC)(LDDIR) -o @^ $(LDFLAGS)
3 makefile Description of relevant parameters
CFLAGS For C Compiler options ,
CXXFLAGS For C++ Compiler options .
These two variables actually cover compilation and assembly .
Let's start with a few related environment variables :PATH、LDFLAGS、CFLAGS
LDFLAGS:gcc Wait for some optimization parameters that the compiler will use , You can also specify the location of the library file in it . usage :LDFLAGS=“-L/usr/lib -L/path/to/your/lib”. Every installation of a package will almost certainly create one in the installation directory lib Catalog . If you install a package , When you install another package , It said it couldn't find , Then take that bag lib Path joined LDFALGS Have a try .
CFLAGS: and LDFLAGS similar , Just add the header file to it (.h file ) The path of , Such as :CFLAGS=“-I/usr/include -I/path/to/your/include”. similarly , When a package is installed, a include Catalog , When there is a problem during the installation , Try to install the package before include The directory is added to the variable .
边栏推荐
- QT (VI) value and string conversion
- DRF学习笔记(一):数据序列化
- 语音直播系统——提升云存储安全性的必要手段
- openwrt 编译驱动模块(在openwrt源代码外部任意位置编写代码,独立模块化编译.ko)
- 文字批量替换功能
- Breaking through soft and hard barriers, Xilinx releases Vitis unified software platform for developers
- 突破软硬壁垒,赛灵思面向开发者发布Vitis统一软件平台
- Keil implements compilation with makefile
- Pycharm导入已有的Project
- CAS比较交换的知识、ABA问题、锁升级的流程
猜你喜欢

QT (VI) value and string conversion

语音直播系统——提升云存储安全性的必要手段

解决MT7620不断循环uboot(LZMA ERROR 1 - must RESET board to recover)

leetcode25题:K 个一组翻转链表——链表困难题目详解

SQL multi table query

Openwrt adds RTC (mcp7940 I2C bus) drive details

drf使用:get请求获取数据(小例子)

Inter thread wait and wake-up mechanism, singleton mode, blocking queue, timer

数据表的约束以及设计、联合查询——8千字攻略+题目练习解答

Sword finger offer 51. reverse pairs in the array
随机推荐
[sword finger offer] interview question 49: ugly number
[regular expression] matching grouping
UDP message structure and precautions
C: On function
Network device hard core technology insider router Chapter 22
Pycharm导入已有的Project
js操作dom节点
Understand │ what is cross domain? How to solve cross domain problems?
QT (VI) value and string conversion
台积电的反击:指控格芯侵犯25项专利,并要求禁售!
C language: dynamic memory function
Clickhouse 20.x distributed table testing and chproxy deployment (II)
Hj8 consolidated statement record
文字批量替换功能
SQL multi table query
Is the array name the address of the first element?
数据表的约束以及设计、联合查询——8千字攻略+题目练习解答
Sword finger offer 51. reverse pairs in the array
通俗易懂地区分++i和i++
携手SiFive,格兰仕进军半导体领域!两款自研芯片曝光