sg-s / xolotl

A MATLAB neuron simulator. Very fast (written in C++). Flexible (fully object oriented). Immediate (live manipulation in MATLAB). Comes with a powerful parameter optimizer. Get started ➡️
https://go.brandeis.edu/xolotl
GNU General Public License v3.0
43 stars 8 forks source link

Trouble building C++ code from matlab #576

Closed alec-hoyland closed 3 years ago

alec-hoyland commented 3 years ago
>> mex -setup c++
MEX configured to use 'g++' for C++ language compilation.
>> mex -setup c
MEX configured to use 'gcc' for C language compilation.
>> version

ans =

    '9.9.0.1592791 (R2020b) Update 5'

>> build
Warning: Some C++ language constructs in the files for generating interface file are not supported and not imported.

Did not add member 'allchannels' to class 'compartment' at compartment.hpp:49.
  'conductance *' is not supported for element type of vector.

Did not add member 'allcompartments' to class 'xolotl' at xolotl.hpp:22.
  'compartment *' is not supported for element type of vector.

Using g++ compiler.
Generated definition file definexolotl.mlx and data file 'xolotlData.xml' contain definitions for 71 constructs supported by MATLAB.
1 construct(s) require(s) additional definition. To include these construct(s) in the interface, edit the definitions in definexolotl.mlx.
Build using build(definexolotl).
Building interface file 'xolotlInterface.so'.
Error using clibgen.internal.buildHelper (line 62)
Build failed with error:
'/home/alec/code/xolotl/experimental/xolotl.cpp: In member function ‘virtual void conductance::init()’:
/home/alec/code/xolotl/experimental/xolotl.cpp:155:9: error: ‘isnan’ was not declared in this scope; did you mean ‘std::isnan’?
  155 |     if (isnan(m)) {
      |         ^~~~~
      |         std::isnan
In file included from /home/alec/code/xolotl/experimental/conductance.hpp:6,
                 from /home/alec/code/xolotl/experimental/xolotl.cpp:10:
/usr/include/c++/10/cmath:632:5: note: ‘std::isnan’ declared here
  632 |     isnan(_Tp __x)
      |     ^~~~~
/home/alec/code/xolotl/experimental/xolotl.cpp:159:9: error: ‘isnan’ was not declared in this scope; did you mean ‘std::isnan’?
  159 |     if (isnan(h)) {
      |         ^~~~~
      |         std::isnan
In file included from /home/alec/code/xolotl/experimental/conductance.hpp:6,
                 from /home/alec/code/xolotl/experimental/xolotl.cpp:10:
/usr/include/c++/10/cmath:632:5: note: ‘std::isnan’ declared here
  632 |     isnan(_Tp __x)
      |     ^~~~~
'.

Error in clibgen.LibraryDefinition/build (line 630)
            clibgen.internal.buildHelper(obj, obj.LibraryInterface, '', directBuild);

Error in build (line 31)
build(libdef)
sg-s commented 3 years ago
  1. the new interface is totally independent of cpplab, so i moved it here
  2. yeah, gcc seems to be unhappy about std::isnan, so i explicitly added a namespace, maybe works now?
alec-hoyland commented 3 years ago

That's the conclusion I came to as well. You beat me to it. Builds now.

sg-s commented 3 years ago

nice, check out AB.channels(0) -- those are real pointers to the channels that exist in your workspace

alec-hoyland commented 3 years ago

That so elegant!

sg-s commented 3 years ago

and the nice thing is that once the library is built, you don't need to recompile any more. you can construct a completely new model, and everything happens instantly.