Fortran Coder

查看: 1649|回复: 13
打印 上一主题 下一主题

[讨论] 两个静态库重复定义造成冲突如何解决?

[复制链接]

127

帖子

35

主题

1

精华

大师

F 币
1153 元
贡献
592 点
跳转到指定楼层
楼主
发表于 2023-9-22 18:21:22 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
编译器: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


分享到:  微信微信
收藏收藏 点赞点赞 点踩点踩

798

帖子

2

主题

0

精华

大宗师

F 币
3793 元
贡献
2268 点
沙发
发表于 2023-9-23 12:12:23 | 只看该作者
use module 的时候,只导出需要的函数, use A,only: B. 如果两个line都需要,可以用别名  use A, AB=>B

1963

帖子

12

主题

5

精华

论坛跑堂

臭石头雪球

F 币
1357 元
贡献
574 点

美女勋章热心勋章星光勋章新人勋章贡献勋章管理勋章帅哥勋章爱心勋章规矩勋章元老勋章水王勋章

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

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

127

帖子

35

主题

1

精华

大师

F 币
1153 元
贡献
592 点
地板
 楼主| 发表于 2023-9-23 14:00:01 | 只看该作者
fcode 发表于 2023-9-23 13:12
这俩库如果有源代码还好,可以改一下。
如果没有源代码,还是比较麻烦的。
...

改别名试过了,不行

130

帖子

10

主题

0

精华

大师

F 币
617 元
贡献
372 点

贡献勋章管理勋章帅哥勋章元老勋章星光勋章规矩勋章

5#
发表于 2023-9-23 20:17:30 | 只看该作者
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                                    
                                                                                                                    

127

帖子

35

主题

1

精华

大师

F 币
1153 元
贡献
592 点
6#
 楼主| 发表于 2023-9-25 10:03:12 | 只看该作者
chiangtp 发表于 2023-9-23 20:17
DISLIN: (LINE) -> (STRTPT, STRTPT)
or
SimplyFortran, AppGraphics: (line) -> (moveto, lineto)

用相同功能函数代替还是不行

130

帖子

10

主题

0

精华

大师

F 币
617 元
贡献
372 点

贡献勋章管理勋章帅哥勋章元老勋章星光勋章规矩勋章

7#
发表于 2023-9-25 10:13:35 | 只看该作者
weixing1531 发表于 2023-9-25 10:03
用相同功能函数代替还是不行

請告知 "錯誤訊息"

127

帖子

35

主题

1

精华

大师

F 币
1153 元
贡献
592 点
8#
 楼主| 发表于 2023-9-25 10:44:54 | 只看该作者
chiangtp 发表于 2023-9-25 10:13
請告知 "錯誤訊息"

还是相同的错误信息,网上说只有对静态库进行重新改名封装了

130

帖子

10

主题

0

精华

大师

F 币
617 元
贡献
372 点

贡献勋章管理勋章帅哥勋章元老勋章星光勋章规矩勋章

9#
发表于 2023-9-25 11:01:14 | 只看该作者
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)

127

帖子

35

主题

1

精华

大师

F 币
1153 元
贡献
592 点
10#
 楼主| 发表于 2023-9-28 09:21:02 | 只看该作者
这是SF作者的答复:错误是由链接器而非编译器产生的。链接器遇到两个不同的行过程并失败。即使您没有显式地使用line,由于库中的一些较低级别调用,它仍然很有可能需要链接。
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-4-28 18:52

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表