@@ -32,7 +32,7 @@ const WITH_EXPAT: &str = "ON";
32
32
33
33
/// Linux targets
34
34
const LINUX_INCLUDE_PATHS : & [ & str ] = & [ "/usr/include/sbml" , "/usr/include/libxml2" ] ;
35
- const LINUX_LINK_PATHS : & [ & str ] = & [ "/usr/lib" ] ;
35
+ const LINUX_LINK_PATHS : & [ & str ] = & [ "/usr/lib" , "/usr/lib/x86_64-linux-gnu" ] ;
36
36
const LINUX_LINK_LIBS : & [ & str ] = & [ "sbml" , "xml2" ] ;
37
37
38
38
/// Main build script function that orchestrates the build process
@@ -89,13 +89,25 @@ fn link_to_libraries() -> miette::Result<Vec<PathBuf>> {
89
89
let link_libs = libsbml_vcpkg. found_names ;
90
90
( include_paths, link_paths, link_libs)
91
91
} else if cfg ! ( target_os = "linux" ) {
92
- let link_paths = LINUX_LINK_PATHS . iter ( ) . map ( |p| PathBuf :: from ( p) ) . collect ( ) ;
93
- let include_paths = LINUX_INCLUDE_PATHS
94
- . iter ( )
95
- . map ( |p| PathBuf :: from ( p) )
96
- . collect ( ) ;
97
- let link_libs = LINUX_LINK_LIBS . iter ( ) . map ( |l| l. to_string ( ) ) . collect ( ) ;
98
- ( include_paths, link_paths, link_libs)
92
+ // Try using pkg-config first as it's more reliable
93
+ match pkg_config:: Config :: new ( ) . probe ( "libsbml" ) {
94
+ Ok ( libsbml_pkg_config) => {
95
+ let link_paths = libsbml_pkg_config. link_paths ;
96
+ let include_paths = libsbml_pkg_config. include_paths ;
97
+ let link_libs = libsbml_pkg_config. libs ;
98
+ ( include_paths, link_paths, link_libs)
99
+ }
100
+ // Fall back to hardcoded paths if pkg-config fails
101
+ Err ( _) => {
102
+ let link_paths = LINUX_LINK_PATHS . iter ( ) . map ( |p| PathBuf :: from ( p) ) . collect ( ) ;
103
+ let include_paths = LINUX_INCLUDE_PATHS
104
+ . iter ( )
105
+ . map ( |p| PathBuf :: from ( p) )
106
+ . collect ( ) ;
107
+ let link_libs = LINUX_LINK_LIBS . iter ( ) . map ( |l| l. to_string ( ) ) . collect ( ) ;
108
+ ( include_paths, link_paths, link_libs)
109
+ }
110
+ }
99
111
} else if cfg ! ( target_os = "macos" ) {
100
112
let libsbml_pkg_config = pkg_config:: Config :: new ( )
101
113
. probe ( "libsbml" )
0 commit comments