From cmake Wed Feb 11 15:30:21 2015 From: Andreas Pakulat Date: Wed, 11 Feb 2015 15:30:21 +0000 To: cmake Subject: Re: [CMake] Unexpected use of "ld" on Windows Message-Id: X-MARC-Message: https://marc.info/?l=cmake&m=142366893209580 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============1539020321==" --===============1539020321== Content-Type: multipart/alternative; boundary=001a1133d6147dbe26050ed1aeb0 --001a1133d6147dbe26050ed1aeb0 Content-Type: text/plain; charset=UTF-8 Hi, On Wed, Feb 11, 2015 at 3:16 PM, Arjen Markus wrote: > Hello, > > I am trying to build the Fortran interface to NetCDF4 on Windows, using > the Intel Fortran compiler and "Nmake Makefiles" as the generator (see > http://www.unidata.ucar.edu/downloads/netcdf/index.jsp). > > I had some trouble getting the first part to build, but that is solved > (small issues with the code). The second part, which is supposed to build a > C library that can be called from Fortran, presents a more serious problem: > for some reason CMake picks parts of another toolchain to build this: > > The Makefile contains these lines to compile the sources: > cd D:\netcdf\netcdf-build-fortran\libsrc > C:\PROGRA~2\MICROS~3.0\VC\bin\amd64\cl.exe @<< > /nologo $(C_FLAGS) $(C_DEFINES) > /FoCMakeFiles\ncfortran.dir\fort-attio.c.obj > /FdD:\netcdf\netcdf-build-fortran\libsrc\ncfortran.pdb -c > D:\netcdf\netcdf-fortran-4.4.1\libsrc\fort-attio.c > > But to build the library it contains: > > libsrc\ncfortran.dll: d:\netcdf\netcdf-build\liblib\netcdf.lib > libsrc\ncfortran.dll: libsrc\CMakeFiles\ncfortran.dir\objects1.rsp > @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --red > --bold "Linking C shared library ncfortran.dll" > cd D:\netcdf\netcdf-build-fortran\libsrc > d:\CMake2.8.10.2\bin\cmake.exe -E vs_link_dll > C:\PROGRA~2\HASKEL~1\201320~1.0\mingw\bin\ld.exe /nologo > @CMakeFiles\ncfortran.dir\objects1.rsp @<< > /out:ncfortran.dll /implib:ncfortran.lib > /pdb:D:\netcdf\netcdf-build-fortran\libsrc\ncfortran.pdb /dll /version:0.0 > /STACK:10000000 /INCREMENTAL:YES /machine:x64 /debug > d:\netcdf\netcdf-build\liblib\netcdf.lib kernel32.lib user32.lib gdi32.lib > winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib > advapi32.lib > << > > As you can see, it has picked up a linker (ld.exe) belonging to a > completely different compiler/package for this step. > > I have no idea where this is coming from and how to fix this. Does anyone > have any suggestions? Seeing the path to that ld.exe I'm reminded of a problem a colleague recently had. He has Haskell installed on his system and either haskell itself or some haskell library came with mingw and his PATH ended up including the bin dir of that mingw installation. Even if that entry is after the VS compiler CMake apparently chooses to pick up the mingw toolchain (or parts of it), so one has to make sure that there's no MinGW compiler or linker or other part of the toolchain in any of the directories in PATH. At least thats how he resolved the issue. Andreas --001a1133d6147dbe26050ed1aeb0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,

On Wed, Feb 11, 2015 at 3:16 PM, Arjen Markus <Arjen.Markus@delt= ares.nl> wrote:
Hello,

I am trying to build the Fortran interface to NetCDF4 on Windows, using the= Intel Fortran compiler and "Nmake Makefiles" as the generator (s= ee http://www.unidata.ucar.edu/downloads/netcdf/index.jsp).
I had some trouble getting the first part to build, but that is solved (sma= ll issues with the code). The second part, which is supposed to build a C l= ibrary that can be called from Fortran, presents a more serious problem: fo= r some reason CMake picks parts of another toolchain to build this:

The Makefile contains these lines to compile the sources:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 cd D:\netcdf\netcdf-build-fortran\libsrc
=C2=A0 =C2=A0 =C2=A0 =C2=A0 C:\PROGRA~2\MICROS~3.0\VC\bin\amd64\cl.exe=C2= =A0 @<<
=C2=A0/nologo $(C_FLAGS) $(C_DEFINES) /FoCMakeFiles\ncfortran.dir\fort-atti= o.c.obj /FdD:\netcdf\netcdf-build-fortran\libsrc\ncfortran.pdb -c D:\netcdf= \netcdf-fortran-4.4.1\libsrc\fort-attio.c

But to build the library it contains:

libsrc\ncfortran.dll: d:\netcdf\netcdf-build\liblib\netcdf.lib
libsrc\ncfortran.dll: libsrc\CMakeFiles\ncfortran.dir\objects1.rsp
=C2=A0 =C2=A0 =C2=A0 =C2=A0 @$(CMAKE_COMMAND) -E cmake_echo_color --switch= =3D$(COLOR) --red --bold "Linking C shared library ncfortran.dll"=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 cd D:\netcdf\netcdf-build-fortran\libsrc
=C2=A0 =C2=A0 =C2=A0 =C2=A0 d:\CMake2.8.10.2\bin\cmake.exe -E vs_link_dll C= :\PROGRA~2\HASKEL~1\201320~1.0\mingw\bin\ld.exe /nologo @CMakeFiles\ncfortr= an.dir\objects1.rsp @<<
=C2=A0/out:ncfortran.dll /implib:ncfortran.lib /pdb:D:\netcdf\netcdf-build-= fortran\libsrc\ncfortran.pdb /dll /version:0.0 /STACK:10000000 /INCREMENTAL= :YES /machine:x64=C2=A0 /debug d:\netcdf\netcdf-build\liblib\netcdf.lib ker= nel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.= lib uuid.lib comdlg32.lib advapi32.lib
<<

As you can see, it has picked up a linker (ld.exe) belonging to a completel= y different compiler/package for this step.

I have no idea where this is coming from and how to fix this. Does anyone h= ave any suggestions?

Seeing the path to tha= t ld.exe I'm reminded of a problem a colleague recently had. He has Has= kell installed on his system and either haskell itself or some haskell libr= ary came with mingw and his PATH ended up including the bin dir of that min= gw installation. Even if that entry is after the VS compiler CMake apparent= ly chooses to pick up the mingw toolchain (or parts of it), so one has to m= ake sure that there's no MinGW compiler or linker or other part of the = toolchain in any of the directories in PATH. At least thats how he resolved= the issue.

Andreas
--001a1133d6147dbe26050ed1aeb0-- --===============1539020321== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- 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 --===============1539020321==--