Where to put the shared library (*.so) to avoid "Error: External module not found"
Where to put the shared library (*.so) to avoid "Error: External module not found"
我在 C 编程中创建了一个新代码,并从中创建了一个共享库。我想在 Pharo 7 上访问它。所以我把它放在 /usr/local/lib 、 /usr/lib 甚至 Pharo 可执行文件所在的文件夹中。当我 运行 代码时,我总是得到 "Error: External module not found"。我应该把 *.so 库放在哪里。我 运行 Raspberry Pi 3 Model B+ 中的 Pharo 7,带有 Raspbian Stretch OS。这是我的代码:
'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))! !
我一般建议将库文件放在虚拟机的lib文件夹中。因此,对于我手边的 Pharo 6 发行版,它将位于 pharo6.0-64/bin/lib/pharo/5.0-201705310241 目录中。 (确切的子目录名称会因版本而异,因为它们嵌入了版本号。)此外,您可以 通常 不用复制库就可以使用符号链接而不是复制它。
我在 C 编程中创建了一个新代码,并从中创建了一个共享库。我想在 Pharo 7 上访问它。所以我把它放在 /usr/local/lib 、 /usr/lib 甚至 Pharo 可执行文件所在的文件夹中。当我 运行 代码时,我总是得到 "Error: External module not found"。我应该把 *.so 库放在哪里。我 运行 Raspberry Pi 3 Model B+ 中的 Pharo 7,带有 Raspbian Stretch OS。这是我的代码:
'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))! !
我一般建议将库文件放在虚拟机的lib文件夹中。因此,对于我手边的 Pharo 6 发行版,它将位于 pharo6.0-64/bin/lib/pharo/5.0-201705310241 目录中。 (确切的子目录名称会因版本而异,因为它们嵌入了版本号。)此外,您可以 通常 不用复制库就可以使用符号链接而不是复制它。