我在C编程中创建了一个新代码,并由此创建了一个共享库。我想在Pharo 7上访问它。因此,将它放在/ usr / local / lib,/ usr / lib甚至Pharo可执行文件所在的文件夹中。运行代码时,我总是收到“错误:找不到外部模块”。我应该在哪里正确放置* .so库。我在带有Raspbian Stretch OS的Raspberry Pi 3 Model B +中运行Pharo 7。这是我的代码:
'From Pharo7.0.1 of 25 February 2019 [Build information: Pharo-7.0.1+build.149.sha.890f474a81f116ead0e68c8de77790aef4e9a752 (32 Bit)] on 9 May 2019 at 2:29:46.092395 pm'!
FFILibrary subclass: #AD7091RFFILibrary
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Manifold-AD7091R'!
!AD7091RFFILibrary methodsFor: 'accessing platform' stamp: 'LesterLecong 5/9/2019 14:01'!
unixModuleName
"Kept for backward compatibility.
Users should use unix32* or unix64*"
^ 'AD7091R.so'! !
!AD7091RFFILibrary methodsFor: 'accessing platform' stamp: 'LesterLecong 5/9/2019 11:49'!
macModuleName
^ 'AD7091R.dylib'! !
!AD7091RFFILibrary methodsFor: 'accessing platform' stamp: 'LesterLecong 5/9/2019 11:50'!
win32ModuleName
^ 'AD7091R.dll'! !
!AD7091RFFILibrary methodsFor: 'accessing platform' stamp: 'LesterLecong 5/9/2019 14:01'!
unix32ModuleName
"Kept for backward compatibility.
Users should use unix32* or unix64*"
^ 'AD7091R.so'! !
!AD7091RFFILibrary methodsFor: 'api' stamp: 'LesterLecong 5/9/2019 12:01'!
apiAD7091RDealloc: handle
"int AD7091R_dealloc(AD7091R *p_instance)"
^ self ffiCall: #(int AD7091R_dealloc(AD7091RExternalObject handle))! !
!AD7091RFFILibrary methodsFor: 'api' stamp: 'LesterLecong 5/9/2019 12:13'!
apiAD7091RData: handle pin: pin
"iint AD7091R_data_pin(AD7091R *p_instance,
uint8_t n_data_pin)"
^ self ffiCall: #(int AD7091R_data_pin(AD7091RExternalObject handle, int pin))! !
!AD7091RFFILibrary methodsFor: 'api' stamp: 'LesterLecong 5/9/2019 11:57'!
apiAD7091RAlloc: handle
"int AD7091R_alloc(AD7091R **pp_instance)"
^ self ffiCall: #(int AD7091R_alloc(AD7091RExternalObject *handle))! !
!AD7091RFFILibrary methodsFor: 'api' stamp: 'LesterLecong 5/9/2019 13:12'!
apiAD7091RPins: handle convst: convstPin cs: csPin clk: clkPin data: dataPin
"int AD7091R_pins(AD7091R *p_instance,
uint8_t n_convst_pin,
uint8_t n_cs_pin,
uint8_t n_clk_pin,
uint8_t n_data_pin)"
^self ffiCall: #(int AD7091R_pins(AD7091RExternalObject handle,
int convstPin,
int csPin,
int clkPin,
int dataPin))! !
!AD7091RFFILibrary methodsFor: 'api' stamp: 'LesterLecong 5/9/2019 12:14'!
apiAD7091RBegin: handle
"iint AD7091R_begin(AD7091R *p_instance)"
^ self ffiCall: #(int AD7091R_begin(AD7091RExternalObject handle))! !
!AD7091RFFILibrary methodsFor: 'api' stamp: 'LesterLecong 5/9/2019 12:11'!
apiAD7091RClk: handle pin: pin
"iint AD7091R_clk_pin(AD7091R *p_instance,
uint8_t n_clk_pin)"
^ self ffiCall: #(int AD7091R_clk_pin(AD7091RExternalObject handle, int pin))! !
!AD7091RFFILibrary methodsFor: 'api' stamp: 'LesterLecong 5/9/2019 12:11'!
apiAD7091RConvst: handle pin: pin
"iint AD7091R_convst_pin(AD7091R *p_instance,
uint8_t n_convst_pin)"
^ self ffiCall: #(int AD7091R_convst_pin(AD7091RExternalObject handle, int pin))! !
!AD7091RFFILibrary methodsFor: 'api' stamp: 'LesterLecong 5/9/2019 12:12'!
apiAD7091RCs: handle pin: pin
"iint AD7091R_cs_pin(AD7091R *p_instance,
uint8_t n_cs_pin)"
^ self ffiCall: #(int AD7091R_cs_pin(AD7091RExternalObject handle, int pin))! !
!AD7091RFFILibrary methodsFor: 'api' stamp: 'LesterLecong 5/9/2019 12:16'!
apiAD7091RData: handle
"iint AD7091R_data(AD7091R *p_instance)"
^ self ffiCall: #(int AD7091R_data(AD7091RExternalObject handle))! !
!AD7091RFFILibrary methodsFor: 'api' stamp: 'LesterLecong 5/9/2019 12:16'!
apiAD7091RReset: handle
"iint AD7091R_reset(AD7091R *p_instance)"
^ self ffiCall: #(int AD7091R_reset(AD7091RExternalObject handle))! !
答案 0 :(得分:0)
我通常建议将库文件放在VM的lib文件夹中。因此,对于方便的Pharo 6发行版,它将位于pharo6.0-64 / bin / lib / pharo / 5.0-201705310241目录中。 (确切的子目录名称会因版本而有所不同,因为它们会嵌入版本号。)此外,您通常可以不用符号链接到库而无需复制它。