[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...)
Post Reply
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

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

Post by looo »

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
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: windows smesh: unresolved external symbol __imp_gethostname

Post by sgrogan »

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
"fight the good fight"
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: windows smesh: unresolved external symbol __imp_gethostname

Post by triplus »

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

Re: windows smesh: unresolved external symbol __imp_gethostname

Post by looo »

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
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: windows smesh: unresolved external symbol __imp_gethostname

Post by triplus »

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
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: windows smesh: unresolved external symbol __imp_gethostname

Post by triplus »

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
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

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

Post by looo »

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
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

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

Post by triplus »

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

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

Post by looo »

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
Founder
Posts: 20301
Joined: Thu Feb 19, 2009 10:32 am
Contact:

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

Post by wmayer »

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?
Post Reply