Octave Wrapper in Ubuntu

53 views
Skip to first unread message

Juan de Jesús Chávez

unread,
Jun 22, 2023, 6:23:33 AM6/22/23
to coolprop-users
Hi, there.

I'm trying to use CoolProp in Octave, I'm running Octave 6.4.0 in Ubuntu 22.04.2 LTS.

I followed the procedure for User-Compiled Binaries. I could not install libpython-dev, but used libpython2-dev instead. I'm getting the following message after cmake .. -DCOOLPROP_OCTAVE_MODULE=ON -DBUILD_TESTING=ON -DCMAKE_CXX_STANDARD=11:


-- Configuring done
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
OCTAVE_OCTAVE_LIBRARY
    linked by target "CoolProp" in directory /home/user/CoolProp
OCTAVE_OCTINTERP_LIBRARY
    linked by target "CoolProp" in directory /home/user/CoolProp

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.




Since I don't know if that's too bad, I continued. It seems it was too bad, because I got the following after cmake --build:



Usage: cmake --build <dir>             [options] [-- [native-options]]
       cmake --build --preset <preset> [options] [-- [native-options]]
Options:
  <dir>          = Project binary directory to be built.
  --preset <preset>, --preset=<preset>
                 = Specify a build preset.
  --list-presets
                 = List available build presets.
  --parallel [<jobs>], -j [<jobs>]
                 = Build in parallel using the given number of jobs.
                   If <jobs> is omitted the native build tool's
                   default number is used.
                   The CMAKE_BUILD_PARALLEL_LEVEL environment variable
                   specifies a default parallel level when this option
                   is not given.
  --target <tgt>..., -t <tgt>...
                 = Build <tgt> instead of default targets.
  --config <cfg> = For multi-configuration tools, choose <cfg>.
  --clean-first  = Build target 'clean' first, then build.
                   (To clean only, use --target 'clean'.)
  --verbose, -v  = Enable verbose output - if supported - including
                   the build commands to be executed.
  --             = Pass remaining options to the native tool.



Again, I continued and got what looks like an error after ctest --extra-verbose.



UpdateCTestConfiguration  from :/home/user/CoolProp/build/DartConfiguration.tcl
UpdateCTestConfiguration  from :/home/user/CoolProp/build/DartConfiguration.tcl
Test project /home/user/CoolProp/build
Constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
No tests were found!!!


Am I missing something? Am I doing something wrong? Any help will be greatly appreciated.

Short: I'm trying to build a wrapper for Octave 6.4.0 following the provided instructions but can't. Am I missing something?

Ian Bell

unread,
Jun 22, 2023, 5:03:41 PM6/22/23
to coolpro...@googlegroups.com
I dug into this a bit, and the problem seems to be the FindOctave Cmake module that we use and it does not appear to query the right variables from octave. Octave appears to have changed their tooling a bit. Someone will need to fiddle with this file: https://github.com/CoolProp/CoolProp/blob/master/dev/cmake/Modules/FindOctave.cmake

--
You received this message because you are subscribed to the Google Groups "coolprop-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coolprop-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coolprop-users/c0049df3-be4d-4eeb-b550-4e5c9c36ef36n%40googlegroups.com.

Via Lav

unread,
Jun 23, 2023, 8:11:54 AM6/23/23
to coolprop-users
Hi, Jean,

Here you go (for generating the Octave wrapper): 

-DCOOLPROP_OCTAVE_MODULE=ON -DOCTAVE_OCTINTERP_LIBRARY:LIST="octinterp;octave" -DOCTAVE_OCTAVE_LIBRARY:LIST=octave -DCMAKE_CXX_STANDARD=11

(not sure if the last define is up-to-date). You would also need the latest SWIG (>= 4.1~) for Octave (>= 8~). Beware you need -DCOOLPROP_STATIC_LIBRARY=ON for the static library to link against − because compiling against the shared one results in the OCT file symbol(s) missing, or at least I have not figured how to deal with it (perhaps, not, if static linking would work). I had to "bring back to life" the 'wrappers/Octave' folder with `_OctaveBuilder_Linux.m` and `Example.m` − that was done by reverting the corresponding commit(s) found in the git history − again, not sure if that was indeed necessary but for me just to see it in the source tree back again (I had to modify it lightly to account for the path(s) out of the $DEB_HOST_MULTIARCH directory I'm building in and also blindly had replaced the Octave's `unlink` with equal (?) `delete` due to strange "unlink not found", but not yet thoroughly tested):

