CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 4 of 4 FirstFirst 1234
Results 46 to 50 of 50
  1. #46
    Join Date
    Jul 2020
    Posts
    32

    Re: Problem with cmath/gsl

    Unfortunately, I can not compile it with 32 bit libraries in Matlab. I get the same error as previously, see below. Probably the 64bit MSVC compiler in Matlab environment does not accept the 32bit .lib files.
    I tried to compile the code with sizeof(*int) instead of sizeof(int), but also did not help.
    Would you find a while to adapt that file (…\spike\info\metric\metricdist.c) to be able to run it on your machine with that example input variables and check what was wrong.
    I would be again very grateful for your help.


    >> mex -g info\binless\binlessinfo.c input_c.obj input_mx.obj gen_c.obj gen_mx.obj sort_c.obj entropy_bub_c.obj entropy_bub_mx.obj entropy_c.obj entropy_chaoshen_c.obj entropy_jack_c.obj entropy_ma_c.obj entropy_mx.obj entropy_nsb_c.obj entropy_nsb_mx.obj entropy_plugin_c.obj entropy_tpmc_c.obj entropy_tpmc_mx.obj entropy_ww_c.obj entropy_ww_mx.obj variance_boot_c.obj variance_boot_mx.obj variance_jack_c.obj hist_c.obj hist_mx.obj info\binless\BinlessInfoComp.c shared\MatrixToHist2DComp.c shared\Info2DComp.c info\binless\binless_mx.c ...
    'G:\DATA_WS\Fabian\STAToolkit\spike\MRCGSL\VS2015\lib\x86_debug\gsl.lib' ...
    'G:\DATA_WS\Fabian\STAToolkit\spike\MRCGSL\VS2015\lib\x86_debug\cblas.lib'

    Error using mex
    Creating library binlessinfo.lib and object binlessinfo.exp
    entropy_bub_c.obj : error LNK2019: unresolved external symbol gsl_vector_calloc referenced in function bag1
    entropy_bub_c.obj : error LNK2019: unresolved external symbol gsl_vector_free referenced in function bag1
    entropy_bub_c.obj : error LNK2019: unresolved external symbol gsl_matrix_calloc referenced in function bag1
    entropy_bub_c.obj : error LNK2019: unresolved external symbol gsl_matrix_free referenced in function bag1
    entropy_bub_c.obj : error LNK2019: unresolved external symbol gsl_linalg_SV_decomp referenced in function bag1
    entropy_bub_c.obj : error LNK2019: unresolved external symbol gsl_linalg_SV_solve referenced in function bag1
    entropy_bub_c.obj : error LNK2019: unresolved external symbol gsl_sf_lngamma referenced in function make_binom
    entropy_nsb_c.obj : error LNK2001: unresolved external symbol gsl_sf_lngamma

  2. #47
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Problem with cmath/gsl

    file (…\spike\info\metric\metricdist.c)
    That file contains just one function mexFunction(). If you provide a main() wrapper that calls mexFunction(), I'll have a look.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #48
    Join Date
    Jul 2020
    Posts
    32

    Re: Problem with cmath/gsl

    I did some research online and I found out that the lines making problems like:
    d_dims = (int *)mxMalloc(3*sizeof(int));
    could be corrected probably in that way:
    d_dims = (mwSize*)mxMalloc(4*sizeof(mwSize));
    i.e. replacing the ‘int’ by ‘mwSize’

    After recompiling the code, the mexw64 files seems to work properly.

    1. Do you think it is a proper solution to the above problem ?

    2. I found more ‘c’ files (12 of ~40) with exactly the same memory allocation like above. Is it possible that at other instances that memory allocation with ‘int’ may work, but it did problems at only one particular point?
    My second question would be, should I correct all that 12 lines from ‘int’ to ‘mwSize’ as above to avoid any potential problems or leave it as it is until any problems appear.

  4. #49
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Problem with cmath/gsl

    1. Without a study of the code, I couldn't say. If it works...... What's the value of sizeof(mwSize) ? if 4 * sizeof(mwSize) is > 3 * sizeof(int), then discounting possible 'wasted' memory (allocation being too big for what's needed), I don't see a problem. But why 4?? What's the type of mwSize? What's the values of sizeof(mwSize) and sizeof(int)?

    2. Again, without a study of the code, I couldn't say. The same comment as for 1) applies re size.

    These are the sort of problems I would expect when compiling code that previously was OK for 32 bit as 64 bit - as sizes under 64 bit are not inter-changeable as they would be under 32 bit.
    Last edited by 2kaud; July 29th, 2020 at 12:19 PM.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  5. #50
    2kaud's Avatar
    2kaud is online now Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: Problem with cmath/gsl

    PS. I don't see anywhere in the code I've seen where testing is done for failed memory allocation? Normally, in c after every allocation there would be a test that the allocation was successful - or not.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

Page 4 of 4 FirstFirst 1234

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured