Skip to content

Problems compiling for ESP32 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
MatthewFehl365 opened this issue Aug 6, 2021 · 5 comments
Open

Problems compiling for ESP32 #1

MatthewFehl365 opened this issue Aug 6, 2021 · 5 comments

Comments

@MatthewFehl365
Copy link

Hello,

I'm trying to impliment this branch on the ESP32 but I've ran into some issues.

Code:
#include "C:\Users\mxf5351\Documents\Linear-Algebra-arduino\Linear-Algebra-arduino\src\Linear_Algebra.h"
#include "C:\Users\mxf5351\Documents\Linear-Algebra-arduino\Linear-Algebra-arduino\src\include\linalg\HouseholderQR.hpp"
#include "C:\Users\mxf5351\Documents\Linear-Algebra-arduino\Linear-Algebra-arduino\src\include\linalg\Matrix.hpp"

void setup(){
Matrix A = {
{11, 12, 13},
{21, 22, 23},
{31, 32, 33},
};
}
void loop() {}

Errors:
sketch\sketch_aug06a.ino.cpp.o:(.literal._ZNK6Matrix7printToER5Print[Matrix::printTo(Print&) const]+0x0): undefined reference to Matrix::print(Print&, unsigned char, unsigned char) const' sketch\sketch_aug06a.ino.cpp.o:(.literal._Z5setupv+0x4): undefined reference to SquareMatrix::SquareMatrix(std::initializer_list<std::initializer_list >)'
sketch\sketch_aug06a.ino.cpp.o: In function Matrix::printTo(Print&) const': C:\Users\mxf5351\Documents\Linear-Algebra-arduino\Linear-Algebra-arduino\src\include/linalg/Matrix.hpp:260: undefined reference to Matrix::print(Print&, unsigned char, unsigned char) const'
sketch\sketch_aug06a.ino.cpp.o: In function setup()': C:\Users\mxf5351\Documents\sketch_aug06a/sketch_aug06a.ino:10: undefined reference to SquareMatrix::SquareMatrix(std::initializer_list<std::initializer_list >)'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board DOIT ESP32 DEVKIT V1.

I'm stumped as to why this is occurring as these functions are absolutely defined in the library.

Any thoughts or suggestions would be greatly appriciated.

@tttapa
Copy link
Owner

tttapa commented Aug 6, 2021

#include "C:\Users\mxf5351\Documents\Linear-Algebra-arduino\Linear-Algebra-arduino\src\Linear_Algebra.h"

It's never a good idea to include headers using an absolute path.

Try installing the library using the Sketch > Include Library > Add .ZIP Library menu in the Arduino IDE, and then include the relative path, e.g. #include <Linear_Algebra.h>. If the library is not installed and included properly, the IDE will not link to it, resulting in the undefined reference errors you're seeing.

@MatthewFehl365
Copy link
Author

MatthewFehl365 commented Aug 7, 2021

Thank you for the help, I managed to get it to work after installing the library correctly but I also need to change the function in householdQR.cpp ComputeFactorization to not use std::copysign. I had to include the cmath header and remove the std:: namespace. Might be a small bug when compiling on ESP32 or it might be just my system.

@tttapa
Copy link
Owner

tttapa commented Aug 7, 2021

remove the std:: namespace

That's not a good idea, the compiler will not select the right overload of these C math functions, you have to use the C++ math functions prefixed with std::.

The latest CI run was successful for ESP32, so I'm not sure why you're seeing this error: https://github.com/tttapa/Linear-Algebra/runs/1942413800?check_suite_focus=true
It was a while ago, maybe there's a problem with a newer version of the ESP32 Arduino Core, I'll look into that on Monday.

@MatthewFehl365
Copy link
Author

Sounds good. Only the copysign function was throwing an error saying "std::copysign" is not a member of the std namespace.

@tttapa
Copy link
Owner

tttapa commented Aug 7, 2021

The examples compile successfully for me using Arduino 1.8.15 and ESP32 core version 1.0.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants