[WIP] updating to netgen 6.2.2004 (was smesh windows problem)

This subforum is specifically to discuss packaging issues on different platforms (windows, mac, linux), and using different packaging systems (conda, etc...)
User avatar
looo
Posts: 3424
Joined: Mon Nov 11, 2013 5:29 pm

[WIP] updating to netgen 6.2.2004 (was smesh windows problem)

Postby looo » Sun Apr 26, 2020 4:49 pm

Maybe someone can give me a hint what this means. I tried to rerun the smesh windows build.

Code: Select all

error LNK2019: unresolved external symbol __imp_gethostname referenced in function "class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl GetHostname(void)" (?GetHostname@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
SMESHMisc.dll : fatal error LNK1120: 1 unresolved externals
Last edited by looo on Fri May 01, 2020 8:40 am, edited 2 times in total.
User avatar
sgrogan
Posts: 5954
Joined: Wed Oct 22, 2014 5:02 pm

Re: windows smesh: unresolved external symbol __imp_gethostname

Postby sgrogan » Sun Apr 26, 2020 5:18 pm

looo wrote:
Sun Apr 26, 2020 4:49 pm
Maybe someone can give me a hint what this means. I tried to rerun the smesh windows build.
Maybe this offers a hint?
https://www.experts-exchange.com/questi ... ame-8.html
Hi ,

you'll have to link with Ws2_32.lib ... simply open 'Project->Settings' dialog, select 'Link'-tab
and add Ws2_32.lib to 'Object/library modules'.

hope that helps,

ZOPPO
https://developercommunity.visualstudio ... -c-in.html
triplus
Posts: 9475
Joined: Mon Dec 12, 2011 4:45 pm

Re: windows smesh: unresolved external symbol __imp_gethostname

Postby triplus » Sun Apr 26, 2020 6:38 pm

Sometimes on Linux such outcome signals a borked build, starting fresh usually helps.
User avatar
looo
Posts: 3424
Joined: Mon Nov 11, 2013 5:29 pm

Re: windows smesh: unresolved external symbol __imp_gethostname

Postby looo » Sun Apr 26, 2020 6:51 pm

triplus wrote:
Sun Apr 26, 2020 6:38 pm
Sometimes on Linux such outcome signals a borked build, starting fresh usually helps.
Already tried 3 times. I guess it's a problem of VisualStudio setup on azure or it is related to the used compiler-package. The update I wanted to make is not very important. Only pinning netgen tightly to smesh to make sure smesh doesn't pull a newer version of netgen if we update netgen. I tried updating netgen recently (6.2.1808 ->6.2.2004) but netgen changed the interface which makes smesh incompatible...
triplus
Posts: 9475
Joined: Mon Dec 12, 2011 4:45 pm

Re: windows smesh: unresolved external symbol __imp_gethostname

Postby triplus » Sun Apr 26, 2020 8:52 pm

I guess the question is why are we talking about a 32 bit network oriented library in the first place. I would say try what @sgrogan suggested if you have "settings dialog" at your disposal? Reading this:
Ensure that the build environment links to the Winsock Library file Ws2_32.lib.
https://docs.microsoft.com/en-us/window ... pplication

This is therefore indeed what is likely missing. If the actual file is missing, then it is likely a part or some SDK, or you would need to define ws2_32.lib somewhere, as a dependency. Just guessing, as i have no experience with such toolchain.
triplus
Posts: 9475
Joined: Mon Dec 12, 2011 4:45 pm

Re: windows smesh: unresolved external symbol __imp_gethostname

Postby triplus » Sun Apr 26, 2020 8:57 pm

If you have a chance to install "Desktop development with C++" workload, do that. As maybe the mentioned library will be a part of that workload.
User avatar
looo
Posts: 3424
Joined: Mon Nov 11, 2013 5:29 pm

Re: [solved] windows smesh: unresolved external symbol __imp_gethostname

Postby looo » Mon Apr 27, 2020 8:27 am

triplus wrote:
Sun Apr 26, 2020 8:52 pm
Ensure that the build environment links to the Winsock Library file Ws2_32.lib.
sgrogan wrote:
Sun Apr 26, 2020 5:18 pm
looo wrote:
Sun Apr 26, 2020 4:49 pm
Maybe someone can give me a hint what this means. I tried to rerun the smesh windows build.
Maybe this offers a hint?
https://www.experts-exchange.com/questi ... ame-8.html
Hi ,

you'll have to link with Ws2_32.lib ... simply open 'Project->Settings' dialog, select 'Link'-tab
and add Ws2_32.lib to 'Object/library modules'.

hope that helps,

ZOPPO
https://developercommunity.visualstudio ... -c-in.html
You were right. It seems like the library was linked in automatically previously but this has changed. The build is fixed with this little patch:
https://github.com/conda-forge/smesh-fe ... nker.patch
triplus
Posts: 9475
Joined: Mon Dec 12, 2011 4:45 pm

Re: [solved] windows smesh: unresolved external symbol __imp_gethostname

Postby triplus » Mon Apr 27, 2020 10:29 am

Great!
User avatar
looo
Posts: 3424
Joined: Mon Nov 11, 2013 5:29 pm

Re: [solved] windows smesh: unresolved external symbol __imp_gethostname

Postby looo » Mon Apr 27, 2020 4:33 pm

question to the c++ experts:

Netgen has changed the interface to this:

Code: Select all

geo->SetOCCParameters(occparam);
auto mesh = make_shared<Mesh>();
geo->GenerateMesh(mesh, mp);
mesh->SetGeometry(geo);
SetGlobalMesh(mesh);
which previously looked like this:

Code: Select all

DLL_HEADER extern int OCCGenerateMesh(OCCGeometry&, shared_ptr<Mesh>&, MeshingParameters&);
Whats the easiest way to align to the new interface? Does it make sense? Or should we use the python bindings they provide to interface the meshing functionality?
wmayer
Site Admin
Posts: 16261
Joined: Thu Feb 19, 2009 10:32 am

Re: [solved] windows smesh: unresolved external symbol __imp_gethostname

Postby wmayer » Tue Apr 28, 2020 8:44 am

looo wrote:
Mon Apr 27, 2020 4:33 pm
Whats the easiest way to align to the new interface?
An option might be to add an implementation of OCCGenerateMesh to NETGENPlugin_Mesher.cxx in order to reduce the amount of changes. It could look like this:

Code: Select all

int OCCGenerateMesh(OCCGeometry& geo, shared_ptr<Mesh>& mesh, MeshingParameters& mp)
{
    auto value = geo.GenerateMesh(mesh, mp);
    mesh->SetGeometry(geo);
    return value;
}
Or should we use the python bindings they provide to interface the meshing functionality?
I wouldn't do that because it could become quite inefficient because the functions which call OCCGenerateMesh can be invoked many times.

Is SetOCCParameters a new function and if yes what's the type of occparam?