Fortran Coder

标题: 两个静态库重复定义造成冲突如何解决? [打印本页]

作者: weixing1531    时间: 2023-9-22 18:21
标题: 两个静态库重复定义造成冲突如何解决?
编译器:SimplyFortran 3.31
Dislin库文件dismg_d.a与SimplyFortran自带界面库文件libappgraphics.a中均有line子程序,重复定义造成冲突
报错信息:
d:/program files (x86)/simply fortran 3/mingw-w64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/lib/../lib\libappgraphics.a(drawing.o):drawing.c:(.text+0x13e0): multiple definition of `line'
c:\dislin\dismg_d.a(line.o):line.c:(.text+0x476e): first defined here
collect2.exe: error: ld returned 1 exit status



作者: li913    时间: 2023-9-23 12:12
use module 的时候,只导出需要的函数, use A,only: B. 如果两个line都需要,可以用别名  use A, AB=>B
作者: fcode    时间: 2023-9-23 13:12
li913 发表于 2023-9-23 12:12
use module 的时候,只导出需要的函数, use A,only: B. 如果两个line都需要,可以用别名  use A, AB=>B ...

这俩库如果有源代码还好,可以改一下。
如果没有源代码,还是比较麻烦的。

作者: weixing1531    时间: 2023-9-23 14:00
fcode 发表于 2023-9-23 13:12
这俩库如果有源代码还好,可以改一下。
如果没有源代码,还是比较麻烦的。
...

改别名试过了,不行
作者: chiangtp    时间: 2023-9-23 20:17
DISLIN: (LINE) -> (STRTPT, STRTPT)
or
SimplyFortran, AppGraphics: (line) -> (moveto, lineto)

======================================================================                                             
DISLIN: (LINE) -> (STRTPT, STRTPT)                                                                                 
======================================================================                                             
                                                                                                                    
L I N E                                                                                                            
                                                                                                                    
LINE joins two points with a line.                                                                                 
Different line styles can be used.                                                                                 
                                                                                                                    
The call is:    CALL LINE (X1, Y1, X2, Y2)      level 1, 2, 3                                                      
                                                                                                                    
X1, Y1  are real numbers containing the plot coordinates of the first point.                                       
X2, Y2  are real numbers containing the plot coordinates of the second point.                                       
                                                                                                                    
----------------------------------------                                                                           
                                                                                                                    
XMOVE and XDRAW are simple subroutines for plotting lines.                                                         
Different line styles can be used.                                                                                 
                                                                                                                    
The calls are:  CALL STRTPT (X, Y)      level 1, 2, 3                                                               
                CALL CONNPT (X, Y)      level 1, 2, 3                                                               
                                                                                                                    
X, Y    are real numbers containing the plot coordinates.                                                           
                                                                                                                    
======================================================================                                             
SimplyFortran, AppGraphics: (line) -> (moveto, lineto)                                                              
======================================================================                                             
                                                                                                                    
line                                                                                                               
                                                                                                                    
Fortran subroutine line (x1, y1, x2, y2)                                                                           
                                                                                                                    
Description                                                                                                         
Draws a line using the current color from point (x1,y1) to point (x2,y2).                                          
                                                                                                                    
Parameters                                                                                                         
Parameter       Fortran Type    Description                                                                        
x1              integer         Horizontal coordinate of the start point of the line                                
y1              integer         Vertical coordinate of the start point of the line                                 
x2              integer         Horizontal coordinate of the end point of the line                                 
y2              integer         Vertical coordinate of the end point of the line                                    
                                                                                                                    
----------------------------------------                                                                           
                                                                                                                    
moveto                                                                                                              
Fortran subroutine moveto (x, y)                                                                                    
                                                                                                                    
Description                                                                                                         
Sets the current position to be used with subsequent relative graphics operations.                                 
                                                                                                                    
Parameters                                                                                                         
Parameter       Fortran Type    Description                                                                        
x               integer         Horizontal coordinate of the current position                                       
y               integer         Vertical coordinate of the current position                                         
                                                                                                                    
--------------------                                                                                                
                                                                                                                    
lineto                                                                                                              
                                                                                                                    
Fortran subroutine lineto (x, y)                                                                                    
                                                                                                                    
Description                                                                                                         
Draws a line from the current position to the point (x, y) using the current color.                                 
The current position is moved to this new offset after the drawing operation.                                       
                                                                                                                    
Parameters                                                                                                         
Parameter       Fortran Type    Description                                                                        
x               integer         Horizontal coordinate of the end point of the line                                 
y               integer         Vertical coordinate of the end point of the line                                    
                                                                                                                    
作者: weixing1531    时间: 2023-9-25 10:03
chiangtp 发表于 2023-9-23 20:17
DISLIN: (LINE) -> (STRTPT, STRTPT)
or
SimplyFortran, AppGraphics: (line) -> (moveto, lineto)

用相同功能函数代替还是不行
作者: chiangtp    时间: 2023-9-25 10:13
weixing1531 发表于 2023-9-25 10:03
用相同功能函数代替还是不行

請告知 "錯誤訊息"
作者: weixing1531    时间: 2023-9-25 10:44
chiangtp 发表于 2023-9-25 10:13
請告知 "錯誤訊息"

还是相同的错误信息,网上说只有对静态库进行重新改名封装了
作者: chiangtp    时间: 2023-9-25 11:01
1. "LINE" 在DISLIN中為"EXTERNAL" subroutine,  在AppGraphics中應該也是
2. 如果都是"MODULE" subroutines, li913的作法OK
3. 如果 錯誤訊息 仍是 multiple definition of `line', 請確認:你的程式中 所有的 "LINE"calls 均已做替換
    DISLIN: (LINE) -> (STRTPT, CONNPT)      
    AppGraphics: (line) -> (moveto, lineto)
作者: weixing1531    时间: 2023-9-28 09:21
这是SF作者的答复:错误是由链接器而非编译器产生的。链接器遇到两个不同的行过程并失败。即使您没有显式地使用line,由于库中的一些较低级别调用,它仍然很有可能需要链接。
作者: chiangtp    时间: 2023-9-28 10:05
1. 你 "自己的source", 所有的 LINE calls 均已做替換[ (STRTPT, CONNPT) , (moveto, lineto)] , link時就不會   
    有 multiple definition of "LINE"的問題
2.  低階[ (STRTPT, CONNPT) , (moveto, lineto)] 是不會再referenc 高階[LINE] 的
3.  有 不是"自己的source", i.e., 第三方OBJ? 參與 link?
4. LINE不是唯一的問題?
4. 請你描述一下, 為何一個 PROGRAM/SUBRRIGRAM/PLOT 用到兩個不兼容ˊ的graphics linraries
5. 兩座大山難移, 登山之路前有古人後有來者
作者: weixing1531    时间: 2023-9-28 11:03
这是原话

C2D7A1E8-1576-454E-A542-5ED74FA5A0C7.png (370.59 KB, 下载次数: 121)

C2D7A1E8-1576-454E-A542-5ED74FA5A0C7.png

作者: weixing1531    时间: 2023-9-28 11:09
chiangtp 发表于 2023-9-28 10:05
1. 你 "自己的source", 所有的 LINE calls 均已做替換[ (STRTPT, CONNPT) , (moveto, lineto)] , link時就 ...

Appgraphics库做界面,Dislin库画图
我尝试一下Dislin既做界面又画图,可能会有点麻烦

作者: chiangtp    时间: 2023-9-28 12:22
CALL SYSTEM("Dislin库画图")是否可行?




欢迎光临 Fortran Coder (http://bbs.fcode.cn/) Powered by Discuz! X3.2