| [ Return to Bugs & Features | SVN ⇄ GIT ]
STR #3469
Application: | FLTK Library |
Status: | 1 - Closed w/Resolution |
Priority: | 3 - Moderate, e.g. unable to compile the software |
Scope: | 2 - Specific to an operating system |
Subsystem: | Build Files |
Summary: | WIN7: TrackMouseEvent unresolved |
Version: | 1.4.0 |
Created By: | szukw000 |
Assigned To: | AlbrechtS |
Fix Version: | None |
Update Notification: | |
Trouble Report Files:
Trouble Report Comments:
|
#1 | szukw000 01:34 May 04, 2018 |
| WIN7-64Bit, Community 2017, fltk-1.4.x-r12861 :
[100%] Linking CXX executable flimage.exe^M fltk.lib(Fl_win32.cxx.obj) : error LNK2019: unresolved external symbol __imp__TrackMouseEvent referenced in function "__int64 __cdecl WndProc(struct HWND__ *,unsigned int,unsigned __int64,__int64)" (?WndProc@@YA_JPEAUHWND__@@I_K_J@Z)^M flimage.exe : fatal error LNK1120: 1 unresolved externals^M LINK failed. with 1120
winfried | |
|
#2 | AlbrechtS 02:33 May 04, 2018 |
| Please check that you link with comctl32.lib, this is very likely the cause of the failure:
_TrackMouseEvent() is documented here: https://msdn.microsoft.com/en-us/library/windows/desktop/ms646266(v=vs.85).aspx
"Requirements ... Library Comctl32.lib DLL Comctl32.dll"
This requirement is also documented somewhere in the FLTK docs. | |
|
#3 | szukw000 11:36 May 04, 2018 |
| fltk-1.4.x-r12562 was - on my disk - the last version with the following text in 'src/Fl_win32.cxx':
#if !defined(NO_TRACK_MOUSE) # include <commctrl.h> // TrackMouseEvent // fabien: Ms Visual Studio >= 2003 permit embedded lib reference // that makes fltk use easier as only fltk libs are now requested // This idea could be extended to fltk libs themselves, // implementer should then care about DLL linkage flags ... # if defined(_MSC_VER) && (_MSC_VER>=1310) # pragma comment (lib, "comctl32.lib") # endif #endif
After inserting the inner #ifdef ... #endif the bug report disappeared.
CMAKE did fail without the pragma. Why was the removal necessary?
winfried | |
|
#4 | AlbrechtS 03:01 May 06, 2018 |
| To answer your question: strictly spoken it was not necessary to remove this pragma. I did it to unify all (Windows) platforms. There were several reasons I considered:
(1) It is documented that comctl32.lib must be added to the linker libraries. Users that add the FLTK libs to their linker settings should also be able to add comctl32.lib (or any other requirements). In the future there may be even more linkage requirements. http://www.fltk.org/doc-1.4/basics.html#basics_visual_cpp
(2) This "comctl32" pragma was the only one in the code. The idea in the comment to "extend this to [other] libs" was never pursued.
(3) If you build your project with CMake the library dependencies should be propagated to your project settings anyway. See below [1].
(4) This pragma is only available with Microsoft (Visual Studio) compilers and build tools starting at a specific (admittedly a very old) version. Other toolkits on the Windows platform still need to add comctl32.lib explicitly (unless they use CMake).
This is the reasoning why I removed the pragma from the current code.
--- [1] The propagation of library dependencies in CMake builds may not yet work as expected. I'd rather fix this than to add the pragma to the source code. I'll follow up with questions regarding your build environment. | |
|
#5 | AlbrechtS 03:12 May 06, 2018 |
| Winfried, you wrote: > [100%] Linking CXX executable flimage.exe > ... > CMAKE did fail without the pragma.
So I assume the FLTK library builds without issues. Correct?
Did you build FLTK with CMake?
I further assume you (try to) build a third party project (flimage). Correct?
Please elaborate how you build it. Is there a given CMakeLists.txt, or did you create one yourself?
Please post the CMakeLists.txt file or at least all the FLTK specific parts or a download link if it is included in the project.
I'd like to understand why the CMake build failed to see if and how we can improve FLTK's CMake files.
You can help us to complete our CMake support. Thanks in advance. | |
|
#6 | szukw000 08:06 May 06, 2018 |
| First I removed the pragma from Fl_win32.cxx, re-compiled and re-installed FLTK.
Then I changed the CMakeLists.txt in FLIMAGE. I have now added the line
#IF(WIN32) set(LIBS ${LIBS} comctl32.lib) #ENDIF(WIN32)
to the CMakeLists.txt. I could compile without bug report. Thanks.
winfried | |
|
#7 | AlbrechtS 04:07 May 07, 2018 |
| Thanks for your comment and the CMakeLists.txt file. I'll try to build flimage later (may take some days, don't hold your breath).
FWIW, your solution is good for now, but the FLTK related stuff seems to be suboptimal. My goal is to make this more platform independent so you can use the same code on all platforms. In the future you shouldn't need to execute fltk-config, you should rather use either a variable (like FLTK_LIBRARIES) or the "fltk" target itself, and CMake should "now" all the dependencies. But this is not yet working.
I'll keep this STR open for now as a reminder to improve FLTK's CMake support and I'll post progress here. | |
|
#8 | AlbrechtS 04:09 May 07, 2018 |
| Sorry, there was a typo. Should read:
... you should rather use either a variable (like FLTK_LIBRARIES) or the "fltk" target itself, and CMake should "know" all the dependencies. | |
|
#9 | AlbrechtS 21:51 Aug 06, 2018 |
| I added a comment (#4) to STR #3471 (CMake improvements) concerning propagation of linkage requirements.
Closing this STR now. | |
[ Return to Bugs & Features ]
|
| |