# mesh.addNormals() gives error

I have the following code from the Creative Coding Demystified book, but it gives me an error in Xcode:
I don’t understand this, since I use gym::vec3 for norm.

void setNormals( ofMesh &mesh ){
//The number of the vertices
int nV = mesh.getNumVertices();
//The number of the triangles
int nT = mesh.getNumIndices() / 3;
vectorglm::vec3 norm( nV ); //Array for the normals
//Scan all the triangles. For each triangle add its
//normal to norm’s vectors of triangle’s vertices
for (int t=0; t<nT; t++) {
//Get indices of the triangle t
int i1 = mesh.getIndex( 3 * t );
int i2 = mesh.getIndex( 3 * t + 1 );
int i3 = mesh.getIndex( 3 * t + 2 );
//Get vertices of the triangle
const ofPoint &v1 = mesh.getVertex( i1 );
const ofPoint &v2 = mesh.getVertex( i2 );
const ofPoint &v3 = mesh.getVertex( i3 );
//Compute the triangle’s normal
ofPoint dir = ( (v2 - v1).crossed( v3 - v1 ) ).normalized();
//Accumulate it to norm array for i1, i2, i3
norm[ i1 ] += dir;
norm[ i2 ] += dir;
norm[ i3 ] += dir;
}
//Normalize the normal’s length
for (int i=0; i<nV; i++) {
norm[i] = glm::normalize(norm[i]);
}
//Set the normals to mesh
mesh.clearNormals();

}

Blockquote
Undefined symbols for architecture x86_64:
“ofApp::setNormals(ofMesh_<glm::vec<3, float, (glm::qualifier)0>, glm::vec<3, float, (glm::qualifier)0>, ofColor_, glm::vec<2, float, (glm::qualifier)0> >&)”, referenced from:
ofApp::update() in ofApp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Blockquote

might just be the above line not declaring the vector correctly.
Needs to be:
`vector<glm::vec3> norm( nV ); //Array for the normals`

no, it did it that way. it must be sth else

This here works for me on macOS 10.15.7 with OF 0.11.0 on Xcode 12.4

Thank you, it works! it was just the namespace :: I forgot.

void ofApp::setNormals( ofMesh &mesh ){