Thumbnailprovider.dll

Having trouble installing or compiling FreeCAD? Get help here.
User avatar
uwestoehr
Posts: 1084
Joined: Sun Jan 27, 2019 3:21 am

Re: Thumbnailprovider.dll

Postby uwestoehr » Mon Nov 04, 2019 1:14 am

uwestoehr wrote:
Mon Nov 04, 2019 12:14 am
So I can implement to register the DLL file necessary to get thumbnails,
I wanted to do so and in several forums I read I should provide if possible the DLLs compiled with the same MSVC version than the main program.
So I tried to compile the DLL by myself. I was able to update their solution files, see PR https://github.com/FreeCAD/FreeCAD/pull/2690
But when compiling the target FCStdThumbnail I get this error:

Code: Select all

1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.16.27023\include\stdint.h(17): error C2371: 'int8_t': redefinition; different basic types
1>d:\freecadgit\src\tools\thumbs\thumbnailprovider\fcconfig.h(105): note: see declaration of 'int8_t'
I can fix this by uncommenting the redefinition. But then I get these errors:

Code: Select all

1>   Creating library D:\FreeCADGit\src\Tools\thumbs\ThumbnailProvider\x64\Release\FCStdThumbnail.lib and object D:\FreeCADGit\src\Tools\thumbs\ThumbnailProvider\x64\Release\FCStdThumbnail.exp
1>deflateoutputstreambuf.obj : error LNK2001: unresolved external symbol deflateInit2_
1>deflateoutputstreambuf.obj : error LNK2001: unresolved external symbol deflateReset
1>deflateoutputstreambuf.obj : error LNK2001: unresolved external symbol deflateEnd
1>deflateoutputstreambuf.obj : error LNK2001: unresolved external symbol crc32
1>deflateoutputstreambuf.obj : error LNK2001: unresolved external symbol deflate
1>inflateinputstreambuf.obj : error LNK2001: unresolved external symbol inflateEnd
1>inflateinputstreambuf.obj : error LNK2001: unresolved external symbol inflate
1>inflateinputstreambuf.obj : error LNK2001: unresolved external symbol inflateInit2_
1>inflateinputstreambuf.obj : error LNK2001: unresolved external symbol inflateReset
1>ThumbnailProvider.obj : error LNK2001: unresolved external symbol "public: struct HBITMAP__ * __cdecl CxImage::MakeBitmap(struct HDC__ *)" (?MakeBitmap@CxImage@@QEAAPEAUHBITMAP__@@PEAUHDC__@@@Z)
1>ThumbnailProvider.obj : error LNK2001: unresolved external symbol "public: bool __cdecl CxImage::DestroyFrames(void)" (?DestroyFrames@CxImage@@QEAA_NXZ)
1>ThumbnailProvider.obj : error LNK2001: unresolved external symbol "public: bool __cdecl CxImage::Destroy(void)" (?Destroy@CxImage@@QEAA_NXZ)
1>ThumbnailProvider.obj : error LNK2001: unresolved external symbol "public: __cdecl CxImage::CxImage(unsigned long)" (??0CxImage@@QEAA@K@Z)
1>ThumbnailProvider.obj : error LNK2001: unresolved external symbol "public: virtual __cdecl CxMemFile::~CxMemFile(void)" (??1CxMemFile@@UEAA@XZ)
1>ThumbnailProvider.obj : error LNK2001: unresolved external symbol "public: __cdecl CxMemFile::CxMemFile(unsigned char *,unsigned long)" (??0CxMemFile@@QEAA@PEAEK@Z)
1>ThumbnailProvider.obj : error LNK2001: unresolved external symbol "public: bool __cdecl CxImagePNG::Decode(class CxFile *)" (?Decode@CxImagePNG@@QEAA_NPEAVCxFile@@@Z)
1>D:\FreeCADGit\src\Tools\thumbs\ThumbnailProvider\x64\Release\FCStdThumbnail.dll : fatal error LNK1120: 16 unresolved externals
Has anybody a clue? I also see that the zlib version is 1.2.3 (9 years old). Can anybody please update to zlib 1.2.11? (I tried but failed. I got then other unresolved externals.)

There is also a file FCThumbs.sln. When I compile its target FCThumbs I get this error:

Code: Select all

1>StdAfx.cpp
1>d:\freecadgit\src\tools\thumbs\stdafx.cpp(34): fatal error C1083: Cannot open include file: 'atlimpl.cpp': No such file or directory
There is no atlimpl.cpp in the FC source code. It seems FCThumbs.sln is an outdated solution file since it also only offers 32bit builds. Could it be removed?
wmayer
Site Admin
Posts: 15274
Joined: Thu Feb 19, 2009 10:32 am

Re: Thumbnailprovider.dll

Postby wmayer » Mon Nov 04, 2019 7:32 am

So I can implement to register the DLL file necessary to get thumbnails, but I would also like to have the thumbnail saving option turned on by default that our users see the advantage.
Unfortunately, things are never so easy as as they look at the first glance. The save-thumbnail option is based on the off-screen rendering which doesn't work reliably on every system -- due to bad graphic drivers or other issues. Affected people have all sort of problems like black images, garbled images or even crashes.

So, the option was never on by default because it would be extremely annoying if FreeCAD crashes while saving a document.

In the past it was discussed a few times to offer a dialog when running FreeCAD the very first time where the user can define a few things like language, navigation style, unit scheme, .... There we could also present the thumbnail option but with the recommendation that he must try that it really works for him.
User avatar
uwestoehr
Posts: 1084
Joined: Sun Jan 27, 2019 3:21 am

Re: Thumbnailprovider.dll

Postby uwestoehr » Mon Nov 04, 2019 12:11 pm

wmayer wrote:
Mon Nov 04, 2019 7:32 am
So, the option was never on by default because it would be extremely annoying if FreeCAD crashes while saving a document.
Thanks for the explanation. So the option must be kept off for now.

What about the compilation? I found an interesting method to register a DLL also without admin privileges. For this one must set certain compiler flags at compile time. Therefore I need to compile the DLL by myself to try this out.
In general, the DLL should be compilable out of the box and this is currently not the case. Since you provided the DLLs in 2015 (see this thread), you was able to compile it and maybe have an idea how to fix the compilability?
User avatar
Kunda1
Posts: 6427
Joined: Thu Jan 05, 2017 9:03 pm

Re: Thumbnailprovider.dll

Postby Kunda1 » Mon Nov 04, 2019 1:40 pm

wmayer wrote:
Mon Nov 04, 2019 7:32 am
In the past it was discussed a few times to offer a dialog when running FreeCAD the very first time where the user can define a few things like language, navigation style, unit scheme, .... There we could also present the thumbnail option but with the recommendation that he must try that it really works for him.
This is making more and more sense as time goes on.
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
wmayer
Site Admin
Posts: 15274
Joined: Thu Feb 19, 2009 10:32 am

Re: Thumbnailprovider.dll

Postby wmayer » Mon Nov 04, 2019 6:09 pm

User avatar
uwestoehr
Posts: 1084
Joined: Sun Jan 27, 2019 3:21 am

Re: Thumbnailprovider.dll

Postby uwestoehr » Mon Nov 04, 2019 9:13 pm

wmayer wrote:
Mon Nov 04, 2019 6:09 pm
git commit 5476ab4b6
Many thanks Werner!
However, it still doesn't compile with MSVC 2017 x64 because of the unresolved external symbols I reported. :?

Besides this, could you merge my PR https://github.com/FreeCAD/FreeCAD/pull/2690 ? I am asking because then I don't have to run through the same conversion routines whenever I open the solution files.

What about zlib? Do you agree that it should be updated or is this not necessary?
wmayer
Site Admin
Posts: 15274
Joined: Thu Feb 19, 2009 10:32 am

Re: Thumbnailprovider.dll

Postby wmayer » Mon Nov 04, 2019 9:35 pm

However, it still doesn't compile with MSVC 2017 x64 because of the unresolved external symbols I reported.
No problem here. I used the CMake file to generate a correct VS project file for VS 2017, I don't think you should use the existing VS project file. This is file was built for VS 2008 and with this version it still compiles (but only when I undo my change for int8_t).
What about zlib? Do you agree that it should be updated or is this not necessary?
I don't think it's worth to upgrade.
Besides this, could you merge my PR https://github.com/FreeCAD/FreeCAD/pull/2690 ? I am asking because then I don't have to run through the same conversion routines whenever I open the solution files.
You really don't need that. Generate a VS project file from the CMakeLists.txt underneath ThumbnailProvider and your build problems will disappear.
User avatar
uwestoehr
Posts: 1084
Joined: Sun Jan 27, 2019 3:21 am

Re: Thumbnailprovider.dll

Postby uwestoehr » Tue Nov 05, 2019 12:36 am

wmayer wrote:
Mon Nov 04, 2019 9:35 pm
No problem here. I used the CMake file to generate a correct VS project file for VS 2017, I don't think you should use the existing VS project file.
Thanks. Indeed, building a new solution file from scratch works.
However, I am a lazy guy and I expect others are too. And since we already have a MSVC solution file in our code, we could update it. Therefore I retracted my old PR and made this new one that uses the solution I just built from scratch and that compiles out of the box:
https://github.com/FreeCAD/FreeCAD/pull/2695

wmayer wrote:
Mon Nov 04, 2019 9:35 pm
I don't think it's worth to upgrade.
OK.
User avatar
uwestoehr
Posts: 1084
Joined: Sun Jan 27, 2019 3:21 am

Re: Thumbnailprovider.dll

Postby uwestoehr » Thu Nov 14, 2019 2:39 am

With this PR: https://github.com/FreeCAD/FreeCAD/pull/2713 the thumbnail provider DLL will be registered to Windows while FreeCAD is installed.
This can only be done if the user executing the installer has admin privileges. (I tried without success to get a system DLL registered just for the current user.)

When FreeCAD is uninstalled, the DLL will be unregistered, In this case admin permissions are assured because once a program was installed with admin privileges, it can only be uninstalled with the same privileges.
triplus
Posts: 9136
Joined: Mon Dec 12, 2011 4:45 pm

Re: Thumbnailprovider.dll

Postby triplus » Thu Nov 14, 2019 11:39 am

Thanks for investing the effort. Thumbnail support, on any supported platform, that for sure makes the FreeCAD experience more polished. Too bad, we can't enable the option, to create thumbnails automatically and by default. Potential strange looking thumbnail, on some combinations of GPU hardware, that would be acceptable. Potential crashing on the save operation, that for sure would be not.