STR #3443

GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 Home  |  Articles & FAQs  |  Bugs & Features  |  Documentation  |  Download  |  Screenshots  ]
 

Return to Bugs & Features | Post Text | Post File | Prev | Next ]

STR #3443

Application:FLTK Library
Status:5 - New
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:Unassigned
Fix Version:Unassigned
Update Notification:

Receive EMails Don't Receive EMails

Trouble Report Files:

Post File ]

No files


Trouble Report Comments:

Post Text ]
Name/Time/Date Text top right image
 
#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.
 
bottom left image   bottom right image

Return to Bugs & Features | Post Text | Post File ]

 
 

Comments are owned by the poster. All other content is copyright 1998-2021 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.