```octave

cd ../../CoolProp

include_string = '-I../../include/ -I../../src'

system('rm -f *_wrap.cpp')
system('swig -octave -c++ -o CoolProp_wrap.cpp -I../../include/ -I../../src ../../src/CoolProp.i')
main_files = glob('*.cpp');
files=[main_files];
o_files = ''
cpp_files = ''

for i=1:size(files)(1)
       file = files{i,1};
       o_file = strrep(file,'.cpp','.o');
       o_files = [o_files, ' ', o_file];
       cpp_files = [cpp_files, ' ',file];
       eval(['mkoctfile -v -c ', include_string,' -o ',o_file,' ',file])
end

eval(['mkoctfile -v -lgomp ', include_string,' -o CoolProp.oct ',o_files])

% Clean up - remove the object files
for i=1:size(files)(1)
       file = files{i,1};
       o_file = strrep(file,'.cpp','.o');
       delete(o_file);
       disp(['deleting the file ',o_file]);
end

delete('CoolProp_wrap.o')
delete('CoolProp_wrap.cpp')

system('mv CoolProp.oct ../wrappers/Octave')

```

Hi, Ian,

The following is my shortlist of compiled (or yet not) wrappers:

```text
    - Enable building the wide range of wrappers by default: Android, Java, CSharp (SMath[Studio]), Octave (>= 8~), LibreOffice (<< 7.5~), R,  etc (#TODO)
      #DONE: Lua, [Microsoft] Excel, R, Rust, JavaScript [Re: Emscripten (>= 3~)]
      #TODO: Engineering Equation Solver (EES), iOS (iPhone), FORTRAN, Fluent, Julia, Delphi [& Lazarus], LabVIEW, MATLAB, Maple (since 2016), MathCAD [Prime] (>= 15), Mathematica, Modelica, PHP (>= 7~), SciLab, VB.NET
      #SWIG: Chicken, D, Go, Guile (>= 2.0~), Lisp S-Expressions, MzScheme/Racket, OCaml, Perl (>= 5~), Pike, Ruby, Tcl8, XML
```

in particular I would propose the following changes to the Android wrapper: 

```diff
--- coolprop-6.5.0~git20230613.orig/wrappers/Android/Application.mk
+++ coolprop-6.5.0~git20230613/wrappers/Android/Application.mk
@@ -2,3 +2,9 @@ APP_STL := c++_static
 APP_CPPFLAGS += -fexceptions
 LOCAL_LDLIBS += -latomic
 LIBCXX_FORCE_REBUILD := true
+
+BIONIC_PATH := /usr/lib/android-sdk/ndk-bundle/bionic
+
+APP_ABI := armeabi-v7a
+APP_PLATFORM := android-19
+APP_BUILD_SCRITP := Android.mk
```
and note the following dependencies under Debian / Ubuntu due to $LIBCXX_FORCE_REBUILD: 
#               google-android-ndk-installer <!nowrapper !noandroid> | android-framework-25c <!nowrapper !noandroid>,
#               google-android-toolchain-llvm-project-installer <!nowrapper !noandroid>,
#               google-android-bionic-installer <!nowrapper !noandroid>,
-DCOOLPROP_ANDROID_MODULE=ON -DNDK_PATH:FILEPATH="/usr/lib/android-sdk/ndk-bundle"
for Android 4.1 (KitKat) ARMv7 API 19 for NDK Release 25c − that is, the last support-providing. 

two latter DEB packages were custom made to add/reflect upon the `bionic` and `toolchain/llvm-project/libcxx` [bind-mounted over `sources/cxx-stl/llvm-libc++`] folder(s) under the $NDK_ROOT/PATH which were missing from the first one (readily available or easily made).

Please, note (if relevant) there's no longer `liboctave-dev` Debian package in the wild but `octave-dev` swallowing the former (sorry if cannot follow-up further, life where I am is demanding).

Thank you for your wonderful `CoolProp.i` SWIG library which has made all this fantastic features auto-magically enabling! 

Best,
V.L.
Reply all
Reply to author
Forward
0 new messages