Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: dbs584 on September 13, 2023, 08:43:51 pm

Title: Code::Blocks +GCC64 + MATLAB
Post by: dbs584 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,
Title: Re: Code::Blocks +GCC64 + MATLAB
Post by: stahta01 on September 13, 2023, 10:10:23 pm
Link to wiki page https://wiki.codeblocks.org/index.php/Main_Page (https://wiki.codeblocks.org/index.php/Main_Page)
Link to this website rules https://forums.codeblocks.org/index.php/topic,9996.0.html (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.
Title: Re: Code::Blocks +GCC64 + MATLAB
Post by: dbs584 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\"

Title: Re: Code::Blocks +GCC64 + MATLAB
Post by: stahta01 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.