|-|-x-4|=|x-4|-|x 4|=e=c/a=4/20

已知ax+bx的2次方+cx的3次方+dx的4次方+e=(x-20)的4次方,那么a+b+c+d+e等于几,a+b+c又等于几?????_百度知道已只函数y=x+4的图象于y轴交于点A,函数y=-3x-6的图象与x轴交于点B,两个函数的图象交于点C,求通过线段AB的中点即点C的一次函数的解析式.(写出计算过程)题目中我少写了 最后一句应改为:求通过线段A,B的中点D,及点C的一次函数的解析式 (呵呵不好意思~) 本人关键不会求A,B的中点D的坐标 (由于本人的失误给大家带来众多并不便``~`)
盖纸292082
在y=x+4与y轴交点A,A为(0,4),B为(-2,0)C为(-2.5,1.5),给你两点连线中点公式:两点为:(x1,y1),(x2,y2),中点为(x,y),x=(x1+x2)/2,y=(y1+y2)/2,现在代入A,B,D点为(-1,2).解析式为:y=x/3+7/3
为您推荐:
其他类似问题
设A,B的中点D的坐标为(x,y)因a=(0,4)
b=(-2,0)所以x=1/2*(-2)=-1
y=1/2*4=2所以d=(-1,2)因为c=(-3,1)所以Lcd:y=1/2x+5/2y
连理y=x+4和y=-3x-6
解得x=-5/2
把x带入任意式子解y得y=3/2
所以c (-5/2,3/2)求D:
AB与坐标轴成等腰直角三角形,直角边长为4,做中位线两条,根据中位线性质,求出D(-2,2)
我不知道我做得对不对,应该是这样吧
容易求得A(0,4),B(2,0)
在直角三角行AOB中,AO=4,BO=2,
过D点作DE平行BO交y轴于E,作D平行AO交x轴于F
可以证明E,F分别为AO,BO之中点,
所以D(1,2),且C(5,9)
可得过线段A,B的中点D,及点C的一次函数的解析式为y=1.75x+0.25
扫描下载二维码当前位置:
>>>如图平面直角坐标系中,抛物线y=-x2+x+2交x轴于A、B两点,交y轴于..
如图平面直角坐标系中,抛物线y=-x2+x+2 交x轴于A、B两点,交y轴于点C.(1)求证:△ABC为直角三角形;(2)直线x=m(0<m<4)在线段OB上移动,交x轴于点D,交抛物线于点E,交BC于点F.求当m为何值时,EF=DF?(3)连接CE和BE后,对于问题“是否存在这样的点E,使△BCE的面积最大?”小红同学认为:“当E为抛物线的顶点时,△BCE的面积最大”。她的观点是否正确?提出你的见解,若△BCE的面积存在最大值,请求出点E的坐标和△BCE的最大面积.
题型:解答题难度:偏难来源:河南省期末题
解: (1)对于y=-x2+x+2当y=0时, y=-x2+x+2=0, 解得x1=-1, x2=4当x=0时, y=2 ∴A、B、C三点的坐标分别为 A(-1,0),B(4,0),C(0,2)∴OA=1,OB= 4,OC=2, ∴AB=OA+OB=5,∴AB2=25在Rt△AOC中,AC2=OA2+OC2=12+22=5 在Rt△COB中,BC2=OC2+OB2=22+42=20 ∴AC2+BC2=AB2 ∴△ABC是以∠ACB为直角的直角三角形。(2)解:∵直线DE的解析式为直线x=m,∴OD= m,DE⊥OB∵OC⊥AB,∴OC∥DE,∴△BDE∽△BOC& ∴∵OC=2,OB=4,BD=OB-OD=4-m,∴DF=当EF=DF时,DE=2DF=4-m,∴E点的坐标为(m, 4-m)∵E点在抛物线解得m1=1,m2=4. ∵0<m<4,∴m2=4舍去, ∴当m=1时,EF=DF (3)解:小红同学的观点是错误的∵OD= m, DE⊥OB, E点在抛物线∴E点的坐标可表示为∴DE=-m2+m+2& ∵DF=2-m,∴EF=DE-DF=-m 2+2m ∵S△BCE=S△CEF+S△BEF= EF·OD+ EF·BD= EF·(OD+BD) =EF·OB= EF·4=2EF ∴S△BCE=-m 2+4m=-(m2-4m+4-4)=-(m-2)2+4∴当m=2时, S△BCE有最大值,△BCE的最大面积为4∵当m=2时,-m 2+m+2=3,∴E点的坐标为(2, 3)而抛物线y=-x2+x+2的顶点坐标为( ,),∴小红同学的观点是错误的 。
马上分享给同学
据魔方格专家权威分析,试题“如图平面直角坐标系中,抛物线y=-x2+x+2交x轴于A、B两点,交y轴于..”主要考查你对&&求二次函数的解析式及二次函数的应用,二次函数的最大值和最小值,直角三角形的性质及判定,相似三角形的性质&&等考点的理解。关于这些考点的“档案”如下:
现在没空?点击收藏,以后再看。
因为篇幅有限,只列出部分考点,详细请访问。
求二次函数的解析式及二次函数的应用二次函数的最大值和最小值直角三角形的性质及判定相似三角形的性质
求二次函数的解析式:最常用的方法是待定系数法,根据题目的特点,选择恰当的形式,一般,有如下几种情况: (1)已知抛物线上三点的坐标,一般选用一般式; (2)已知抛物线顶点或对称轴或最大(小)值,一般选用顶点式; (3)已知抛物线与x轴的两个交点的横坐标,一般选用两点式; (4)已知抛物线上纵坐标相同的两点,常选用顶点式。 二次函数的应用:(1)应用二次函数才解决实际问题的一般思路: 理解题意;建立数学模型;解决题目提出的问题。 (2)应用二次函数求实际问题中的最值: 即解二次函数最值应用题,设法把关于最值的实际问题转化为二次函数的最值问题,然后按求二次函数最值的方法求解。求最值时,要注意求得答案要符合实际问题。 二次函数的三种表达形式:①一般式:y=ax2+bx+c(a≠0,a、b、c为常数),顶点坐标为 [,]把三个点代入函数解析式得出一个三元一次方程组,就能解出a、b、c的值。
②顶点式:y=a(x-h)2+k(a≠0,a、h、k为常数),顶点坐标为对称轴为直线x=h,顶点的位置特征和图像的开口方向与函数y=ax2的图像相同,当x=h时,y最值=k。有时题目会指出让你用配方法把一般式化成顶点式。例:已知二次函数y的顶点(1,2)和另一任意点(3,10),求y的解析式。解:设y=a(x-1)2+2,把(3,10)代入上式,解得y=2(x-1)2+2。注意:与点在平面直角坐标系中的平移不同,二次函数平移后的顶点式中,h&0时,h越大,图像的对称轴离y轴越远,且在x轴正方向上,不能因h前是负号就简单地认为是向左平移。具体可分为下面几种情况:当h&0时,y=a(x-h)2的图象可由抛物线y=ax2向右平行移动h个单位得到;当h&0时,y=a(x-h)2的图象可由抛物线y=ax2向左平行移动|h|个单位得到;当h&0,k&0时,将抛物线y=ax2向右平行移动h个单位,再向上移动k个单位,就可以得到y=a(x-h)2+k的图象;当h&0,k&0时,将抛物线y=ax2向右平行移动h个单位,再向下移动|k|个单位可得到y=a(x-h)2+k的图象;当h&0,k&0时,将抛物线y=ax2向左平行移动|h|个单位,再向上移动k个单位可得到y=a(x-h)2+k的图象;当h&0,k&0时,将抛物线y=ax2向左平行移动|h|个单位,再向下移动|k|个单位可得到y=a(x-h)2+k的图象。
③交点式:y=a(x-x1)(x-x2) (a≠0) [仅限于与x轴即y=0有交点时的抛物线,即b2-4ac≥0] .已知抛物线与x轴即y=0有交点A(x1,0)和 B(x2,0),我们可设y=a(x-x1)(x-x2),然后把第三点代入x、y中便可求出a。由一般式变为交点式的步骤:二次函数∵x1+x2=-b/a, x1?x2=c/a(由韦达定理得),∴y=ax2+bx+c=a(x2+b/ax+c/a)=a[x2-(x1+x2)x+x1?x2]=a(x-x1)(x-x2).重要概念:a,b,c为常数,a≠0,且a决定函数的开口方向。a&0时,开口方向向上;a&0时,开口方向向下。a的绝对值可以决定开口大小。a的绝对值越大开口就越小,a的绝对值越小开口就越大。能灵活运用这三种方式求二次函数的解析式;能熟练地运用二次函数在几何领域中的应用;能熟练地运用二次函数解决实际问题。二次函数的其他表达形式:①牛顿插值公式:f(x)=f[x0]+f[x0,x1](x-x0)+f[x0,x1,x2](x-x0)(x-x1)+...f[x0,...xn](x-x0)...(x-xn-1)+Rn(x)由此可引导出交点式的系数a=y/(x·x)(y为截距) 二次函数表达式的右边通常为二次三项式。双根式y=a(x-x1)*(x-x2)若ax2+bx+c=0有两个实根x1,x2,则y=a(x-x1)(x-x2)此抛物线的对称轴为直线x=(x1+x2)/2。③三点式已知二次函数上三个点,(x1,f(x1))(x2,f(x2))(x3,f(x3))则f(x)=f(x3)(x-x1)(x-x2)/(x3-x1)(x3-x2)+f(x2)(x-x1)*(x-x3)/(x2-x1)(x2-x3)+f(x1)(x-x2)(x-x3)/(x1-x2)(x1-x3)与X轴交点的情况当△=b2-4ac&0时,函数图像与x轴有两个交点。(x1,0), (x2,0);当△=b2-4ac=0时,函数图像与x轴只有一个交点。(-b/2a,0)。Δ=b2-4ac&0时,抛物线与x轴没有交点。X的取值是虚数(x=-b±√b2-4ac的值的相反数,乘上虚数i,整个式子除以2a)二次函数解释式的求法:就一般式y=ax2+bx+c(其中a,b,c为常数,且a≠0)而言,其中含有三个待定的系数a ,b ,c.求二次函数的一般式时,必须要有三个独立的定量条件,来建立关于a ,b ,c 的方程,联立求解,再把求出的a ,b ,c 的值反代回原函数解析式,即可得到所求的二次函数解析式。
1.巧取交点式法:知识归纳:二次函数交点式:y=a(x-x1)(x-x2) (a≠0)x1,x2分别是抛物线与x轴两个交点的横坐标。已知抛物线与x轴两个交点的横坐标求二次函数解析式时,用交点式比较简便。①典型例题一:告诉抛物线与x轴的两个交点的横坐标,和第三个点,可求出函数的交点式。例:已知抛物线与x轴交点的横坐标为-2和1 ,且通过点(2,8),求二次函数的解析式。点拨:解设函数的解析式为y=a(x+2)(x-1),∵过点(2,8),∴8=a(2+2)(2-1)。解得a=2,∴抛物线的解析式为:y=2(x+2)(x-1),即y=2x2+2x-4。②典型例题二:告诉抛物线与x轴的两个交点之间的距离和对称轴,可利用抛物线的对称性求解。例:已知二次函数的顶点坐标为(3,-2),并且图象与x轴两交点间的距离为4,求二次函数的解析式。点拨:在已知抛物线与x轴两交点的距离和顶点坐标的情况下,问题比较容易解决.由顶点坐标为(3,-2)的条件,易知其对称轴为x=3,再利用抛物线的对称性,可知图象与x轴两交点的坐标分别为(1,0)和(5,0)。此时,可使用二次函数的交点式,得出函数解析式。
2.巧用顶点式:顶点式y=a(x-h)2+k(a≠0),其中(h,k)是抛物线的顶点。当已知抛物线顶点坐标或对称轴,或能够先求出抛物线顶点时,设顶点式解题十分简洁,因为其中只有一个未知数a。在此类问题中,常和对称轴,最大值或最小值结合起来命题。在应用题中,涉及到桥拱、隧道、弹道曲线、投篮等问题时,一般用顶点式方便.①典型例题一:告诉顶点坐标和另一个点的坐标,直接可以解出函数顶点式。例:已知抛物线的顶点坐标为(-1,-2),且通过点(1,10),求此二次函数的解析式。点拨:解∵顶点坐标为(-1,-2),故设二次函数解析式为y=a(x+1)2-2 (a≠0)。把点(1,10)代入上式,得10=a·(1+1)2-2。∴a=3。∴二次函数的解析式为y=3(x+1)2-2,即y=3x2+6x+1。②典型例题二:如果a&0,那么当 时,y有最小值且y最小=;如果a&0,那么,当时,y有最大值,且y最大=。告诉最大值或最小值,实际上也是告诉了顶点坐标,同样也可以求出顶点式。例:已知二次函数当x=4时有最小值-3,且它的图象与x轴两交点间的距离为6,求这个二次函数的解析式。点拨:析解∵二次函数当x=4时有最小值-3,∴顶点坐标为(4,-3),对称轴为直线x=4,抛物线开口向上。由于图象与x轴两交点间的距离为6,根据图象的对称性就可以得到图象与x轴两交点的坐标是(1,0)和(7,0)。∴抛物线的顶点为(4,-3)且过点(1,0)。故可设函数解析式为y=a(x-4)2-3。将(1,0)代入得0=a(1-4)2-3, 解得a=13.∴y=13(x-4)2-3,即y=13x2-83x+73。③典型例题三:告诉对称轴,相当于告诉了顶点的横坐标,综合其他条件,也可解出。例如:(1)已知二次函数的图象经过点A(3,-2)和B(1,0),且对称轴是直线x=3.求这个二次函数的解析式. (2)已知关于x的二次函数图象的对称轴是直线x=1,图象交y轴于点(0,2),且过点(-1,0),求这个二次函数的解析式. (3)已知抛物线的对称轴为直线x=2,且通过点(1,4)和点(5,0),求此抛物线的解析式. (4)二次函数的图象的对称轴x=-4,且过原点,它的顶点到x轴的距离为4,求此函数的解析式.④典型例题四:利用函数的顶点式,解图像的平移等问题非常方便。例:把抛物线y=ax2+bx+c的图像向右平移3 个单位, 再向下平移2 个单位, 所得图像的解析式是y=x2-3x+5, 则函数的解析式为_______。点拨:解先将y=x2-3x+5化为y=(x-32)2+5-94, 即y=(x-32)2+114。∵它是由抛物线的图像向右平移3 个单位, 再向下平移2 个单位得到的,∴原抛物线的解析式是y=(x-32+3)2+114+2=(x+32)2+194=x2+3x+7。二次函数的最值:1.如果自变量的取值范围是全体实数,则当a&0时,抛物线开口向上,有最低点,那么函数在处取得最小值y最小值=;当a&0时,抛物线开口向下,有最高点,即当时,函数取得最大值,y最大值=。 也即是:如果自变量的取值范围是全体实数,那么函数在顶点处取得最大值(或最小值),即当时,。2.如果自变量的取值范围是,那么,首先要看是否在自变量取值范围内,若在此范围内,则当x=时,;若不在此范围内,则需要考虑函数在范围内的增减性,如果在此范围内,y随x的增大而增大,则当x=x2 时,,当x=x1 时;如果在此范围内,y随x的增大而减小,则当x=x1时,,当x=x2时&。 直角三角形定义:有一个角为90°的三角形,叫做直角三角形。直角三角形可用Rt△表示,如直角三角形ABC写作Rt△ABC。 直角三角形性质:直角三角形是一种特殊的三角形,它除了具有一般三角形的性质外,具有一些特殊的性质:性质1:直角三角形两直角边a,b的平方和等于斜边c的平方。即。如图,∠BAC=90°,则AB2+AC2=BC2(勾股定理)性质2:在直角三角形中,两个锐角互余。如图,若∠BAC=90°,则∠B+∠C=90°性质3:在直角三角形中,斜边上的中线等于斜边的一半(即直角三角形的外心位于斜边的中点,外接圆半径R=C/2)。性质4:直角三角形的两直角边的乘积等于斜边与斜边上高的乘积。性质5:如图,Rt△ABC中,∠BAC=90°,AD是斜边BC上的高,则有射影定理如下:(1)(AD)2=BD·DC。(2)(AB)2=BD·BC。(3)(AC)2=CD·BC。性质6:在直角三角形中,如果有一个锐角等于30°,那么它所对的直角边等于斜边的一半。在直角三角形中,如果有一条直角边等于斜边的一半,那么这条直角边所对的锐角等于30°。性质7:如图,1/AB2+1/AC2=1/AD2性质8:直角三角形被斜边上的高分成的两个直角三角形和原三角形相似。性质9:直角三角形直角上的角平分线与斜边的交点D 则&&& BD:DC=AB:AC直角三角形的判定方法:判定1:定义,有一个角为90°的三角形是直角三角形。判定2:判定定理:以a、b、c为边的三角形是以c为斜边的直角三角形。如果三角形的三边a,b,c满足,那么这个三角形就是直角三角形。(勾股定理的逆定理)。判定3:若一个三角形30°内角所对的边是某一边的一半,则这个三角形是以这条长边为斜边的直角三角形。判定4:两个锐角互为余角(两角相加等于90°)的三角形是直角三角形。判定5:若两直线相交且它们的斜率之积互为负倒数,则两直线互相垂直。那么判定6:若在一个三角形中一边上的中线等于其所在边的一半,那么这个三角形为直角三角形。判定7:一个三角形30°角所对的边等于这个三角形斜边的一半,则这个三角形为直角三角形。(与判定3不同,此定理用于已知斜边的三角形。)相似三角形性质定理:(1)相似三角形的对应角相等。(2)相似三角形的对应边成比例。(3)相似三角形的对应高线的比,对应中线的比和对应角平分线的比都等于相似比。(4)相似三角形的周长比等于相似比。(5)相似三角形的面积比等于相似比的平方。(6)相似三角形内切圆、外接圆直径比和周长比都和相似比相同,内切圆、外接圆面积比是相似比的平方(7)若a/b =b/c,即b2=ac,b叫做a,c的比例中项(8)c/d=a/b 等同于ad=bc.(9)不必是在同一平面内的三角形里①相似三角形对应角相等,对应边成比例.②相似三角形对应高的比,对应中线的比和对应角平分线的比都等于相似比.③相似三角形周长的比等于相似比
定理推论:推论一:顶角或底角相等的两个等腰三角形相似。推论二:腰和底对应成比例的两个等腰三角形相似。推论三:有一个锐角相等的两个直角三角形相似。推论四:直角三角形被斜边上的高分成的两个直角三角形和原三角形都相似。推论五:如果一个三角形的两边和其中一边上的中线与另一个三角形的对应部分成比例,那么这两个三角形相似。推论六:如果一个三角形的两边和第三边上的中线与另一个三角形的对应部分成比例,那么这两个三角形相似。
发现相似题
与“如图平面直角坐标系中,抛物线y=-x2+x+2交x轴于A、B两点,交y轴于..”考查相似的试题有:
919162908452550786311197893096921560C H A P T E R
4 - Libraries
C H A P T E R
This chapter describes how to use and create libraries of subprograms. Both static and dynamic libraries are discussed.
A software library is usually a set of subprograms that have been previously compiled and organized into a single binary library file. Each member of the set is called a library element or module. The linker searches the library files, loading object modules referenced by the user program while building the executable binary program. See ld(1) and the Solaris Linker and Libraries Guide for details.
There are two basic kinds of software libraries:
Static library. A library in which modules are bound into the executable file before execution. Static libraries are commonly named libname.a. The .a suffix refers to archive.
Dynamic library. A library in which modules can be bound into the executable program at runtime. Dynamic libraries are commonly named libname.so. The .so suffix refers to shared object.
Typical system libraries that have both static (.a) and dynamic (.so) versions are:
Fortran 95 libraries: libfsu, libfui, libfai, libfai2, libfsumai, libfprodai, libfminlai, libfmaxlai, libminvai, libmaxvai, libifai, libf77compat
C libraries: libc
There are two advantages to the use of libraries:
There is no need to have source code for the library routines that a program calls.
Only the needed modules are loaded.
Library files provide an easy way for programs to share commonly used subroutines. You need only name the library when linking the program, and those library modules that resolve references in the program are linked and merged into the executable file.
Summary information about library usage and loading can be obtained by passing additional options to the linker through the LD_OPTIONS environment variable. The compiler calls the linker with these options (and others it requires) when generating object binary files.
Using the compiler to call the linker is always recommended over calling the linker directly because many compiler options require specific linker options or library references, and linking without these could produce unpredictable results.
Example: Using LD_OPTIONS to create a load map:
demo% setenv LD_OPTIONS '-m -Dfiles'
demo% f95 -o myprog myprog.f
Some linker options do have compiler command-line equivalents that can appear directly on the f95 command. These include -Bx, -dx, -G, -hname, -Rpath, and -ztext. See the f95(1) man pages or the Fortran User's Guide for details.
More detailed examples and explanations of linker options and environment variables can be found in the Solaris Linker and Libraries Guide.
The linker -m option generates a load map that displays library linking information. The routines linked during the building of the executable binary program are listed together with the libraries that they come from.
Example: Using -m to generate a load map:
demo% setenv LD_OPTIONS '-m'
demo% f95 any.f
LINK EDITOR MEMORY MAP
.interp 100d4
2e8 (null)
.dynsym 103d0
650 (null)
.dynstr 10a20
366 (null)
00 /opt/SUNWspro/lib/crti.o
f4 /opt/SUNWspro/lib/crt1.o
00 /opt/SUNWspro/lib/values-xi.o
d20 sparse.o
Additional linker debugging features are available through the linker's -Dkeyword option. A complete list can be displayed using -Dhelp.
Example: List linker debugging aid options using the -Dhelp option:
demo% ld -Dhelp
debug: args
display input argument processing
debug: bindings
debug: detail
provide more information
debug: entry
display entrance criteria descriptors
For example, the -Dfiles linker option lists all the files and libraries referenced during the link process:
demo% setenv LD_OPTIONS '-Dfiles'
demo% f95 direct.f
MAIN direct:
debug: file=/opt/SUNWspro/lib/crti.o
[ ET_REL ]
debug: file=/opt/SUNWspro/lib/crt1.o
[ ET_REL ]
debug: file=/opt/SUNWspro/lib/values-xi.o
[ ET_REL ]
debug: file=direct.o
[ ET_REL ]
debug: file=/opt/SUNWspro/lib/libM77.a
[ archive ]
debug: file=/opt/SUNWspro/lib/libF77.so
[ ET_DYN ]
debug: file=/opt/SUNWspro/lib/libsunmath.a
[ archive ]
See the Linker and Libraries Guide for further information on these linker options.
Ensuring a consistent choice of compiling and linking options is critical whenever compilation and linking are done in separate steps. Compiling any part of a program with some options requires linking with the same options. Also, a number of options require that all source files be compiled with that option, including the link step.
The option descriptions in the Fortran User's Guide identify such options.
Example: Compiling sbr.f with -fast, compiling a C routine, and then linking in a separate step:
demo% f95 -c -fast sbr.f
demo% cc -c -fast simm.c
demo% f95 -fast sbr.o simm.o
to the linker
The linker searches for libraries at several locations and in a certain prescribed order. Some of these locations are standard paths, while others depend on the compiler options -Rpath, -llibrary, and -Ldir and the environment variable LD_LIBRARY_PATH.
The standard library search paths used by the linker are determined by the installation path, and they differ for static and dynamic loading. A standard install puts the Sun Studio compiler software under /opt/SUNWspro/.
While building the executable file, the static linker searches for any libraries in the following paths (among others), in the specified order:
/opt/SUNWspro/lib
Sun Studio shared libraries
/usr/ccs/lib/
Standard location for SVr4 software
Standard location for UNIX software
These are the default paths used by the linker.
The dynamic linker searches for shared libraries at runtime, in the specified order:
Paths specified by user with -Rpath
/opt/SUNWspro/lib/
/usr/lib standard UNIX default
The search paths are built into the executable.
Use the LD_LIBRARY_PATH environment variable to specify directory paths that the linker should search for libraries specified with the -llibrary option.
Multiple directories can be specified, separated by a colon. Typically, the LD_LIBRARY_PATH variable contains two lists of colon-separated directories separated by a semicolon:
dirlist1;dirlist2
The directories in dirlist1 are searched first, followed by any explicit -Ldir directories specified on the command line, followed by dirlist2 and the standard directories.
That is, if the compiler is called with any number of occurrences of -L, as in:
f95 ... -Lpath1 ... -Lpathn ...
then the search order is:
dirlist1 path1 ... pathn dirlist2 standard_paths
When the LD_LIBRARY_PATH variable contains only one colon-separated list of directories, it is interpreted as dirlist2.
In the Solaris operating environment, a similar environment variable, LD_LIBRARY_PATH_64 can be used to override LD_LIBRARY_PATH when searching for 64-bit dependencies. See the Solaris Linker and Libraries Guide and the ld(1) man page for details.
On a 32-bit SPARC processor, LD_LIBRARY_PATH_64 is ignored.
If only LD_LIBRARY_PATH is defined, it is used for both 32-bit and 64-bit linking.
If both LD_LIBRARY_PATH and LD_LIBRARY_PATH_64 are defined, 32-bit linking will be done using LD_LIBRARY_PATH, and 64-bit linking with LD_LIBRARY_PATH_64.
Note - Use of the LD_LIBRARY_PATH environment variable with production software is strongly discouraged. Although useful as a temporary mechanism for influencing the runtime linker's search path, any dynamic executable that can reference this environment variable will have its search paths altered. You might see unexpected results or a degradation in performance.
Use the -llibrary compiler option to name additional libraries for the linker to search when resolving external references. For example, the option -lmylib adds the library libmylib.so or libmylib.a to the search list.
The linker looks in the standard directory paths to find the additional libmylib library. The -L option (and the LD_LIBRARY_PATH environment variable) creates a list of paths that tell the linker where to look for libraries outside the standard paths.
Were libmylib.a in directory /home/proj/libs, then the option
-L/home/proj/libs would tell the linker where to look when building the executable:
demo% f95 -o pgram part1.o part2.o -L/home/proj/libs -lmylib
For any particular unresolved reference, libraries are searched only once, and only for symbols that are undefined at that point in the search. If you list more than one library on the command line, then the libraries are searched in the order in which they are found on the command line. Place -llibrary options as follows:
Place the -llibrary option after any .f, .for, .F, .f95, or .o files.
If you call functions in libx, and they reference functions in liby, then place -lx before -ly.
The -Ldir option adds the dir directory path to the library search list. The linker searches for libraries first in any directories specified by the -L options and then in the standard directories. This option is useful only if it is placed preceding the
-llibrary options to which it applies.
With dynamic libraries, changing the library search path and order of loading differs from the static case. Actual linking takes place at runtime rather than build time.
When building the executable file, the linker records the paths to shared libraries in the executable itself. These search paths can be specified using the -Rpath option. This is in contrast to the -Ldir option which indicates at buildtime where to find the library specified by a -llibrary option, but does not record this path into the binary executable.
The directory paths that were built in when the executable was created can be viewed using the dump command.
Example: List the directory paths built into a.out:
demo% f95 program.f -R/home/proj/libs -L/home/proj/libs -lmylib
demo% dump -Lv a.out | grep RPATH
/home/proj/libs:/opt/SUNWspro/lib
At runtime, the linker determines where to find the dynamic libraries that an executable needs from:
The value of LD_LIBRARY_PATH at runtime
The paths that had been specified by -R at the time the executable file was built
As noted earlier, use of LD_LIBRARY_PATH can have unexpected side-effects and is not recommended.
When the dynamic linker cannot locate a needed library, it issues this error message:
ld.so: prog: fatal: libmylib.so: can't open file:
The message indicates that the libraries are not where they are supposed to be. Perhaps you specified paths to shared libraries when the executable was built, but the libraries have subsequently been moved. For example, you might have built a.out with your own dynamic libraries in /my/libs/, and then later moved the libraries to another directory.
Use ldd to determine where the executable expects to find the libraries:
demo% ldd a.out
libfui.so.1 =&
/opt/SUNWspro/lib/libfui.so.1
libfai.so.1 =&
/opt/SUNWspro/lib/libfai.so.1
libfai2.so.1 =&
/opt/SUNWspro/lib/libfai2.so.1
libfsumai.so.1 =&
/opt/SUNWspro/lib/libfsumai.so.1
libfprodai.so.1 =&
/opt/SUNWspro/lib/libfprodai.so.1
libfminlai.so.1 =&
/opt/SUNWspro/lib/libfminlai.so.1
libfmaxlai.so.1 =&
/opt/SUNWspro/lib/libfmaxlai.so.1
libfminvai.so.1 =&
/opt/SUNWspro/lib/libfminvai.so.1
libfmaxvai.so.1 =&
/opt/SUNWspro/lib/libfmaxvai.so.1
libfsu.so.1 =&
/opt/SUNWspro/lib/libfsu.so.1
libsunmath.so.1 =&
/opt/SUNWspro/lib/libsunmath.so.1
libm.so.1 =&
/usr/lib/libm.so.1
libc.so.1 =&
/usr/lib/libc.so.1
libdl.so.1 =&
/usr/lib/libdl.so.1
/usr/platform/SUNW,Ultra-5_10/lib/libc_psr.so.1
If possible, move or copy the libraries into the proper directory or make a soft link to the directory (using ln -s) in the directory that the linker is searching. Or, it could be that LD_LIBRARY_PATH is not set correctly. Check that LD_LIBRARY_PATH includes the path to the needed libraries at runtime.
Static library files are built from precompiled object files (.o files) using the ar(1) utility.
The linker extracts from the library any elements whose entry points are referenced within the program it is linking, such as a subprogram, entry name, or COMMON block initialized in a BLOCKDATA subprogram. These extracted elements (routines) are bound permanently into the a.out executable file generated by the linker.
There are three main issues to keep in mind regarding static, as compared to dynamic, libraries and linking:
Static libraries are more self-contained but less adaptable.
If you bind an a.out executable file statically, the library routines it needs become part of the executable binary. However, if it becomes necessary to update a static library routine bound into the a.out executable, the entire a.out file must be relinked and regenerated to take advantage of the updated library. With dynamic libraries, the library is not part of the a.out file and linking is done at runtime. To take advantage of an updated dynamic library, all that is required is that the new library be installed on the system.
The &elements& in a static library are individual compilation units, .o files.
Since a single compilation unit (a source file) can contain more than one subprogram, these routines when compiled together become a single module in the static library. This means that all the routines in the compilation unit are loaded together into the a.out executable, even though only one of those subprograms was actually called. This situation can be improved by optimizing the way library routines are distributed into compilable source files. (Still, only those library modules actually referenced by the program are loaded into the executable.)
Order matters when linking static libraries.
The linker processes its input files in the order in which they appear on the command line--left to right. When the linker decides whether or not to load an element from a library, its decision is determined by the library elements that it has already processed. This order is not only dependent on the order of the elements as they appear in the library file but also on the order in which the libraries are specified on the compile command line.
Example: If the Fortran program is in two files, main.f and crunch.f, and only the latter accesses a library, it is an error to reference that library before crunch.f or crunch.o:
demo% f95 main.f -lmylibrary crunch.f -o myprog
(Incorrect)
demo% f95 main.f crunch.f -lmylibrary -o myprog
Suppose that you can distribute all the routines in a program over a group of source files and that these files are wholly contained in the subdirectory test_lib/.
Suppose further that the files are organized in such a way that they each contain a single principal subprogram that would be called by the user program, along with any &helper& routines that the subprogram might call but that are called from no other routine in the library. Also, any helper routines called from more than one library routine are gathered together into a single source file. This gives a reasonably well-organized set of source and object files.
Assume that the name of each source file is taken from the name of the first routine in the file, which in most cases is one of the principal files in the library:
demo% cd test_lib
The lower-level &helper& routines are gathered together into the file etc.f. The other files can contain one or more subprograms.
First, compile each of the library source files, using the -c option, to generate the corresponding relocatable .o files:
demo% f95 -c *.f
Now, create the static library testlib.a using ar:
demo% ar cr testlib.a *.o
To use this library, either include the library file on the compilation command or use the -l and -L compilation options. The example uses the .a file directly:
demo% cat trylib.f
program to test testlib routines
call evalx(x)
call point(x)
print*, 'value ',x
demo% f95 -o trylib trylib.f test_lib/testlib.a
Notice that the main program calls only two of the routines in the library. You can verify that the uncalled routines in the library were not loaded into the executable file by looking for them in the list of names in the executable displayed by nm:
demo% nm trylib | grep FUNC | grep point
152|FUNC |GLOB |0
demo% nm trylib | grep FUNC | grep evalx
152|FUNC |GLOB |0
demo% nm trylib | grep FUNC | grep delte
demo% nm trylib | grep FUNC | grep markx
demo% ..etc
In the preceding example, grep finds entries in the list of names only for those library routines that were actually called.
Another way to reference the library is through the -llibrary and -Lpath options. Here, the library's name would have to be changed to conform to the libname.a convention:
demo% mv test_lib/testlib.a test_lib/libtestlib.a
demo% f95 -o trylib trylib.f -Ltest_lib -ltestlib
The -llibrary and -Lpath options are used with libraries installed in a commonly accessible directory on the system, like /usr/local/lib, so that other users can reference it. For example, if you left libtestlib.a in /usr/local/lib, other users could be informed to compile with the following command:
demo% f95 -o myprog myprog.f -L/usr/local/lib -ltestlib
It is not necessary to recompile an entire library if only a few elements need recompiling. The -r option of ar permits replacement of individual elements in a static library.
Example: Recompile and replace a single routine in a static library:
demo% f95 -c point.f
demo% ar -r testlib.a point.o
To order the elements in a static library when it is being built by ar, use the commands lorder(1) and tsort(1):
demo% ar -cr mylib.a 'lorder exg.o fofx.o diffz.o | tsort'
Dynamic library files are built by the linker ld from precompiled object modules that can be bound into the executable file after execution begins.
Another feature of a dynamic library is that modules can be used by other executing programs in the system without duplicating modules in each program's memory. For this reason, a dynamic library is also a shared library.
A dynamic library offers the following features:
The object modules are not bound into the executable file by the linker during the compile- such binding is deferred until runtime.
A shared library module is bound into system memory when the first running program references it. If any subsequent running program references it, that reference is mapped to this first copy.
Maintaining programs is easier with dynamic libraries. Installing an updated dynamic library on a system immediately affects all the applications that use it without requiring relinking of the executable.
Dynamic libraries introduce some additional tradeoff considerations:
Smaller a.out file
Deferring binding of the library routines until execution time means that the size of the executable file is less than the equivalent executable calling a static ve the executable file does not contain the binaries for the library routines.
Possibly smaller process memory utilization
When several processes using the library are active simultaneously, only one copy of the library resides in memory and is shared by all processes.
Possibly increased overhead
Additional processor time is needed to load and link-edit the library routines during runtime. Also, the library's position-independent coding might execute more slowly than the relocatable coding in a static library.
Possible overall system performance improvement
Reduced memory utilization due to library sharing should result in better overall system performance (reduced I/O access time from memory swapping).
Performance profiles among programs vary greatly from one to another. It is not always possible to determine or estimate in advance the performance improvement (or degradation) between dynamic versus static libraries. However, if both forms of a needed library are available to you, it would be worthwhile to evaluate the performance of your program with each.
Position-independent code (PIC) can be bound to any address in a program without requiring relocation by the link editor. Such code is inherently sharable between simultaneous processes. Thus, if you are building a dynamic, shared library, you must compile the component routines to be position-independent by using the -xcode compiler option.
In position-independent code, each reference to a global item is compiled as a reference through a pointer into a global offset table. Each function call is compiled in a relative addressing mode through a procedure linkage table. The size of the global offset table is limited to 8 Kbytes on SPARC processors.
Use the compiler flag -xcode=v for specifying the code address space of a binary object. With this flag, 32-, 44-, or 64-bit absolute addresses can be generated, as well as small and large model position-independent code. (-xcode=pic13 is equivalent to the legacy -pic flag, and -xcode=pic32 is equivalent to -PIC.)
The -xcode=pic32 compiler option is similar to -xcode=pic13, but allows the global offset table to span the range of 32-bit addresses. See the f95(1) man page or the Fortran User's Guide, for details.
You can specify dynamic or static library binding when you compile. These options are actually linker options, but they are recognized by the compiler and passed on to the linker.
-Bdynamic sets the preference for shared, dynamic binding whenever possible.
-Bstatic restricts binding to static libraries only.
When both static and dynamic versions of a library are available, use this option to toggle between preferences on the command line:
f95 prog.f -Bdynamic -lwells -Bstatic -lsurface
Allows or disallows dynamic linking for the entire executable. (This option may appear on the command line only once.)
-dy allows dynamic, shared libraries to be linked. -dn does not allow linking of dynamic libraries.
Some static system libraries, such as libm.a and libc.a, are not available on 64-bit Solaris operating environments. These are supplied as dynamic libraries only. Use of -dn in these environments will result in an error indicating that some static system libraries are missing. Also, ending the compiler command line with -Bstatic will have the same effect.
To link with static versions of specific libraries, use a command line that looks something like:
f95 -o prog prog.f -Bstatic -labc -lxyz -Bdynamic
Here the user's libabc.a and libxyz.a file are linked (rather than libabc.so or libxyz.so), and the final -Bdynamic insures that the remaining libraries, including system libraries, and dynamically linked.
In more complicated situations, it may be necessary to explicitly reference each system and user library on the link step with the appropriate -Bstatic or -Bdynamic as required. First use LD_OPTIONS set to '-Dfiles' to obtain a listing of all the libraries needed. Then perform the link step with -nolib (to suppress automatic linking of system libraries) and explicit references to the libraries you need. For example:
f95 -xarch=v9 -o cdf -nolib cdf.o -Bstatic -lsunmath \
-Bdynamic -lm -lc
To conform to the dynamic library naming conventions assumed by the link loader and the compilers, assign names to the dynamic libraries that you create with the prefix lib and the suffix .so. For example, libmyfavs.so could be referenced by the compiler option -lmyfavs.
The linker also accepts an optional version number suffix: for example, libmyfavs.so.1 for version one of the library.
The compiler's -hname option records name as the name of the dynamic library being built.
Building a dynamic library requires a compilation of the source files with the -xcode option and linker options -G, -ztext, and -hname. These linker options are available through the compiler command line.
You can create a dynamic library with the same files used in the static library example.
Example: Compile with -pic and other linker options:
demo% f95 -o libtestlib.so.1 -G -xcode=pic13 -ztext
-hlibtestlib.so.1 *.f
-G tells the linker to build a dynamic library.
-ztext warns you if it finds anything other than position-independent code, such as relocatable text.
Example: Make an executable file a.out using the dynamic library:
demo% f95 -o trylib -R`pwd` trylib.f libtestlib.so.1
demo% file trylib
trylib:ELF 32-bit MSB executable SPARC Version 1, dynamically linked, not stripped
demo% ldd trylib
libtestlib.so.1 =& /export/home/U/Tests/libtestlib.so.1
libfui.so.1 =& /opt/SUNWspro/lib/libfui.so.1
libfai.so.1 =& /opt/SUNWspro/lib/libfai.so.1
libc.so.1 =& /usr/lib/libc.so.1
Note that the example uses the -R option to bind into the executable the path (the current directory) to the dynamic library.
The file command shows that the executable is dynamically linked.
When building dynamic libraries, insure proper initialization of common blocks (by DATA or BLOCK DATA) by gathering the initialized common blocks into the same library, and referencing that library before all others.
For example:
demo% f95 -G -xcode=pic32 -o init.so blkdat1.f blkdat2.f blkdat3.f
demo% f95 -o prog main.f init.so otherlib1.so otherlib2.so
The first compilation creates a dynamic library from files that define common blocks and initialize them in BLOCK DATA units. The second compilation creates the executable binary, linking the compiled main program with the dynamic libraries required by the application. Note that the dynamic library that initializes all the common blocks appears first before all the other libraries. This insures the blocks are properly initialized.
The table shows the libraries installed with the compilers.
Major Libraries Provided With the Compilers
f95 support intrinsics
f95 interface
f95 array intrinsics libraries
f95 interval arithmetic intrinsic library
-xinterval
Library of Sun math functions
libsunmath
If your executable uses a Sun dynamic library that is listed in the runtime.libraries README file, your license includes the right to redistribute the library to your customer.
This README file is located in the READMEs directory:
/opt/SUNWspro/READMEs/
Do not redistribute or otherwise disclose the header files, source code, object modules, or static libraries of object modules in any form.
Refer to your software license for more details.

我要回帖

更多关于 20awgx2c 的文章

 

随机推荐