我正在构建一个包含一些依赖项的共享库,包括readline
和ncurses
:
g++ -m64 -shared -o lib/libXYZ.so <some .o files> -lz -lgmp -lreadline -lncurses
但是,当我在生成的库上运行ncurses
时,对ldd
的依赖关系没有显示出来:
ldd lib/libXYZ.so
linux-vdso.so.1 => (0x00007ffe5399e000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fd9d4d9e000)
libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007fd9d4b2a000)
libreadline.so.6 => /lib/x86_64-linux-gnu/libreadline.so.6 (0x00007fd9d48e4000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd9d45e0000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd9d42da000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd9d40c4000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd9d3cff000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007fd9d3ad6000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd9d59f5000)
当我尝试使用此库libX
生成C应用程序时,一切正常。
使用它来构建Cython代码会导致Python模块损坏:
ImportError: <python-environment>/lib/libreadline.so.6: undefined symbol: PC
解决方案尝试1
在构建Python模块时,明确地将ncurses
添加到库列表中。
我不喜欢这个,因为所有依赖项都应包含在libX
。
解决方案尝试2
强制Python模块使用与C代码最初链接的相同readline
库。由于ncurses
而需要readline
,并且我的anaconda Python环境具有自己的readline
版本,因为设置了运行时库路径而使用它。如果我从此路径中删除libreadline.so
,链接器将使用我的全局库,ncurses
依赖项不会造成任何困难。
这显然是一种破解并迫使用户搞乱他们的Python环境。
首选解决方案(不知道如何)
使用ncurses
构建库libX
时,只需强制readline
的依赖关系。
有没有办法用gcc / g ++链接器做到这一点?
修改
显然,构建Python模块不需要readline
Anaconda个包。删除它可以解决问题 - 很可能因为使用readline
与libXYZ
链接的'set the current directory to the location of the template
ChDir ThisWorkbook.Path
myDir = ThisWorkbook.Path
'capture username
userName = ThisWorkbook.Sheets("Temp").Range("D2").Value
gMail = ThisWorkbook.Sheets("Tool").Range("B1").Value
sPassword = ThisWorkbook.Sheets("Tool").Range("B3").Value
'capture date
yDate = Format(Now, "mmddyy")
'save workbook as csv file
ThisWorkbook.Sheets("Report").SaveAs Filename:= _
"report_" & userName & "_" & Format(Now, "mmddyy"), _
FileFormat:=xlCSVMSDOS, CreateBackup:=False
'***********************************
'****send csv file as attachment****
'***********************************
Dim NewMail As Object
fName = "report_" & userName & "_" & yDate & ".csv"
myDir = myDir & "\"
Set NewMail = CreateObject("CDO.Message")
NewMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
NewMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
NewMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
NewMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
NewMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
NewMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = gMail
NewMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = sPassword
NewMail.Configuration.Fields.Update
'Set All Email Properties
With NewMail
.Subject = "Report for " & userName & " " & yDate
.From = gMail
.To = "ddoctor@yahoo.com"
.CC = ""
.BCC = ""
.AddAttachment myDir & Dir(myDir & fName) 'This is where I am getting the error
End With
NewMail.send
MsgBox ("Mail has been Sent")
'Set the NewMail Variable to Nothing
Set NewMail = Nothing
ThisWorkbook.Close SaveChanges:=False
End If
库。