Skip to content

Commit

Permalink
Use older GCC/G++ compiler for compatibility with MATLAB libs
Browse files Browse the repository at this point in the history
Instead of trying to ship our own newer libs. I believe that was not working
because MATLAB already dynamically loads its own libs at start up, and multiple
versions of the same library cannot be loaded at the same time because that
would lead to multiple definitions of the same symbols. This means the RPATH
cannot ensure the libraries we won't will be loaded.

Actually fixes #2.
  • Loading branch information
David R Connell committed Feb 7, 2024
1 parent fe94680 commit f474127
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 39 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yaml
Expand Up @@ -14,6 +14,9 @@ jobs:
build-linux:
name: Build Linux toolbox
runs-on: ubuntu-latest
env:
CC: gcc-10
CXX: g++-10

steps:
- uses: actions/checkout@v4
Expand All @@ -24,7 +27,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt update && sudo apt upgrade
sudo apt install cmake ninja-build gcc g++ libxml2-dev libbison-dev libfl-dev
sudo apt install cmake ninja-build gcc-10 g++-10 libxml2-dev libbison-dev libfl-dev
- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v1
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.8] 2024-02-06

### Fixed

- Compile with older versions gcc/g++ on Linux to fix GLIBCXX version issue.

## [0.1.7] 2024-02-06

Fake update to try to get File Exchange to change the toolbox file it grabs.
Expand Down
6 changes: 0 additions & 6 deletions CMakeLists.txt
Expand Up @@ -18,7 +18,6 @@ endif()

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(BUILD_SHARED_LIBS OFF)

Expand Down Expand Up @@ -88,11 +87,6 @@ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
PRE_EXCLUDE_REGEXES "api-ms-*" "libmx" "libmex" "ext-ms-*"
DESTINATION matlab-igraph/toolbox/+igraph/private
COMPONENT toolbox)
elseif ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
install(RUNTIME_DEPENDENCY_SET toolbox_deps
DESTINATION matlab-igraph/toolbox/+igraph/private/lib
PRE_EXCLUDE_REGEXES "libmex" "libmx" "libicuuc.so.69" "libz.so.1"
COMPONENT toolbox)
endif()

# Packaging
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 21 additions & 20 deletions flake.nix
Expand Up @@ -14,25 +14,26 @@
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in {
devShells.${system}.default = pkgs.mkShell {
buildInputs = (with nix-matlab.packages.${system}; [
matlab
matlab-mlint
matlab-mex
]) ++ (with pkgs; [
astyle
cmake
ninja
gdb
hugo
# igraph dependencies
bison
flex
libxml2
]);
shellHook = ''
export OMP_NUM_THREADS=16
'';
};
devShells.${system}.default =
(pkgs.mkShell.override { stdenv = pkgs.gcc10Stdenv; }) {
packages = (with nix-matlab.packages.${system}; [
matlab
matlab-mlint
matlab-mex
]) ++ (with pkgs; [
astyle
cmake
ninja
gdb
hugo
# igraph dependencies
bison
flex
libxml2
]);
shellHook = ''
export OMP_NUM_THREADS=16
'';
};
};
}
4 changes: 0 additions & 4 deletions mex/CMakeLists.txt
Expand Up @@ -8,10 +8,6 @@ foreach(source ${src_files})
R2018a
)

if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
target_link_options(${mex_name} PRIVATE LINKER:--disable-new-dtags)
endif()

target_include_directories(${mex_name}
PRIVATE ${Matlab_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}
)
Expand Down
5 changes: 0 additions & 5 deletions toolbox/+igraph/postinstall.m
Expand Up @@ -22,11 +22,6 @@ function postinstall()
if ~startsWith(currentSystem, 'win')
delete(fullfile(path{1}, "*.dll"));
end

if exist(fullfile(path{1}, 'lib'), 'dir') && ...
~startsWith(currentSystem, 'gln')
rmdir(fullfile(path{1}, "lib"), "s");
end
end

self = mfilename('fullpath') + ".m";
Expand Down

0 comments on commit f474127

Please sign in to comment.