How do I link C symbols in my C++ program? [closed]

22 hours ago 1
ARTICLE AD BOX

I'm working on a C++ project to process 3D meshes. (https://github.com/blackears/cyclops_tetrahedralizer). I want to add a public domain C file that implements some advanced floating point mathematics. (https://github.com/libigl/libigl-predicates)

I'm using cmake to build the project and running into an issue where it says it can't find the symbol to link from the predicates file.

unresolved external symbol orient3d referenced in function "public: static double __cdecl CyclopsTetra3D::Math::test_orient_3d(struct CyclopsTetra3D::Vector3 const &,struct CyclopsTetra3D::Vector3 const &,struct CyclopsTetra3D::Vector3 const &,struct CyclopsTetra3D::Vector3 const &)" (?test_orient_3d@Math@CyclopsTetra3D@@SANAEBUVector3@2@000@Z)

The method is

class Math { public: ... static real test_orient_3d(const Vector3& pa, const Vector3& pb, const Vector3& pc, const Vector3& pd) { double a[3] = { pa.x, pa.y, pa.z }; double b[3] = { pb.x, pb.y, pb.z }; double c[3] = { pc.x, pc.y, pc.z }; double d[3] = { pd.x, pd.y, pd.z }; return orient3d(a, b, c, d); }

orient3d is defined in the predicates.c file.

I'm basically just trying to create a wrapper function in my math library for this C method, but I only have a basic understanding of how to put together my CMakeLists.txt file.

What do I need to change to get this project to link?


Edit:

Here's a simple cpp file that causes a link error:

unresolved external symbol orient3d referenced in function "void __cdecl test2(void)" (?test2@@YAXXZ) #include "predicates/predicates.h" void test2() { double a[3]; double b[3]; double c[3]; double d[3]; orient3d(a, b, c, d); } int main(int argc, char **argv) { test2(); return 0; }

I think this may relate to how cmake configures the build process. I don't know why the editor removed that tag.

Read Entire Article