Author Topic: Code::Blocks +GCC64 + MATLAB  (Read 5127 times)

Offline dbs584

  • Single posting newcomer
  • *
  • Posts: 2
Code::Blocks +GCC64 + MATLAB
« on: September 13, 2023, 08:43:51 pm »
Dear Friends,

I hope this message finds you well. I am writing to seek guidance on configuring Code::Blocks for the compilation of Pure C source code, specifically with the inclusion of the "engine.h" header file. I am a dedicated user of Code::Blocks and have come to appreciate its versatility; however, I am aware that integrating such components has posed challenges in the past.

Could you kindly provide instructions or insights on how to set up Code::Blocks to compile Pure C source code while incorporating the necessary "engine.h" header file? Additionally, I am interested in understanding how to compile source code that is linked to MATLAB for seamless integration. Any guidance or best practices you can share in this regard would be greatly appreciated.

Thank you in advance for your assistance, and I look forward to your response.

Warm regards,

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Code::Blocks +GCC64 + MATLAB
« Reply #1 on: September 13, 2023, 10:10:23 pm »
Link to wiki page https://wiki.codeblocks.org/index.php/Main_Page
Link to this website rules https://forums.codeblocks.org/index.php/topic,9996.0.html

I suggest posting your compiler information if you cannot figure what is needed to set it up in Code::Blocks.
Location/Path installed?
Where compiler was downloaded from?

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline dbs584

  • Single posting newcomer
  • *
  • Posts: 2
Re: Code::Blocks +GCC64 + MATLAB
« Reply #2 on: September 14, 2023, 07:02:43 pm »
My compiler is MSYS2 downloaded from official site, updated.
The code is simple
===================
#include <stdio.h>
#include <stdlib.h>
#include <engine.h>

int main() {
    Engine *ep;
    mxArray *result = NULL;

    if (!(ep = engOpen(NULL))) {
        fprintf(stderr, "No MATLAB Engine\n");
        return 1;
    }

    engEvalString(ep, "x = 5; y = x^2;");

    result = engGetVariable(ep, "y");
    if (result) {
        double *data = mxGetPr(result);
        printf("Square: %lf\n", data[0]);
        mxDestroyArray(result);
    }

    engClose(ep);

    return 0;
}
=================
The settings are "Compiler - Search directories - Compiler - C:\Program Files\MATLAB\R2022a\extern\include\"
"Compiler - Search directories - Linker - C:\Program Files\MATLAB\R2022a\extern\lib\win64\mingw64\"


Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Re: Code::Blocks +GCC64 + MATLAB
« Reply #3 on: September 14, 2023, 07:07:31 pm »
So, I am guessing you have no toolchain setup problem; since you failed to post the information needed to setup CB to use the Compiler.

Edit: I have no idea how to use MATLAB; but, the MATLAB directions suggested only a certain version of the MINGW compiler are supported.

Tim S.
« Last Edit: September 14, 2023, 07:10:04 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org