← Back to team overview

kicad-developers team mailing list archive

Re: eeschema depends on libngspice.so instead of libngspice.so.0?

 

Hi Carsten,

On 10/27/18 11:50 AM, Carsten Schoenert wrote:
[snip]
> I'd really appreciate if the situation could be improved here somewhere
> in the future!

Can you check if the attached patch solves the problem? It still does
not recognize the right libngspice file under Windows, but I need to
know if it is a step in the right direction.

Cheers,
Orson
diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt
index e56f3c849..cd4d0d78e 100644
--- a/eeschema/CMakeLists.txt
+++ b/eeschema/CMakeLists.txt
@@ -7,6 +7,15 @@ add_definitions( -DEESCHEMA )
 
 if( KICAD_SPICE )
     set( INC_AFTER ${INC_AFTER} ${NGSPICE_INCLUDE_DIR} )
+
+    # Find out the exact libngspice file name
+    get_filename_component( NGSPICE_REAL_PATH "${NGSPICE_LIBRARY}" REALPATH )
+    get_filename_component( NGSPICE_LIB_FILE "${NGSPICE_REAL_PATH}" NAME )
+
+    set_property( SOURCE sim/ngspice.cpp
+        APPEND PROPERTY COMPILE_DEFINITIONS
+        NGSPICE_LIB_FILE="${NGSPICE_LIB_FILE}"
+        )
 endif()
 
 include_directories( BEFORE ${INC_BEFORE} )
@@ -359,7 +368,15 @@ target_link_libraries( eeschema_kiface
     legacy_gal
     ${wxWidgets_LIBRARIES}
     ${GDI_PLUS_LIBRARIES}
+    ${NGSPICE_LIBRARY}
     )
+
+if( KICAD_SPICE )
+    target_link_libraries( eeschema_kiface
+        ${NGSPICE_LIBRARY}
+        )
+endif()
+
 set_target_properties( eeschema_kiface PROPERTIES
     # Decorate OUTPUT_NAME with PREFIX and SUFFIX, creating something like
     # _eeschema.so, _eeschema.dll, or _eeschema.kiface
diff --git a/eeschema/sim/ngspice.cpp b/eeschema/sim/ngspice.cpp
index 3b6e4dd74..3cfbf8b1f 100644
--- a/eeschema/sim/ngspice.cpp
+++ b/eeschema/sim/ngspice.cpp
@@ -293,7 +293,7 @@ void NGSPICE::init_dll()
     const vector<string> dllPaths = { "", "/mingw64/bin", "/mingw32/bin" };
 #endif /* __WINDOWS__ */
 #ifdef __WXMAC__
-    wxFileName dllFile( "", "libngspice.0.dylib" );
+    wxFileName dllFile( "", NGSPICE_LIB_FILE );
     const vector<string> dllPaths = {
         GetOSXKicadUserDataDir() + "/PlugIns/ngspice",
         GetOSXKicadMachineDataDir() + "/PlugIns/ngspice",
@@ -320,7 +320,7 @@ void NGSPICE::init_dll()
     if( !m_dll.IsLoaded() ) // try also the system libraries
         m_dll.Load( wxDynamicLibrary::CanonicalizeName( "ngspice" ) );
 #else
-    m_dll.Load("libngspice.so.0");
+    m_dll.Load( NGSPICE_LIB_FILE );
 #endif /* __WINDOWS || __WXMAC__ */
 
     if( !m_dll.IsLoaded() )

Attachment: signature.asc
Description: OpenPGP digital signature


Follow ups

References