CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 4 FirstFirst 1234 LastLast
Results 16 to 30 of 50

Thread: Problem with cmath/gsl

  1. #16
    Join Date
    Jul 2020
    Posts
    23

    Re: Problem with cmath

    Thanks for the link, I have installed for it the DEV\vcpkg and Git before I started the whole work.

    Thank you very much for the instructions. I tried to add into old compilation line the extra element ‘gsl-2.6\vector\init_source.c’ like below, but got many syntax like errors.
    Could you pls help to remove them, is it again incompatibility between c and cpp.


    >> mex -c entropy\entropy_bub_c.c entropy\entropy_bub_mx.c entropy\entropy_c.c entropy\entropy_chaoshen_c.c entropy\entropy_jack_c.c entropy\entropy_ma_c.c entropy\entropy_mx.c entropy\entropy_nsb_c.cpp entropy\entropy_nsb_mx.cpp entropy\entropy_plugin_c.c entropy\entropy_tpmc_c.c entropy\entropy_tpmc_mx.c entropy\entropy_ww_c.c entropy\entropy_ww_mx.c entropy\variance_boot_c.c entropy\variance_boot_mx.c entropy\variance_jack_c.c shared\hist_c.c shared\hist_mx.c gsl-2.6\vector\init_source.c


    Building with 'Microsoft Visual C++ 2019'.
    Error using mex
    init_source.c
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(20): error C2143: syntax error: missing '{' before '*'
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(22): error C2091: function returns function
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(23): warning C4013: 'TYPE' undefined; assuming extern returning int
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(23): error C2065: 'gsl_block': undeclared identifier
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(23): error C2065: 'block': undeclared identifier
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(23): warning C4552: '*': result of expression not used
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(24): error C2065: 'v': undeclared identifier
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(24): warning C4552: '*': result of expression not used
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(26): error C2065: 'v': undeclared identifier
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(26): error C2059: syntax error: ')'
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(28): error C2065: 'v': undeclared identifier
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(30): warning C4013: 'GSL_ERROR_VAL' undefined; assuming extern returning int
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(31): error C2065: 'GSL_ENOMEM': undeclared identifier
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(34): error C2065: 'block': undeclared identifier
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(34): error C2065: 'gsl_block': undeclared identifier
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(34): error C2065: 'n': undeclared identifier
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(34): warning C4047: '=': 'int' differs in levels of indirection from 'int *'
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(36): error C2065: 'block': undeclared identifier
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(38): warning C4013: 'free' undefined; assuming extern returning int
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(38): error C2065: 'v': undeclared identifier
    G:\DATA_WS\Fabian\STAToolkit\spike\gsl-2.6\vector\init_source.c(41): error C2065: 'GSL_ENOMEM': undeclared identifier

    and many, many more such errors

  2. #17
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,257

    Re: Problem with cmath

    The TYPE macro (and probably others) can't be found by the compiler (3rd error line) as the file in which they are defined (??) isn't being included as part of the compile.

    The link in post #15 describes how to install gsl for VS. If you are still having problems with gsl after this, then I'm sorry I can't be of more help. gsl, as provided and downloaded, is designed to be installed onto a gnu system (linux or cygwin for Windows) that supports the make environment. I don't (and haven't) used that environment.

    Maybe some other guru may be able to offer further help with gsl for Visual Studio.
    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++17 Compiler: Microsoft VS2019 (16.7.3)

  3. #18
    Join Date
    Jul 2020
    Posts
    23

    Re: Problem with cmath

    Thank you for your last post. I did some investigation and would have a question.
    I can execute in my MSVC attached cpp file what means that the GSL libs are properly installed/connected to MSVC.

    When you tested my software, did you compile the below example line in MSVC only or you have used Matlab mex wrapper. If you have used the MSVC only could you pls explain me how you made that compilation. Maybe I could make now a proper compilation with added definition of function from the missing .c files.
    Would it be possible to create mexw64 file in MSVC environment only without Matlab?

    >> mex -c entropy\entropy_bub_c.c entropy\entropy_bub_mx.c entropy\entropy_c.c entropy\entropy_chaoshen_c.c entropy\entropy_jack_c.c entropy\entropy_ma_c.c entropy\entropy_mx.c entropy\entropy_nsb_c.cpp entropy\entropy_nsb_mx.cpp entropy\entropy_plugin_c.c entropy\entropy_tpmc_c.c entropy\entropy_tpmc_mx.c entropy\entropy_ww_c.c entropy\entropy_ww_mx.c entropy\variance_boot_c.c entropy\variance_boot_mx.c entropy\variance_jack_c.c shared\hist_c.c shared\hist_mx.c

    ----------------------
    If the above would not work, then, is it very difficult to create the .dll for the GSL library on my own with MSVC?
    I found compiled library ‘gsl-2.2.1_mingw-6.2.0’ with files named ‘libgsl-19.dll’ and ‘libgslcblas-0.dll’ at https://sourceforge.net/projects/gnu...brary-windows/
    At your post #14 you wrote that when I would have GSL .dll library then I could use/link them. Could you pls advise how to link that library, I am not sure how to do it.
    Attached Files Attached Files

  4. #19
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,257

    Re: Problem with cmath

    did you compile the below example line in MSVC only or you have used Matlab mex wrapper
    I compiled within MSVC when testing the cmath issue using the provided files. Once I'd sorted the compile errors, I still got plenty of linker errors (that you're getting). For the issue of the cmath compilation issues, this didn't matter.

    Re the link errors and .dll files. As you just posted the gsl headers, I wondered if the gsl had been previously compiled to a .dll file on Windows. If it had then there would be 2 files named something like gsl.dll and gsl.lib somewhere on the computer (the names could be different but I'd expect gsl to be there somewhere and with .dll and .lib extensions).

    The files referenced in the sourceforge link are for mingw or for cygwin (both providing a GNU environment) - not for Visual Studio. I know nothing about the GNU enviromnent and can't provide any help regarding them.

    Re compiling gsl within Visual Studio. Without being able to use the GNU make files, it will take a bit of work to get gsl to compile and link OK. The .c files don't have the required .h files specified so you can't just add them to a project. You probably need to include them after the appropriate headers (yes you can include .c files as well as .h files). I might have a try over the next 3 - 4 days if I have the time.

    [Does any other codeguru have any experience compiling/using gsl with Visual Studio?]
    Last edited by 2kaud; July 24th, 2020 at 01:54 AM.
    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++17 Compiler: Microsoft VS2019 (16.7.3)

  5. #20
    Join Date
    Jul 2020
    Posts
    23

    Re: Problem with cmath

    Thank you for your reply. Sorry, I am not expert from all those environments, so mixed them up. I would be extremely grateful if you could help in compiling the gsl for MSVC and next get the linking process working which would help me to get finally the correct mexw64 files. So, I think we should concentrate only on MSVC and Matlab. I understand that when we get the linking problems sorted out then I would be able properly compile/link and generate the mexw64 files in Matlab (with my old long Matlab commands) using MSVC compiler/linker. It is important for me to use MSVC environment to build the mexw64 files, because later I would be able to connect/attach Matlab to MSVC and switch between their debuggers.
    There is no rush, of course when you would have free time to work on it.

    Some old procedures, how to make the toolbox running, are described in file: \spike\doc\install.html
    They say that we need the gsl library compiled for MSVC to get the linking process working and mexw64 files built.

    If I could help in anything in the meantime, please let me know. I will try to learn more about compiling gsl to dll libraries in MSVC. Is something else I should have a look at?

    I did not ask any other guru for help.

  6. #21
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,257

    Re: Problem with cmath

    I did not ask any other guru for help.
    That was me asking if any other codeguru reading this thread could provide further info.
    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++17 Compiler: Microsoft VS2019 (16.7.3)

  7. #22
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,257

    Re: Problem with cmath

    I've had a look at compiling gsl within VS without using the GNU make system. Unfortunately it's an absolute nightmare - so I won't be able to help further with this.
    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++17 Compiler: Microsoft VS2019 (16.7.3)

  8. #23
    Join Date
    Jul 2020
    Posts
    23

    Re: Problem with cmath

    Thanks for your last post.
    As far as I understand you are not familiar with GNU make tool. Is it absolutely necessary to use the GNU make to perform the gsl compilation in MSVC? Should I try to search for the help from GNU make guru?

    Or, maybe I could do the nightmare job and you would only finalise it with MSVC?
    Can you advise where the problem is and how we could sort it out.

  9. #24
    Join Date
    Jul 2020
    Posts
    23

    Re: Problem with cmath

    Can you have a look at the link https://mrcdata.dide.ic.ac.uk/wiki/i...es_for_Windows
    I managed to create the GSL.dll library, but it has a very small size. There is no .lib file.
    Maybe we could use the binaries for VS2015 in MSVC2019 as we need the GSL functions for software written in 2010 ?

  10. #25
    Join Date
    Jul 2020
    Posts
    23

    Re: Problem with cmath

    Why we can not take and use the gsl .dll and .lib files from from the gsl installed from the link https://solarianprogrammer.com/2020/...s-macos-linux/ (post#15)
    Pls see attached the list of gsl libraries on my HDD.
    Attached Images Attached Images   

  11. #26
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,257

    Re: Problem with cmath

    The mrcdata VS2015 lib/dll files work fine with VS2019! The test code on the mrcdata link compiles, links and works fine.

    So does your test code in post #18!
    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++17 Compiler: Microsoft VS2019 (16.7.3)

  12. #27
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,257

    Re: Problem with gsl

    [Title changed to reflect issue with gsl so that users of this forum looking for help with gsl fund this thread]
    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++17 Compiler: Microsoft VS2019 (16.7.3)

  13. #28
    Join Date
    Jul 2020
    Posts
    23

    Re: Problem with gsl

    Thank you very much for your reply. It looks that we sorted the problem out.
    I would be very grateful if could explain me step by step how you compiled the mrcdata VS2015 in MSVC2019 to get the required gsl.dll and gsl.lib files. I mean you probably had to create the dll project in MSVC etc.. Then how they were made visible to mex wrapper in Matlab to properly compile/link and build the mexw64 files with MSVC2019 compiler. I would like to be able to repeat all that steps on my machine on my own. Thanks.

  14. #29
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,257

    Re: Problem with cmath/gsl

    The mrcdata gsl VS2015 zip file contains all the required gsl .lib, .dll and include files (for x64/86 and debug/release) to enable code using gsl functions to be compiled and linked OK with VS. The site has instructions as to how to use them within VS.
    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++17 Compiler: Microsoft VS2019 (16.7.3)

  15. #30
    Join Date
    Jul 2020
    Posts
    23

    Re: Problem with cmath/gsl

    Thank you for your post. I did everything what the instructions asked to do on the mrcdata website and ended with with two new directories as described in the GSL_01.docx file. I am not sure what is the function of those new dll files in Debug and Release dirs. What that prescription on mrcata website was for when we have ready to use VS2015 dll and lib files.

    Pls let me know how you compiled and linked my long mex instruction in MSVC, can you attach your MSVC files/project then I would try to repeat it from my side. It would the easiest way to test it on my end.
    What I need to do to be able (using these ready to use dll and lib files from mrcdata) to compile/link/build mexw64 files in Matlab environment using MSVC compiler. I mean, should I set some parameters in MSVC, setup some special pathnames?


    (3)
    >> mex -c entropy\entropy_bub_c.c entropy\entropy_bub_mx.c entropy\entropy_c.c entropy\entropy_chaoshen_c.c entropy\entropy_jack_c.c entropy\entropy_ma_c.c entropy\entropy_mx.c entropy\entropy_nsb_c.cpp entropy\entropy_nsb_mx.cpp entropy\entropy_plugin_c.c entropy\entropy_tpmc_c.c entropy\entropy_tpmc_mx.c entropy\entropy_ww_c.c entropy\entropy_ww_mx.c entropy\variance_boot_c.c entropy\variance_boot_mx.c entropy\variance_jack_c.c shared\hist_c.c shared\hist_mx.c


    (4)
    >> 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
    Attached Files Attached Files

Page 2 of 4 FirstFirst 1234 LastLast

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)