Linux - 建立动态库

Synopsys安装教程Ubuntu22.04版本 在Ubuntu22版本上安装Synopsys等系列工具,安装DC,VCS等等 阅读详情

用个简单例子来举例。

sum.c里封装着sum函数用来计算俩数之和,main.c去调用这个动态库。

//1.建立动态库
book@book-virtual-machine:~/0826$gcc sum.c -shared -fPIC -libsum.so(Linux命名规范-lib+文件名.so  .so就是动态库的意思)
//2.编译
book@book-virtual-machine:~/0826$gcc main.c -lsum -L.(L. 声明运行路径)
//3.运行
book@book-virtual-machine:~/0826$./a.out

//然后就会出现这个错误提示
./a.out: error while loading shared libraries: libsum.so: cannot open shared object file: No such file or directory
//4.查看程序所需要用到的库
book@book-virtual-machine:~/0826$ldd a.out

//出现下面提示,书找不到libsum.so ,因为系统找的路径不对,这时候我们就告诉系统要找的路径
	linux-vdso.so.1 =>  (0x00007fffb0fe2000)
	libsum.so => not found
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f66c7d8f000)

//5.配置环境
export LD_LIBRARY_PATH =. (. 表示当前目录)
//6.运行

book@book-virtual-machine:~/0826$ ./a.out 
sum=2

尝试使用CubeMX做stm32开发之九:SYS配置 参考《STM32中文参考手册_V10》,研究CubeMX中有关SYS的配置 阅读详情

相关推荐

手把手教你用FPGA+AD9822搭建300DPI的CIS高速图像采集系统(附时序调试心得)

本文详细介绍了如何利用FPGA作为核心控制器,结合AD9822三通道采样保持放大器/ADC,构建一套完整的300DPI CIS高速图像采集系统。内容涵盖从CIS传感器驱动时序、AD9822寄存器配置与协同调试,到采用千兆以太网替代USB实现稳定高速数据传输的完整实战指南,并分享了关键的时序调试心得与系统集成经验。

weixin_29306261的博客 143

LINUX系统中动态链接库的创建与使用

LINUX系统中动态链接库的创建与使用       大家都知道,在WINDOWS系统中有很多的动态链接库(以.DLL为后缀 的文件,DLL即Dynamic Link Library)。这种动态链接库,和静态函数库不 同,它里面的函数并不是执行程序本身的一部分,而是根据执行程序需要 按需装入,同时其执行代码可在多个执行程序间共享,节省了空间,提高 了效率,具备很高的灵活性,得到越来越多

leo115的专栏 774

win10安装openvpn客户端

进入C:\Program Files\TAP-Windows\bin目录,然后右键用管理员权限执行addtap.bat文件,此文件执行会创建一个网卡。链接:https://pan.baidu.com/s/1KAifTiP7qp1i5ZkfdnfwkA。4.2 进入安装目录的config下新建一个文件夹,将证书文件全部挪进去(不移动.ovpn文件)3.4 将拿到的ssl认证文件放入安装目录的config目录下。然后修改ovpn文件 “./”代表当前路径,第二个链接重复。3.1 一直下一步到这里打上勾。

qq_36200932的博客 3万+

Linux动态链接库的创建与使用

linux动态链接库的创建与使用

weixin_47459234的博客 2189

自动驾驶仿真基础:使用Veristand自定义CAN报文的Checksum和Counter

文章目录前言一、关于Checksum的组成形式二、自定义的Checksum方法一1、实现的主要流程图如下:2、方法一的主要算法参考三、自定义的Checksum方法二1、软件及插件下载;2、Custom device的使用;4、Veristand调用Custom Device;5、Veristand发送信号值;6、部署到实时机; 前言 1、现在很多的车厂对于车辆的安全机制非常重视,车厂通过对发送的CAN数据进行加密而形成一种保护机制,而Checksum和Counter是其中的一种保护介质,当CAN报文数据的

zataji的博客 1万+

SAR成像概述

1. 发展概述 雷达是英文Radar(Radio detection and ranging)的音译,原意为“无线电探测与测距”。雷达的发明是无线电发展史上的里程碑,二战时,英国急需通过雷达探测空中金属物体来帮助搜寻德国飞机,这期间,雷达技术飞速发展,发展出了地对空、空对地轰炸、空对空火控、敌我识别等功能。雷达在第二次世界大战中发挥了重大作用,至今仍是军用和许多民用领域的重要传感器。 早期雷达系统通过时间延迟来测距,通过天线指向来测角,通过多普勒频移测速。1951年,Carl Wiley发现,通..

5100

Linux学习——动态库的创建

Linux——创建动态库一.动态库特点:二.生成动态库(共享库)(1)生成目标文件 .o(2)创建共享库,以command为例(3)给共享库创建链接(4)编译测试(5)让系统找到库的方法1.方法二:2.方法三: 一.动态库特点: 二.生成动态库(共享库) 例子文件: test.c: #include <stdio.h> #include "mydemo.h" int main() { printf("Test begin : \n"); hello();

正弦定理的博客 953

AI摄影师:自动构图与修图算法设计

AI摄影师:自动构图与修图算法设计​ ,人工智能,计算机视觉,大模型,AI,AI 摄影师的核心能力体现在两方面:自动构图(通过算法优化画面元素布局)与智能修图(自动调整光影、色彩、细节)。例如,手机摄影中的 “AI 构图建议” 功能可实时框选最佳拍摄区域,修图软件中的 “一键增强” 能在 0.1 秒内完成专业级调色,这些都依赖于计算机视觉与深度学习的深度融合。

不踩坑,不知道坑有多深;不总结,踩过的坑白踩。 16万+

Linux复习之动态库的建立与使用

动态库又被称作共享库,编译时链接动态库,但是不加载目标代码,只有在运行时才加载相关的目标代码到内存,进程结束时自动释放所占内存。 动态库的建立 还是以排序函数sort.c与bank.h为例: 1.编辑sort.c与bank.h文件 2.生成sort.o文件 指令:gcc -c -fpic sort.c 选项-fpic的作用是将源文件编译成带有PIC标志的目标文件 3.将文件加入到动态库中 gcc -shared xxxxx.o yyyy.o -o libxxx.so 动态库的使用 和静态库一样,动态

mlc741295821的博客 201

用playwright封装一个处理web网页的爬虫,并隐藏自动化特征,自动处理反爬

本文介绍了一个使用Playwright封装的Python爬虫函数,具备反爬对抗能力。该脚本通过移除自动化标志、注入真实用户代理、禁用Chrome自动化属性等措施,有效绕过电商、新闻等中等反爬网站的检测。核心功能包括:隐藏navigator.webdriver标志、模拟人类浏览行为、设置合理的设备参数,并支持代理和延迟加载。使用时需注意避免高频访问并定期更新User-Agent。该方案适用于需要JavaScript渲染的动态网页,性能优于非无头模式。

数据知道的博客 3402

基于逆向工程的中国裁判文书网爬虫技术深度解析:从反爬破解到合规抓取

最近承接了一个法律大数据分析的项目,需要获取某类合同纠纷的裁判文书数据,用于分析不同地区的判决规律、法官的裁判倾向以及法条适用情况。原本以为用常规的Python爬虫就能搞定,结果刚对着中国裁判文书网发了几个请求,就遭遇了“滑铁卢”:要么请求直接返回403 Forbidden,要么触发滑块验证码,甚至连IP都被临时封禁了。普通的requests+BeautifulSoup组合在裁判文书网面前完全失效,这也让我意识到,想要获取这里的数据,必须先通过逆向工程拆解网站的请求逻辑和反爬机制。经过一周的摸索,从抓包分析

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 3176

linux gcc 编译的so文件 运行时无法找到 错误:cannot open shared object file: No such file or directory

解决方法: 执行 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. 表示把当前目录加入到动态链接库查找的目录中去重新运行 成功! 上述方法设置是临时的 另外一种方法: sudo vim /etc/ld.so.conf 添加库路径 如 ./ (表示当前目录)或者 so文件所在路径 添加保存后运行 sudo ldconfig ...

qq_19393857的博客 3323

LLM制造业最佳实践:基于大语言模型处理最优化问题,制造业如何更优排产,提升资源利用率

随着制造业数字化转型加速,生产排产优化成为提升企业效率和竞争力的关键环节。大语言模型(LLM)凭借其强大的多模态数据处理、动态优化和智能推理能力,在复杂排产场景中展现出独特优势。谷歌、DeepSeek等机构的研究表明,LLM可通过自然语言交互和生成式决策,突破传统优化算法的局限性。本报告结合半导体行业实践案例与技术路径,系统分析LLM在排产优化中的应用潜力与挑战。

shiter编写程序的艺术 948

Linux下动态库的建立

昨天我们讨论了Linux下静态库的建立和使用,今天我们将讲述一下动态库的建立和使用     首先还是说一下规则                                    动态库的创建:                                                           gcc  -shared –fPIC –o 库名.so 源文件.c      

goodman_lqifei的博客 619

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

linux 动态库建立,浅析linux下静态库和动态库的建立和使用

在粤嵌学了很多知识,我们把常用的公用函数放在一起做成一个函数库,可以供其他程序共同使用,函数库本质上说,是一个可执行代码的二进制形式,可被操作系统载入内存执行。linux下的库分为两种:静态库,后缀名为.a和动态库后缀名为.so(共享库);两者的区别是:静态库和动态库被载入应用程序的时刻不同,调用静态库函数的应用程序在编译时,会把静态库的代码链接到目标代码中(也就是应用程序的代码中),因此程序所占...

weixin_42165583的博客 180

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

Linux操作系统3-文件与IO操作5(动态库与静态库的建立与加载)

C/C++中静态库和动态库的打包与使用

