User forums > Using Code::Blocks

Undefined reference

(1/1)

Kaz:
Hello, I'm tryin to compile a program. And although command line works perfectly, I can't seem to do the same thing from Code::Blocks. Could you tell me how I can solve this? Thanks in advance.

This one below is the command in in command line

$ g++ -std=c++11 -I /usr/local/MATLAB/R2021a/extern/include/ -L /usr/local/MATLAB/R2021a/extern/bin/glnxa64/ -pthread main.cpp -lMatlabDataArray -lMatlabEngine

And the attached image is (a part of) the build log in Code::Blocks.

BlueHazzard:
You have to split linker and compiler options

your compiler options:

--- Code: ----std=c++11
-I /usr/local/MATLAB/R2021a/extern/include/

--- End code ---

the linker options:

--- Code: ----L /usr/local/MATLAB/R2021a/extern/bin/glnxa64/
-lMatlabDataArray
-lMatlabEngine

--- End code ---

In Project->Build options->Select your project name on the left->Compiler settings->Compiler flags-> Tick the c++11 flag
In Project->Build options->Select your project name on the left->Search directories->Compiler->Add-> "/usr/local/MATLAB/R2021a/extern/include/"
In Project->Build options->Select your project name on the left->Search directories->Linker->Add-> "/usr/local/MATLAB/R2021a/extern/bin/glnxa64/"
In Project->Build options->Select your project name on the left->Linker settings->Link libraries->Add-> "MatlabDataArray"
In Project->Build options->Select your project name on the left->Linker settings->Link libraries->Add-> "MatlabEngine"
In Project->Build options->Select your project name on the left->Linker settings->Other options-> "-pthread"

Kaz:
Thank you very much. Now it perfectly works!



--- Quote from: BlueHazzard on May 06, 2021, 03:48:09 pm ---You have to split linker and compiler options

your compiler options:

--- Code: ----std=c++11
-I /usr/local/MATLAB/R2021a/extern/include/

--- End code ---

the linker options:

--- Code: ----L /usr/local/MATLAB/R2021a/extern/bin/glnxa64/
-lMatlabDataArray
-lMatlabEngine

--- End code ---

In Project->Build options->Select your project name on the left->Compiler settings->Compiler flags-> Tick the c++11 flag
In Project->Build options->Select your project name on the left->Search directories->Compiler->Add-> "/usr/local/MATLAB/R2021a/extern/include/"
In Project->Build options->Select your project name on the left->Search directories->Linker->Add-> "/usr/local/MATLAB/R2021a/extern/bin/glnxa64/"
In Project->Build options->Select your project name on the left->Linker settings->Link libraries->Add-> "MatlabDataArray"
In Project->Build options->Select your project name on the left->Linker settings->Link libraries->Add-> "MatlabEngine"
In Project->Build options->Select your project name on the left->Linker settings->Other options-> "-pthread"

--- End quote ---

Navigation

[0] Message Index

Go to full version