Skip to content
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

Building on Windows (VS2015 Win64) - Linker Errors #11

Closed
herzig opened this issue Jul 2, 2018 · 11 comments
Closed

Building on Windows (VS2015 Win64) - Linker Errors #11

herzig opened this issue Jul 2, 2018 · 11 comments

Comments

@herzig
Copy link

herzig commented Jul 2, 2018

I have problems building TetWild on Windows. CGAL 4.12 is installed and working (examples work).
cmake can generate build files (VS Projects & sln)
geogram.lib seems to be compiling fine (using VS2015)

then building lib_tetwild fails with the following linker error:

1>------ Build started: Project: lib_tetwild, Configuration: Release x64 ------
1>MeshRefinement.obj : error LNK2019: unresolved external symbol "struct GEO::CellDescriptor * * GEO::MeshCellDescriptors::cell_type_to_cell_descriptor" (?cell_type_to_cell_descriptor@MeshCellDescriptors@GEO@@3PAPEAUCellDescriptor@2@A) referenced in function "public: unsigned int __cdecl GEO::MeshCells::create_cells(unsigned int,enum GEO::MeshCellType)" (?create_cells@MeshCells@GEO@@QEAAIIW4MeshCellType@2@@Z)
1>D:\proj\TetWild\build\Release\TetWild.dll : fatal error LNK1120: 1 unresolved externals
2>------ Build started: Project: TetWild, Configuration: Release x64 ------
2>LINK : fatal error LNK1181: cannot open input file 'Release\TetWild.lib'
========== Build: 0 succeeded, 2 failed, 5 up-to-date, 0 skipped ==========

geogram.lib seems to be fine, and is found by the linker as only this single symbol is causing a problem.

Thanks for you help!

@Yixin-Hu
Copy link
Owner

Yixin-Hu commented Jul 2, 2018

@herzig
Copy link
Author

herzig commented Jul 2, 2018

Just did, still the same result
Here's the cmake output:

Selecting Windows SDK version  to target Windows 10.0.17134.
No build type selected, default to Release
Using local options file: D:/proj/TetWild/extern/geogram/CMakeOptions.txt
Configuring build for standalone Geogram (without Vorpaline)
Configuring 64 bits build
Doxygen >= 1.7.0 not found, cannot generate documentation
Boost version: 1.67.0
Boost include dirs: C:/dev/boost_1_67_0
Boost libraries:    
Found CGAL: C:/dev/CGAL-4.12/build
Boost version: 1.67.0
Found the following Boost libraries:
  thread
  system
  chrono
  date_time
  atomic
Could NOT find Matlab (missing: Matlab_INCLUDE_DIRS Matlab_MEX_LIBRARY Matlab_MEX_EXTENSION MEX_COMPILER MX_LIBRARY ENG_LIBRARY) (found version "unknown")
Could NOT find MOSEK (missing: MOSEK_LIBRARIES MOSEK_INCLUDE_DIR) 
Creating target: igl::core
Found CGAL: C:/dev/CGAL-4.12/build
Creating target: igl::cgal
Boost version: 1.67.0
Found the following Boost libraries:
  thread
  system
  chrono
  date_time
  atomic
Configuring done
Generating done

Also the complete build output:
tetwild_vs14win64.txt

@Yixin-Hu
Copy link
Owner

Yixin-Hu commented Jul 2, 2018

Could you try using older version of geogram, like version ~1.5.5?

@herzig
Copy link
Author

herzig commented Jul 2, 2018

Tried with 1.5.5 and 1.5.2, unfortuneately, exactly the same result for both version.

Maybe I am using the wrong, cmake generator/VS version, which did you use to test it under Windows?

@trelau
Copy link
Contributor

trelau commented Jul 3, 2018

@herzig you may have a look here https://github.com/trelau/TetWild/commits/reorg

For Windows, nothing was being exported to the shared library so it didn't generate TetWild.lib. I made some changes as outlined in the commit history that includes:

  • Build a static lib when building an executable

  • Build a shared lib only when NOT building an executable (this will be nice if using tetwild in a different program)

Still some things that need cleaned up but I think I'm on the right track...

@herzig
Copy link
Author

herzig commented Jul 3, 2018

@trelau Could you get it working with your version?

I have the same issue as before. geogram.lib is created fine, but then linking tetwild_lib fails.

I tried to use the dumpbin utility to list all symbols defined in geogram.lib, and the supposedly missing symbol
?cell_type_to_cell_descriptor@MeshCellDescriptors@GEO@@3PAPEAUCellDescriptor@2@A (struct GEO::CellDescriptor * * GEO::MeshCellDescriptors::cell_type_to_cell_descriptor)
is listed in the output. Why the linker can not find the symbol is beyond me, any ideas?

Full output of dumpbin /exports geogram.lib :
geogram_lib_exports.txt

@trelau
Copy link
Contributor

trelau commented Jul 3, 2018

@herzig in my branch, when i turn BUILD_WITH_DEBUG to OFF the TetWild.exe will build and link to the static libTetWild.lib (I renamed some stuff). All this switch does is not compile things that use PyMesh to write out stuff (I plan to change this). But, this tells us something, although it's strange that an unresolved external to what seems like geogram shows up in the code that is being left out with BUILD_WITH_DEBUG...?

@herzig
Copy link
Author

herzig commented Jul 3, 2018

@trelau Sorry I mixed up my working copies, embarassing... I can build your branch fine (with BUILD_WITH_DEBUG OFF). i generates an exe, and I just successfully meshed a geometry that all other simple meshing tools failed to mesh. Awesome project!

@trelau
Copy link
Contributor

trelau commented Jul 3, 2018

@herzig Great! I just took a step back and pushed a branch that builds the basic exe https://github.com/trelau/TetWild/commit/78aa7fc42750e6dce1278890c97c5428af46b47c I had to comment out some code to resolve the external, so looking for the root cause now. This should now represent the initial state of @Yixin-Hu 's code. I'm thinking about refactoring the API a little in the tetwild.h file (use a single class to define parameters and load/retrieve mesh) to make it easier to optionally build as a shared lib. If you're looking to contribute the next step will be to optimize for speed!

@herzig
Copy link
Author

herzig commented Jul 5, 2018

I could resolve the linker issue by moving the definition for the static function MeshCellsStore::cell_type_to_cell_descriptor in geogram mesh.h to the mesh.cpp file.

mesh.h now looks like this:

		static const CellDescriptor& cell_type_to_cell_descriptor(
			MeshCellType t
		);

and this added to mesh.cpp

	const CellDescriptor& MeshCellsStore::cell_type_to_cell_descriptor(
		MeshCellType t
	) {
		geo_debug_assert(t < GEO::MESH_NB_CELL_TYPES);
		return *(MeshCellDescriptors::cell_type_to_cell_descriptor[t]);
	}
    

I can build tetwild.exe now without any problems and using background meshes (the part that was causing linker problems) now works as well.

@herzig herzig closed this as completed Jul 5, 2018
@jdumas
Copy link
Contributor

jdumas commented Jul 25, 2018

Just FYI, the linking issue with Geogram should be fixed with the latest version (1.6.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

4 participants