yzc的博客 831

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Linux的静态库与动态库的建立

Linux编译器的内部实现过程

被无情调岗的痛苦狗头 544

Linux下.so动态库的建立和调用

我在这里介绍如何在环境中创建共享库 (shared library)。共享库以so为后缀(shared object)。共享库与Windows下的DLL类似,是在程序运行时动态连接。多个进程可以连接同一个共享库。 实现将一个自己编写的Hello.c文件打包成libHello.so动态库,并通过gcc编译工具实现用一个test.c程序调用libHello.so和自定义头文件Hello.h的过程。 具体程序代码如下: //Hello.h文件 #include <stdio.h> void print

墨染锦年的博客 1292

linux makefile建立动态库,makefile编译动态库

加载编译第三方动态库头文件的时候提示找不到头文件的解决方法:1、修改环境变量:C_INCLUDE_PATH=头文件目录2、在编译的时候使用-I属性 -I/usr/local/include在加载编译第三方动态库以及运行的时候找不到动态库的解决方法:1、vi /etc/ld.so.conf添加动态库目录比如/usr/local/lib2、在/etc/ld.so.conf.d/目录下添加一个自己的*....

weixin_40009472的博客 830

linux下静态库和动态库的建立及使用

静态库的制作: 1 将.c文件编译成.o文件 gcc -c fun1.c fun2.c 2 使用ar命令将.o文件打包成.a文件 ar rcs libtest1.a fun1.o fun2.o 静态库的使用: 1 main.c与head.h和libtest1.a在同一级目录的情况 gcc -o main1 main.c -I./ -L./ -ltest1 2 main.c与head.h和libtest1.a在不同一级目录的情况 gcc -o main1 main.c -I./include -L./lib

weixin_50134791的博客 158

linux makefile建立动态库,如何在linux中使用我自己的动态库(Makefile)

我有一个为linux设计的c项目(g / raw Makefile),我曾经静态地链接了所有工作正常的东西.现在我想构建静态和动态链接的二进制文件.我的Makefile中使用以下命令来构建动态库(比如libtest):$(CXX)-shared -Wl,-soname,libtest.so.1 -o libtest.so.1.0.0 $(LIBTEST_OBJS)输出是libtest.so.1.0...

weixin_39980917的博客 496

Linux 静态库 和 动态库 的建立

3/11 gcc -Wall hello.c 显示所有警告 库文件:存放函数和变量的仓库,特点:只能使用库里的函数和变量,不能看到其实现 静态库.a:当使用静态库时,库里的函数和变量只在编译时加载到可执行文件 动态库.so:当使用动态库时,库里函数和变量只在运行时加载到可执行文件的; 可执行文件:静态库>动态库(静态库效率高) 可执行文件速度:静态库>动态库 可执行文件的功能升级:静态库<动态库 可执行文件的代码部署:静态库 >动态库 linux库放在lib文件夹 “”当前目录下

m0_48507061的博客 131

Linux 静态库与动态库建立与使用

静态库建立 ar rcs libadd.a add.c 静态库使用 gcc -o test test.c -L/ -ladd 或者 gcc -o test test.c ./libadd.a 动态库建立 gcc -fpic -shared -o libaddfunc.so addfunc.c 动态库静态调用: 1、将动态库置入库加载环境变量中:

shenhuax的专栏 608

Linux动态库和静态库的建立及使用方法

<br />和Windows系统一样Linux也有静态/动态链接库,下面介绍创建和使用方法:<br />假设有下面几个文件:<br />头文件String.h,声明相关函数原形,内容如下:<br /><br />Strlen.c:函数Strlen的实现,获取给定字符串的长度,内容如下:<br /><br />Strlnen.c:函数StrNlen的实现,获取给定字符串的长度,如果输入字符串的长度大于指定的最大长度,则返回最大长度,否者返回字符串的实际长度,内容如下:<br />生成静态库:<br />利用G

LEE的专栏 1463

linux学习笔记4(静态库和动态库建立)附windows动态库建立

静态库建立和使用步骤 现在有四个cpp文件,四个文件分别存放了加减乘除四种运算的函数,并且有一个头文件如下 #include <iostream> using namespace std; int add(int, int); int sub(int, int); int mul(int, int); int div(int, int); 第一步:将四个cpp文件转换成二进...

qq_34489443的博客 234

关于linux的动态库想要正常使用是否需要重新建立符号链接的一般讨论

符号链接和动态库配置是所有 Linux 系统的通用操作,并不特定于银河麒麟。但是由于银河麒麟的定制路径或软件兼容性,动态库符号链接和路径配置可能需要你更加注意。如果问题确实与银河麒麟有关,可以查看其文档或联系其技术支持。

抟土成人祖,炼石补青天。眼中览银河,手可摘星辰。 916
上一篇: HC-SR04超声波测距 - 树莓派3B
下一篇: 自己写strcpy函数
四夕、
博客等级 码龄8年 19粉丝 39原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值