- Package:
- libngspice0
- Source:
- libngspice0
- Description:
- Spice circuit simulator - library
- Submitter:
- Robert Paciorek
- Date:
- 2024-10-19 10:21:01 UTC
- Severity:
- normal
libngspice uses configuration and model files provided by ngspice package (/usr/share/ngspice/scripts/spinit and /usr/lib/x86_64-linux-gnu/ngspice/*.cm). * running software used libngspice0 without ngspice installed may results in error "MIF-ERROR - unable to find definition of model and Simulation interrupted due to error!" (with previous warning "Warning: can't find the initialization file spinit") * running software used libngspice0 with installed ngspice in version different than libngspice0 version (for example libngspice0 43+ds-1~bpo12+1 and ngspice 39.3+ds-1) may cause segmentation fault. Segmentation fault occurs only while referring to standard models provided by *.cm files, for example while simulating digital systems using: A1 [in1 in2] out AND .model AND d_and
Hello Robert, Am Fri, Oct 18, 2024 at 05:41:44PM +0000 schrieb Robert Paciorek: I disagree, the libngsice0 package is only containing the shared libray parts and if the libary would use some external things without depending on it would be programmed in a bad way. $ dpkg -L libngspice0 /. /usr /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/libngspice.so.0.0.10 /usr/share /usr/share/doc /usr/share/doc/libngspice0 /usr/share/doc/libngspice0/changelog.Debian.gz /usr/share/doc/libngspice0/changelog.gz /usr/share/doc/libngspice0/copyright /usr/share/lintian /usr/share/lintian/overrides /usr/share/lintian/overrides/libngspice0 /usr/lib/x86_64-linux-gnu/libngspice.so.0 While the ngspice package is containing the files you mentioned. $ dpkg -S /usr/share/ngspice/scripts/spinit ngspice: /usr/share/ngspice/scripts/spinit $ dpkg -S /usr/lib/x86_64-linux-gnu/ngspice/* ngspice: /usr/lib/x86_64-linux-gnu/ngspice/analog.cm ngspice: /usr/lib/x86_64-linux-gnu/ngspice/digital.cm ngspice: /usr/lib/x86_64-linux-gnu/ngspice/spice2poly.cm ngspice: /usr/lib/x86_64-linux-gnu/ngspice/table.cm ngspice: /usr/lib/x86_64-linux-gnu/ngspice/xtradev.cm ngspice: /usr/lib/x86_64-linux-gnu/ngspice/xtraevt.cm The ngspice binary isn't even depending on any symbol from libngspice libary so dpkg-shlibdeps isn't filling in the library as an dependency. https://packages.debian.org/unstable/ngspice If there is a symbol from there needed then this needs to get fixed upstream. But I'm sure this isn't the case here. Maybe Holger (CCed) can give a better explanation. You do not provide an example where we could prove your assumption. Without it's impossible to re-adjust a potential misbehavior. You might provide what you try to do in detail, Holger can then have a look at this. Holger, I assume you are interested in some samples so you could have a look at? Thanks! Regards Carsten
Carsten,, Robert, libngspice is a shared library version of ngspice, a full simulator like standard ngspice, but depending on a caller for control. libngspice reads spinit, and loads (using the commands 'codemodel ...' in spinit) the shared libraries *.cm at runtime, thus behaving the same as standard ngspice. Due to ongoing development and functions added to the libngspice interface (not deleting or changing existing functions), older versions may not be compatible when the caller (e.g. KiCad Eeschema) is making use of the new functions. Ideally ngspice exe and libngspice would be distributed together with a single compatible version of the *.cm shared library code models. Currently there are Ubuntu users not being able to install standard ngspice (with *cm) and then KiCad (with libngspice and again *.cm) . Overwriting is not allowed, and the ngspice and libngspice versions may be grossly different. Regards Holger Am 18.10.2024 um 20:34 schrieb Carsten Schoenert:
Hi Carsten, thanks for reply! These files are part of the official library archives from sourceforge.net (https://sourceforge.net/projects/ngspice/files/ng-spice-rework/43/ngspice-43_dll_64.7z). Yes, ngspice is not depending on symbols from libngspice. It is libngspice that (in some scenarios) uses files provided only with ngspice package (perhaps they should be in a separate package, e.g. ngspice-data, because they are used also by the ngspice executable). I'm attaching the source code of simple program used libngspice (gdspice.cpp) and two netlist files: - digital.netlist - simple digital circuit (used standard ngspice model for AND gate via `.model` command) - analog.netlist - similar (but analog, without `.model` command) circuit `gdspice.cpp` can load libngspice via dlopen (default, build via `g++ gdspice.cpp`) or can be linked with libngspice on build time (unset USE_DLOPEN macro and build via `g++ gdspice-nogodot.cpp -lngspice`). This allow test all 3 scenarios: 1. The same version (43+ds-1~bpo12+1) of libngspice0 and ngspice packages: -> both circuit are simulated. 2. Installed only libngspice0 (still 43+ds-1~bpo12+1, but ngspice is not installed): -> analog circuit produce warning about spinit, but is simulated, -> digital circuit produce error about missed definition of model and is not simulated. 3. Different version of libngspice0 (43+ds-1~bpo12+1) and ngspice (39.3+ds-1): -> analog circuit is simulated (no warning), -> digital circuit cause segmentation fault inside libngspice0. Using strace shows that *.cm files are opened even though they are not referenced in the program source code (they are used internally by the library, due to content of the default `spinit` file, also internally referenced via libngspice). Regards Robert
Standard behaviour of both ngspice and libngspice is:
- During start-up (initialization), read 'spinit'.
- Execute the commands found in 'spinit'
- Read .spiceinit.
- Execute the commands found in .spiceinit
- Read the netlist, excute it as prescribed with its dot commands and
.control section commands.
File 'spinit' does contain commands for loading the code model shared
libraries, including absolute path or relative path (relative to the
current directory), for example 'codemodel ../lib/ngspice/xtradev.cm'.
With ngspice this sequence is indispensable.
With libngspice you may suppress reading spinit by the caller and load
the code models individually, for example:
- Load libngspice
- Suppress reading spinit by executing ngSpice_nospinit()
- Initialize simulator by executing ngSpice_Init(...)
- Load code models (one after the other) by executing
ngSpice_Command("codemodel ../lib/ngspice/spice2poly.cm" ) etc.
Code models and ngspice (or libngspice) have to be made and distributed
together, no re-use of older code model versions.