Compiling openNURBS on mingw

First, many thanks for making openNURBS available. I have made several tweaks to the sources and makefiles so as to compile OpenNURBS with the Nuwen mingw compiler (64 bit Windows 10). The library is built successfully, however, a link error is encountered when trying to build “example_read”. Specifically, I get the following undefined references:

ON_Font::GetInstalledWindowsDWriteFonts
ON_Font::FontStretchFromDWriteStretch
ON_WindowsDWriteGetGlyphMetrics
ON_WindowsDWriteGetFontMetrics
ON_WindowsDWriteGetGlyphOutline

I have checked that opennurbs_font.o is compiled and linked into the library; attempts at changing the link order of the libs did not resolve the issue. I am hoping that an OpenNURBS developer might have a suggestion for a fix. Output at the link stage is:

C:/DEV/JCB/bin/g++  example_read/example_read.o example_userdata/example_ud.o -L. -lopennurbs_public -lfltk -lfltk_forms -lfltk_images -lfltk_cairo -lfltk_jpeg -lpng12 -lz -lglu32 -lopengl32 -lmingwex -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lcomctl32 -lwsock32 -lwinmm -lshlwapi -ldwrite -lrpcrt4 -lpthread -lm -o example_read/example_read
c:/dev/jcb/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./libopennurbs_public.a(opennurbs_font.o): in function `ON_ManagedFonts::Internal_GetWindowsInstalledFonts(ON_SimpleArray<ON_Font const*>&)':
C:\DEV\NSX_3\openNURBS\openNURBS-7.x/opennurbs_font.cpp:1566: undefined reference to `ON_Font::GetInstalledWindowsDWriteFonts(wchar_t const*, bool, bool, ON_SimpleArray<ON_WindowsDWriteFontInformation>&)'
c:/dev/jcb/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./libopennurbs_public.a(opennurbs_font.o): in function `ON_Font::ON_Font(ON_Font::FontType, ON_WindowsDWriteFontInformation const&)':
C:\DEV\NSX_3\openNURBS\openNURBS-7.x/opennurbs_font.cpp:8823: undefined reference to `ON_Font::FontStretchFromDWriteStretch(unsigned int, ON_Font::Stretch)'
c:/dev/jcb/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./libopennurbs_public.a(opennurbs_font.o): in function `ON_ManagedFonts::GetGlyphMetricsInFontDesignUnits(ON_Font const*, unsigned int, ON_TextBox&)':
C:\DEV\NSX_3\openNURBS\openNURBS-7.x/opennurbs_font.cpp:11927: undefined reference to `ON_WindowsDWriteGetGlyphMetrics(ON_FontGlyph const*, ON_TextBox&)'
c:/dev/jcb/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./libopennurbs_public.a(opennurbs_font.o): in function `ON_ManagedFonts::GetFontMetricsInFontDesignUnits(ON_Font const*, ON_FontMetrics&)':
C:\DEV\NSX_3\openNURBS\openNURBS-7.x/opennurbs_font.cpp:11975: undefined reference to `ON_WindowsDWriteGetFontMetrics(ON_Font const*, ON_FontMetrics&)'
c:/dev/jcb/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ./libopennurbs_public.a(opennurbs_glyph_outline.o): in function `ON_FontGlyph::GetOutline(bool, ON_Outline&) const':
C:\DEV\NSX_3\openNURBS\openNURBS-7.x/opennurbs_glyph_outline.cpp:2973: undefined reference to `ON_WindowsDWriteGetGlyphOutline(ON_FontGlyph const*, ON_OutlineFigure::Type, ON_Outline&)'
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:893: example_read/example_read] Error 1

I have ensured that the correct #defines are set with regard to my compiler, (for example, the freetype option and sources are ommitted). I have a hunch that I’m missing something basic here (I have not used dwrite before). Any ideas would be greatly appreciated.

Sincerely,

Nicholas Shea.

Looks like you’ll have to adapt the makefile a bit so that the .cpp file that implement those functions is compiled and linked in as well.

opennurbs_win_dwrite.h

Add abover header file to the end of the list ON_INC staring at https://github.com/mcneel/opennurbs/blob/7.x/makefile#L76

opennurbs_win_dwrite.cpp
And above cpp file to the end of the list ON_SRC starting at https://github.com/mcneel/opennurbs/blob/7.x/makefile#L227

2 Likes

Thanks Nathan, you were absolutely correct and your fix worked perfectly. I had done the same for opennurbs_gl.cpp but for some reason missed the opennurbs_win_dwrite.cpp file.

With regard to opennurbs_gl.cpp, I think there is an error on line 603.
ON_Material::MaxShine() is not a function, but a static double type
// GLint shine = (GLint)(128.0*(pMat->Shine() / ON_Material::MaxShine()));
So this was changed to:
GLint shine = (GLint)(128.0*(pMat->Shine() / ON_Material::MaxShine));

And in openNURBS_win_dwrite.cpp, line 318:
DWRITE_FONT_WEIGHT_SEMI_LIGHT is not defined in my version of dwrite
//case DWRITE_FONT_WEIGHT_SEMI_LIGHT: s = L"SEMI_LIGHT"; break; // 350,

I can now run the “example_read” application successfully:

Many thanks for your quick and helpful response.

Nicholas Shea.