Fwd: Re: FortranCInterface not working with 3.9.0 with Intel 2015

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: Re: FortranCInterface not working with 3.9.0 with Intel 2015

John Cary
Yes, we do a replacement of MD with MT as we need fully static builds.

We do this early in configuration, using

The "Dynamic Replace" method described at

https://cmake.org/Wiki/CMake_FAQ

specifically

https://cmake.org/Wiki/CMake_FAQ#Dynamic_Replace

This is possible with 3.8.2.  Is there a way
to get that behavior back?

Thx........

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: FortranCInterface not working with 3.9.0 with Intel 2015

John Cary
Thanks for your help.

Yes, we do a replacement of MD with MT as we need fully static builds.

We do this early in configuration, using

The "Dynamic Replace" method described at

https://cmake.org/Wiki/CMake_FAQ

specifically

https://cmake.org/Wiki/CMake_FAQ#Dynamic_Replace

This is possible with 3.8.2.  Is there a way
to get that behavior back?

Thx........


> Thanks for sending the files.  I think I might have found something.
> The FortranCInterface.exe is not linking because of mismatched linker
> commands.  Here are the errors:
>
> Did you change any of the default compiler/linker flags?  It looks like
> it is mixing run time libraries somehow.
>
>
> [100%] Linking Fortran executable FortranCInterface.exe
>
> LINK: command "xilink /nologo
> @CMakeFiles\FortranCInterface.dir\objects1.rsp
> /out:FortranCInterface.exe /implib:FortranCInterface.lib
> /pdb:C:\winsame\cary\usimall\builds\ulixes\ser\CMakeFiles\FortranCInterface\FortranCInterface.pdb
> /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console symbols.lib
> myfort.lib user32.lib /MANIFEST
> /MANIFESTFILE:FortranCInterface.exe.manifest" failed (exit code 1169)
> with the following output:
> xilink: executing 'link'
>
> LIBCMT.lib(winapisupp.obj) : error LNK2005:
> __crtSetUnhandledExceptionFilter already defined in MSVCRT.lib(MSVCR120.dll)
>
> LIBCMT.lib(crtheap.obj) : error LNK2005: _calloc_crt already defined in
> MSVCRT.lib(MSVCR120.dll)
>
> LIBCMT.lib(crt0dat.obj) : error LNK2005: _amsg_exit already defined in
> MSVCRT.lib(MSVCR120.dll)
>
> LIBCMT.lib(crt0dat.obj) : error LNK2005: _cexit already defined in
> MSVCRT.lib(MSVCR120.dll)
>
> LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in
> MSVCRT.lib(MSVCR120.dll)
>
> LIBCMT.lib(crt0dat.obj) : error LNK2005: _initterm_e already defined in
> MSVCRT.lib(MSVCR120.dll)
>
> LIBCMT.lib(crt0dat.obj) : error LNK2005: exit already defined in
> MSVCRT.lib(MSVCR120.dll)
>
> LIBCMT.lib(mlock.obj) : error LNK2005: _lock already defined in
> MSVCRT.lib(MSVCR120.dll)
>
> LIBCMT.lib(mlock.obj) : error LNK2005: _unlock already defined in
> MSVCRT.lib(MSVCR120.dll)

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: FortranCInterface not working with 3.9.0 with Intel 2015

Brad King
On 12/11/2017 04:34 PM, John Cary wrote:

> Bill Hoffman wrote:
>> LINK: command "xilink ... /out:FortranCInterface.exe ..." failed (exit code 1169)
>> LIBCMT.lib(winapisupp.obj) : error LNK2005:
>> __crtSetUnhandledExceptionFilter already defined in MSVCRT.lib(MSVCR120.dll)
>>
>> Did you change any of the default compiler/linker flags?  It looks like
>> it is mixing run time libraries somehow.
>
> Yes, we do a replacement of MD with MT as we need fully static builds.
>
> We do this early in configuration, using
>
> The "Dynamic Replace" method described at
>
> https://cmake.org/Wiki/CMake_FAQ#Dynamic_Replace
>
> This is possible with 3.8.2.  Is there a way to get that behavior back?

This is likely due to commit v3.9.0-rc1~144^2~1:

```
FortranCInt: Pass CONFIG flags to try_compile

This change ensures that Intel Fortran's /libs: in
CMAKE_Fortran_FLAGS and Visual C++'s /MT or /MD in the
CMAKE_C_FLAGS_RELEASE do not conflict with each other.
```

With that change I'm able to reproduce the failure with
VS 2013 and Intel 2016:

```
cmake_minimum_required (VERSION 3.7)
project(Test C Fortran)
string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
include(FortranCInterface)
FortranCInterface_VERIFY()
```

If the project is changing the C and C++ flags to use a static
runtime library, it should do that for Fortran too:

```
string(REPLACE "/libs:dll" "/libs:static" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
```

Adding that line fixes the problem for me.

-Brad
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: FortranCInterface not working with 3.9.0 with Intel 2015

John Cary
Thanks.  All now configures with 3.9.4.

On 12/12/17 5:50 AM, Brad King wrote:

> On 12/11/2017 04:34 PM, John Cary wrote:
>> Bill Hoffman wrote:
>>> LINK: command "xilink ... /out:FortranCInterface.exe ..." failed (exit code 1169)
>>> LIBCMT.lib(winapisupp.obj) : error LNK2005:
>>> __crtSetUnhandledExceptionFilter already defined in MSVCRT.lib(MSVCR120.dll)
>>>
>>> Did you change any of the default compiler/linker flags?  It looks like
>>> it is mixing run time libraries somehow.
>> Yes, we do a replacement of MD with MT as we need fully static builds.
>>
>> We do this early in configuration, using
>>
>> The "Dynamic Replace" method described at
>>
>> https://cmake.org/Wiki/CMake_FAQ#Dynamic_Replace
>>
>> This is possible with 3.8.2.  Is there a way to get that behavior back?
> This is likely due to commit v3.9.0-rc1~144^2~1:
>
> ```
> FortranCInt: Pass CONFIG flags to try_compile
>
> This change ensures that Intel Fortran's /libs: in
> CMAKE_Fortran_FLAGS and Visual C++'s /MT or /MD in the
> CMAKE_C_FLAGS_RELEASE do not conflict with each other.
> ```
>
> With that change I'm able to reproduce the failure with
> VS 2013 and Intel 2016:
>
> ```
> cmake_minimum_required (VERSION 3.7)
> project(Test C Fortran)
> string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
> include(FortranCInterface)
> FortranCInterface_VERIFY()
> ```
>
> If the project is changing the C and C++ flags to use a static
> runtime library, it should do that for Fortran too:
>
> ```
> string(REPLACE "/libs:dll" "/libs:static" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
> ```
>
> Adding that line fixes the problem for me.
>
> -Brad
>

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake