| [ Return to Bugs & Features | SVN ⇄ GIT ]
STR #3443
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: | cmake/Visual Studio: control /MT vs /MD compiler flags |
Version: | 1.4-current |
Created By: | greg.ercolano |
Assigned To: | AlbrechtS |
Fix Version: | 1.3.9 |
Fix Commit: | cc91cfaac6263c7dac7931d42b0fc604741f5fc2 |
Update Notification: | |
Trouble Report Files:
No files
Trouble Report Comments:
|
#1 | greg.ercolano 10:41 Dec 13, 2017 |
| Cmake generates /MD by default, but sometimes the user wants to build FLTK with /MT.
This should probably be easier to control than to redefine all the compiler flags (as I described in a workaround posted to fltk.general on 12/12/2017, Subject: CMAKE + Visual Studio: /MT vs /MD builds)
Essentially, this is a "static" vs "dynamic" build issue, and may apply to other compilers/platforms as well (e.g. mingw, clang, g++..).
With Visual Studio, it's important that both the user application and FLTK be compiled with the /same/ flags (either /MD or /MT), else numerous errors happen at link time, e.g.
MSVCRT.lib(MSVCR90.dll) : error LNK2005: _malloc already defined in LIBCMT.lib .. MSVCRT.lib(MSVCR90.dll) : error LNK2005: _fwrite already defined in LIBCMT.lib .. MSVCRT.lib(MSVCR90.dll) : error LNK2005: _getenv already defined in LIBCMT.lib .. | |
|
#2 | greg.ercolano 01:33 Jun 20, 2019 |
| Checking status on this; see thread: https://groups.google.com/forum/#!topic/fltkgeneral/VqcYUFlHWSc
I'm running into this problem again with latest CMAKE + fltk.git + VS 2017 to build a debug version of fltk, e.g.
mkdir build cd build cmake -D CMAKE_BUILD_TYPE=Debug ..
..that's apparently building /dynamic/ debug executables (/MDd) and not static debug (/MTd), conflicting with my project.. the VS build logs are showing /MDd for all the CL compiler commands.
I came full circle to my own post in google groups, seeing I've been here before. I think adding a feature that replaces /MD + /MDd with /MT and /MTd is still needed.
I'm trying other random stuff on the web to see if I can lick this with the cmake command line, but if not, I'll have to go search/replacing again.. | |
|
#3 | AlbrechtS 14:46 Jun 20, 2019 |
| FWIW, there's a new feature in CMake 3.15 (to be released soon, currently rc2):
https://cmake.org/cmake/help/v3.15/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html https://cmake.org/cmake/help/v3.15/prop_tgt/MSVC_RUNTIME_LIBRARY.html
See also release notes: https://cmake.org/cmake/help/v3.15/release/3.15.html
and CMake policy CMP0091: https://cmake.org/cmake/help/v3.15/policy/CMP0091.html
The problem with this is however that it's a brand new (not yet released) CMake version and we'd need to check the running CMake version and deal with it dynamically, i.e. *either* use the new feature *or* do string manipulation of CMAKE_*_FLAGS for older CMake versions which is generally discouraged.
I'm not aware of a proper solution - I just wanted to show the current CMake development. | |
|
#4 | AlbrechtS 14:51 Jun 20, 2019 |
| FTR: from the CMake mailing list:
[CMake] [ANNOUNCE] CMake 3.15.0-rc2 is ready for testing Wed Jun 19 11:57:00 EDT 2019
https://cmake.org/pipermail/cmake/2019-June/069638.html
There are also changes in default warning switches (/W3) no longer being set, leaving this to the user. | |
|
#5 | AlbrechtS 14:41 Jan 16, 2023 |
| This STR will be handled in GitHub Issue #655: "CMake fixes". https://github.com/fltk/fltk/issues/655 | |
|
#6 | AlbrechtS 08:51 Dec 03, 2023 |
| Fixed in Git repository.
Fixed in commit 4a461efae6fa36aeb50e61e381dc2ecf95b83d23 | |
|
#7 | AlbrechtS 06:27 Dec 07, 2023 |
| Note: fixed in 1.3.9 and 1.4.0 (CMake only)
1.3.9: commit cc91cfaac6263c7dac7931d42b0fc604741f5fc2 (the log message seems unrelated but this commit adds CMake option FLTK_MSVC_RUNTIME_DLL as well, see README.CMake.txt).
1.4.0: commit 4a461efae6fa36aeb50e61e381dc2ecf95b83d23
The bundled IDE files in FLTK 1.3.9 are unaffected (use CMake instead). | |
|
#8 | AlbrechtS 04:43 Dec 08, 2023 |
| Please see README.CMake.txt, option 'FLTK_MSVC_RUNTIME_DLL' for the "new way" to select the DLL or static MSVC (and NMake) runtime version:
FLTK_MSVC_RUNTIME_DLL - default ON (only for Visual Studio and NMake). Selects whether the build uses the MS runtime DLL or not. Default is ON: either /MD or /MDd for Release or Debug, respectively. Select OFF for either /MT or /MTd for Release or Debug, respectively.
Note that only one option selects this for both Release and Debug builds for Visual Studio (a multi-config build system). | |
[ Return to Bugs & Features ]
|
| |