BrunoLevy / geogram

a programming library with geometric algorithms
Other
1.8k stars 122 forks source link

linker errors for mesh_difference, mesh_remove_intersections #122

Closed kasunJKD closed 9 months ago

kasunJKD commented 9 months ago

I'm creating a c# wrapper for boolean operations and inflating the mesh (c++ clr/CLI to create a dll). so far every other functions are working but im getting these linker errors for these two functions

Severity Code Description Project File Line Suppression State Error LNK2028 unresolved token (0A000AAE) "void cdecl GEO::mesh_difference(class GEO::Mesh &,class GEO::Mesh &,class GEO::Mesh &)" (?mesh_difference@GEO@@$$FYAXAEAVMesh@1@00@Z) referenced in function "public: void clrcall geogrammanageddll::Geogrammanaged::Boolean_operations(void)" (?Boolean_operations@Geogrammanaged@geogrammanageddll@@$$FQE$AAMXXZ) geogram_managed_dll D:\work\geometrylibrary\geogram_managed_dll\geogram_managed_dll.obj 1

Severity Code Description Project File Line Suppression State Error LNK2028 unresolved token (0A000AB5) "void cdecl GEO::mesh_remove_intersections(class GEO::Mesh &,unsigned int)" (?mesh_remove_intersections@GEO@@$$FYAXAEAVMesh@1@I@Z) referenced in function "public: void clrcall geogrammanageddll::Geogrammanaged::fix_mesh_for_boolean_ops_managed(class GEO::Mesh &)" (?fix_mesh_for_boolean_ops_managed@Geogrammanaged@geogrammanageddll@@$$FQE$AAMXAEAVMesh@GEO@@@Z) geogram_managed_dll D:\work\geometrylibrary\geogram_managed_dll\geogram_managed_dll.obj 1

Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol "void cdecl GEO::mesh_remove_intersections(class GEO::Mesh &,unsigned int)" (?mesh_remove_intersections@GEO@@$$FYAXAEAVMesh@1@I@Z) referenced in function "public: void clrcall geogrammanageddll::Geogrammanaged::fix_mesh_for_boolean_ops_managed(class GEO::Mesh &)" (?fix_mesh_for_boolean_ops_managed@Geogrammanaged@geogrammanageddll@@$$FQE$AAMXAEAVMesh@GEO@@@Z) geogram_managed_dll D:\work\geometrylibrary\geogram_managed_dll\geogram_managed_dll.obj 1

Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol "void cdecl GEO::mesh_difference(class GEO::Mesh &,class GEO::Mesh &,class GEO::Mesh &)" (?mesh_difference@GEO@@$$FYAXAEAVMesh@1@00@Z) referenced in function "public: void clrcall geogrammanageddll::Geogrammanaged::Boolean_operations(void)" (?Boolean_operations@Geogrammanaged@geogrammanageddll@@$$FQE$AAMXXZ) geogram_managed_dll D:\work\geometrylibrary\geogram_managed_dll\geogram_managed_dll.obj 1

I dont exactly know why this is happening, since other functions are compiling without any issues.

BrunoLevy commented 9 months ago

Hi, These three functions have changed prototype recently (and have an additional boolean "verbose" parameter), what could cause this error could be a .h that does not match the .cpp. Which version of geogram are you using ?

In both case the solution is to checkout the latest version 1.8.7-rc (then please tell me how it went)

kasunJKD commented 9 months ago

Hi Thank you for the quick respond , I've been using the latest from main still have same issue, where can i find version 1.8.7-rc ?

BrunoLevy commented 9 months ago

1.8.7-rc is what you get from the git repo.

A quick question to help our investigation: do you encounter any problem when following standard compilation instructions ? here

kasunJKD commented 9 months ago

no its working

BrunoLevy commented 9 months ago

TL;DR most probable hypothesis at the end of this message OK (so it eliminates a first potential source of problems). I would have been astonished (because we have continuous integration on all platforms, including Windows, and nothing seems to be broken there).

The error message appears when you link which library ? (I think it is the library that wraps geogram and exposes it to C#, right ?). Something important with DLLs under windows is that each compilation unit needs to know which symbol it imports and which symbol it exports. For that, we have a GEOGRAM_API macro that expands to declspec(DLLexport) when we compile geogram and that expands to declspec(DLLimport) when compiling code that uses geogram, so if a symbol is not found it is related with that. I first sought that I had forgotten to put GEOGRAM_API in the prototype of these functions but I checked and it is there. Another possibility is that there is a more global problem in the compilation and it does not see any symbol but starts barking at the first few ones it does not see. Do you have a tool under Windows to inspect the symbols exported by a DLL ?

Thinking a bit more about that, I'm very astonished by the prototype of the function:

void __cdecl GEO::mesh_difference(class GEO::Mesh &,class GEO::Mesh &,class GEO::Mesh &);

The prototype of the function should be:

void __cdecl GEO::mesh_difference(class GEO::Mesh &,class GEO::Mesh &,class GEO::Mesh &, bool);

Since the last boolean parameter was added very recently, I'm suspecting that an outdated mesh_surface_intersection.h is floating somewhere and included by the compiled file.

So to figure out, I'd do a file search on mesh_surface_intersection.h, double check which one is used and double check whether the functions have the boolean (if they don't, it is a wrong outdated header).

Another possibility: maybe you checked out geogram, built your wrapper, then updated geogram, then rebuilt the wrapper but with a build system that does not know the dependency between your wrapper and geogram. To figure out, I'd redo a full build from scratch (or using clean solution in visual C++, not sure of the exact name). I'd bet for this hypothesis, so try this first

kasunJKD commented 9 months ago

issue is fixed. Thank you for your time, what worked for me , after i update the repo even after i cleaned and rebuilt gfx obj has been the old one. so i had to re clone the repo into another dir and compile. maybe a visual studio issue ? but that worked for me