Help compiling nglib onWin

Having trouble installing or compiling FreeCAD? Get help here.
User avatar
sgrogan
Posts: 2999
Joined: Wed Oct 22, 2014 5:02 pm

Help compiling nglib onWin

Postby sgrogan » Tue Aug 09, 2016 12:08 am

Due to my ignorance to non-cmake build procedure I need help to compile nglib for windows (and ubuntu ;) )
What do I need to learn? Automake, NMAKE, or Can I launch the MS IDE w/ the .sln file https://github.com/peterl94/clbundler-freecad/blob/master/freecad/win/netgen.py(might not understand the python here) and chase the linker errors i "Project Properties"?
wmayer
Site Admin
Posts: 11234
Joined: Thu Feb 19, 2009 10:32 am

Re: Help compiling nglib onWin

Postby wmayer » Tue Aug 09, 2016 8:26 am

Unless you have to change compiler flags there is no need to learn automake or nmake. If the source tarball doesn't include a Makefile you have to first run ./configure, then make and make install.

On Windows just enter nmake. If an .sln file is included then use Visual Studio.
User avatar
sgrogan
Posts: 2999
Joined: Wed Oct 22, 2014 5:02 pm

Re: Help compiling nglib onWin

Postby sgrogan » Mon Aug 15, 2016 10:02 pm

wmayer wrote:If an .sln file is included then use Visual Studio.

There is a nglib.sln, so adding the dependencies in the VS IDE to project properties I've come to a problem linking to zlib1.lib Is this the same as zlibstatic.lib in the libpack? I don't see zlib1.h in the downloaded zlib sources (I've only examined the zlib sources I haven't tried to compile it) If so do I need to patch the nglib sources to use this library?
wmayer
Site Admin
Posts: 11234
Joined: Thu Feb 19, 2009 10:32 am

Re: Help compiling nglib onWin

Postby wmayer » Tue Aug 16, 2016 8:25 am

to zlib1.lib Is this the same as zlibstatic.lib in the libpack?

No, the zlib.lib makes the nglib linking the zlib dll (dynamic linking), while zlibstatic.lib copies all symbols into the nglib.dll (static linking) and makes it slightly bigger. I prefer using the dynamic linking approach.

I don't see zlib1.h in the downloaded zlib sources

The file is called zlib.h and you can use the version of the libpack.

If so do I need to patch the nglib sources to use this library?

You don't have to touch the source code. You only have to add search paths for include directories and library files in the project settings.
User avatar
sgrogan
Posts: 2999
Joined: Wed Oct 22, 2014 5:02 pm

Re: Help compiling nglib onWin

Postby sgrogan » Tue Aug 16, 2016 11:45 am

wmayer wrote:The file is called zlib.h and you can use the version of the libpack.

This is what I was expecting except the error is

Code: Select all

1>------ Build started: Project: nglib, Configuration: Release x64 ------
1>LINK : fatal error LNK1181: cannot open input file 'zlib1.lib'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
wmayer
Site Admin
Posts: 11234
Joined: Thu Feb 19, 2009 10:32 am

Re: Help compiling nglib onWin

Postby wmayer » Tue Aug 16, 2016 1:30 pm

cannot open input file 'zlib1.lib'

It can't find the file zlib1.lib. Depending on the used libpack the file is zlib.lib. In this case just make a copy of it and rename it to zlib1.lib.
User avatar
sgrogan
Posts: 2999
Joined: Wed Oct 22, 2014 5:02 pm

Re: Help compiling nglib onWin

Postby sgrogan » Tue Aug 16, 2016 10:43 pm

wmayer wrote:It can't find the file zlib1.lib. Depending on the used libpack the file is zlib.lib. In this case just make a copy of it and rename it to zlib1.lib.

Thanks for the continued support. I get the following now

Code: Select all

Error   2   error MSB3073: The command ""C:\Users\Chris\GitHub\netgen-mesher-git-cf713efd2da43a733abf06f7c9b5c9697fef7e78\windows\\postBuild_nglib.bat" "nglib" "nglib.dll" "Release" "x64" "C:\Users\Chris\GitHub\netgen-mesher-git-cf713efd2da43a733abf06f7c9b5c9697fef7e78\windows\"
:VCEnd" exited with code 1.   C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets   132   5   nglib

I don't think this matters because nglib.dll and nglib.lib are created. I did this without the OCCT7 patches but will repeat the process with them included then try to compile FreeCAD against this. I assume I will need zlib1.dll created by copying and renaming at runtime?
wmayer
Site Admin
Posts: 11234
Joined: Thu Feb 19, 2009 10:32 am

Re: Help compiling nglib onWin

Postby wmayer » Wed Aug 17, 2016 7:22 am

Thanks for the continued support. I get the following now

It looks like it wanted to copy the files to a certain place which failed for any reason. But since it created the files it doesn't matter.
User avatar
sgrogan
Posts: 2999
Joined: Wed Oct 22, 2014 5:02 pm

Re: Help compiling nglib onWin

Postby sgrogan » Wed Aug 17, 2016 12:09 pm

wmayer wrote:It looks like it wanted to copy the files to a certain place which failed for any reason. But since it created the files it doesn't matter.

Because there is not an install target a post build script is run that tries to copy the files to a write protected location (admin privileges are required)
Thanks again for the help.
User avatar
sgrogan
Posts: 2999
Joined: Wed Oct 22, 2014 5:02 pm

Re: Help compiling nglib onWin

Postby sgrogan » Sat Aug 27, 2016 6:06 pm

Latest attempt:

1. Downloaded netgen 5.1 snapshot from here: https://sourceforge.net/p/netgen-mesher/git/ci/netgen-5.1/tree/
2. Applied changes as explained here: viewtopic.php?f=17&p=127000#p126997
3. Build nglib, Copy and Replace nglib.dll, nglib.lib, nglib.h, and the changed .hpp files over existing locations in the libpack.
Scratch build FreeCAD

Code: Select all

Error   2   error C2375: 'netgen::OCCGenerateMesh' : redefinition; different linkage   C:\Users\Chris\GitHub\FreeCAD\src\3rdParty\salomesmesh\src\NETGENPlugin\NETGENPlugin_Mesher.cpp   87   1   NETGENPlugin
Error   3   error C2568: '=' : unable to resolve function overload   C:\Users\Chris\GitHub\FreeCAD\src\3rdParty\salomesmesh\src\NETGENPlugin\NETGENPlugin_Mesher.cpp   2505   1   NETGENPlugin
Error   4   error C2568: '=' : unable to resolve function overload   C:\Users\Chris\GitHub\FreeCAD\src\3rdParty\salomesmesh\src\NETGENPlugin\NETGENPlugin_Mesher.cpp   2606   1   NETGENPlugin
Error   5   error C2568: '=' : unable to resolve function overload   C:\Users\Chris\GitHub\FreeCAD\src\3rdParty\salomesmesh\src\NETGENPlugin\NETGENPlugin_Mesher.cpp   2647   1   NETGENPlugin
Error   6   error C2568: '=' : unable to resolve function overload   C:\Users\Chris\GitHub\FreeCAD\src\3rdParty\salomesmesh\src\NETGENPlugin\NETGENPlugin_Mesher.cpp   2757   1   NETGENPlugin
Error   7   error C2568: '=' : unable to resolve function overload   C:\Users\Chris\GitHub\FreeCAD\src\3rdParty\salomesmesh\src\NETGENPlugin\NETGENPlugin_Mesher.cpp   2859   1   NETGENPlugin
Error   8   error C2568: '=' : unable to resolve function overload   C:\Users\Chris\GitHub\FreeCAD\src\3rdParty\salomesmesh\src\NETGENPlugin\NETGENPlugin_Mesher.cpp   2891   1   NETGENPlugin
Error   9   error C2440: 'initializing' : cannot convert from 'int (__cdecl *)(netgen::OCCGeometry &,netgen::Mesh *&,netgen::MeshingParameters &,int,int)' to 'int'   C:\Users\Chris\GitHub\FreeCAD\src\3rdParty\salomesmesh\src\NETGENPlugin\NETGENPlugin_Mesher.cpp   3113   1   NETGENPlugin
Error   11   error C2375: 'netgen::OCCGenerateMesh' : redefinition; different linkage   C:\Users\Chris\GitHub\FreeCAD\src\3rdParty\salomesmesh\src\NETGENPlugin\NETGENPlugin_NETGEN_2D_ONLY.cpp   70   1   NETGENPlugin
Error   12   error C2568: '=' : unable to resolve function overload   C:\Users\Chris\GitHub\FreeCAD\src\3rdParty\salomesmesh\src\NETGENPlugin\NETGENPlugin_NETGEN_2D_ONLY.cpp   478   1   NETGENPlugin
Error   14   error C2375: 'netgen::OCCGenerateMesh' : redefinition; different linkage   C:\Users\Chris\GitHub\FreeCAD\src\3rdParty\salomesmesh\src\NETGENPlugin\NETGENPlugin_NETGEN_3D.cpp   79   1   NETGENPlugin
Error   15   error C2568: '=' : unable to resolve function overload   C:\Users\Chris\GitHub\FreeCAD\src\3rdParty\salomesmesh\src\NETGENPlugin\NETGENPlugin_NETGEN_3D.cpp   475   1   NETGENPlugin
Error   16   error LNK1181: cannot open input file '..\..\..\..\lib\Release\NETGENPlugin.lib'   C:\Users\Chris\GitHub\FCNG-build\src\Mod\MeshPart\App\LINK   MeshPart
Error   17   error LNK1181: cannot open input file '..\..\..\..\lib\Release\NETGENPlugin.lib'   C:\Users\Chris\GitHub\FCNG-build\src\Mod\Fem\App\LINK   Fem
Error   18   error LNK1181: cannot open input file '..\App\Release\MeshPart.lib'   C:\Users\Chris\GitHub\FCNG-build\src\Mod\MeshPart\Gui\LINK   MeshPartGui
Error   19   error LNK1181: cannot open input file '..\App\Release\Fem.lib'   C:\Users\Chris\GitHub\FCNG-build\src\Mod\Fem\Gui\LINK   FemGui


Do I need to apply additional patches? like here: https://github.com/peterl94/clbundler-freecad/tree/master/freecad/win/patches/netgen

EDIT: Or could I have some sort of circular dependency issue. I'm building nglib with the provided nglib.sln file in the netgen windows folder, and adding the paths to link against the existing libpack when VS complains, could VS be using the unmodified header files from the existing libpack instead of the modified ones in the netgen libsrc's?