[CMake] Incorrect extra MinGW link flags

Yuri Timenkov yuri at timenkov.ru
Thu May 19 08:41:16 EDT 2011


May be you should use Cygwin build of CMake?

On Thu, May 19, 2011 at 12:46 PM, Stiaan Gerber <sgerber at sun.ac.za> wrote:

>  Dear list
>
> On Windows, MinGW (gcc 4.5.2), CMake 2.8.4.
>
> I have a project building two executables. The first one builds correctly.
> On the second one it appears to me as though CMake adds flags to link to the
> standard MinGW libraries (mingw32, moldname, mingwex, ...) with an incorrect
> .lib suffix.  (See the output below) As far as I can tell this is totally
> unnecessary since these flags are automatically added by the gfortran
> compiler. So in the end I have -lmingw32.lib (presumably added by CMake,
> which fails) and -lmingw32 (automatically added by gfortran, which correctly
> links libmingw32.a)
>
> My CMakelists file for the target CE_SEMFEM is
>
> -------------------------------------------------------------------------------------------------------
> cmake_minimum_required (VERSION 2.8.4)
> project (CE_SEMFEM Fortran)
>
> set (CE_SRCS
>     src/CE_SEMFEM.f95
>     src/CE_config_module.f95
> )
>
> add_executable (CE_SEMFEM ${CE_SRCS})
> target_link_libraries (CE_SEMFEM SEMFEM CE_FEMxml xmlparse)
>
> -------------------------------------------------------------------------------------------------------
>
> The libraries SEMFEM, CE_FEMxml and xmlparse are built elsewhere in the
> project.
>
> Ideas how I can fix this? Any help is much appreciated.
>
> Stiaan
>
>
> -------------------------------------------------------------------------------------------------------
> Linking Fortran executable CE_SEMFEM.exe
> Driving: C:\MinGW\bin\gfortran.exe -v
> CMakeFiles/CE_SEMFEM.dir/src/CE_SEMFEM.f95.obj
> CMakeFiles/CE_SEMFEM.dir/src/CE_con
> fig_module.f95.obj -o CE_SEMFEM.exe
> -LC:\Loher_Berechner_repo\build\Utilities\xml_parser
> -LC:\Loher_Berechner_repo\build
> \SEMFEM\trunk\SEMFEM\core -Lc:\MinGW\lib\gcc\mingw32\4.5.2
> -Lc:\MinGW\lib\gcc -Lc:\MinGW\mingw32\lib -Lc:\MinGW\lib -L\M
> inGW\lib ..\..\core\SEMFEM.lib
> ..\..\..\..\..\Utilities\xml_parser\libCE_FEMxml.a
> ..\..\..\..\..\Utilities\xml_parser\li
> bxmlparse.a C:\MPICH2\lib\fmpich2g.lib -lmingw32.lib -lmoldname.lib
> -lmingwex.lib -lmsvcrt.lib -luser32.lib -lkernel32.l
> ib -ladvapi32.lib -lshell32.lib -lmingw32.lib -lmoldname.lib -lmingwex.lib
> -lmsvcrt.lib -lgfortran -shared-libgcc
> Using built-in specs.
> COLLECT_GCC=C:\MinGW\bin\gfortran.exe
>
> COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.5.2/lto-wrapper.exe
> Target: mingw32
> Configured with: ../gcc-4.5.2/configure
> --enable-languages=c,c++,ada,fortran,objc,obj-c++ --disable-sjlj-exceptions
> --wi
> th-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry
> --enable-libstdcxx-debug --enable-version-specific-r
> untime-libs --disable-werror --build=mingw32 --prefix=/mingw
> Thread model: win32
> gcc version 4.5.2 (GCC)
>
> COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/4.5.2/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.
> 5.2/../../../../mingw32/bin/
>
> LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/4.5.2/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../..
>
> /../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../;/mingw/lib/
> COLLECT_GCC_OPTIONS='-v' '-o' 'CE_SEMFEM.exe'
> '-LC:\Loher_Berechner_repo\build\Utilities\xml_parser' '-LC:\Loher_Berechn
> er_repo\build\SEMFEM\trunk\SEMFEM\core' '-Lc:\MinGW\lib\gcc\mingw32\4.5.2'
> '-Lc:\MinGW\lib\gcc' '-Lc:\MinGW\mingw32\lib'
>  '-Lc:\MinGW\lib' '-L\MinGW\lib' '-shared-libgcc' '-mtune=i386'
> '-march=i386'
>  c:/mingw/bin/../libexec/gcc/mingw32/4.5.2/collect2.exe -Bdynamic -u
> ___register_frame_info -u ___deregister_frame_info
> -o CE_SEMFEM.exe c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../crt2.o
> c:/mingw/bin/../lib/gcc/mingw32/4.5.2/crtbegin.o
> -LC:\Loher_Berechner_repo\build\Utilities\xml_parser
> -LC:\Loher_Berechner_repo\build\SEMFEM\trunk\SEMFEM\core -Lc:\MinGW
> \lib\gcc\mingw32\4.5.2 -Lc:\MinGW\lib\gcc -Lc:\MinGW\mingw32\lib
> -Lc:\MinGW\lib -L\MinGW\lib -Lc:/mingw/bin/../lib/gcc/m
> ingw32/4.5.2 -Lc:/mingw/bin/../lib/gcc
> -Lc:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/lib
> -Lc:/mingw/bin/..
> /lib/gcc/mingw32/4.5.2/../../.. -L/mingw/lib
> CMakeFiles/CE_SEMFEM.dir/src/CE_SEMFEM.f95.obj CMakeFiles/CE_SEMFEM.dir/src
> /CE_config_module.f95.obj ..\..\core\SEMFEM.lib
> ..\..\..\..\..\Utilities\xml_parser\libCE_FEMxml.a ..\..\..\..\..\Utilit
> ies\xml_parser\libxmlparse.a C:\MPICH2\lib\fmpich2g.lib -lmingw32.lib
> -lmoldname.lib -lmingwex.lib -lmsvcrt.lib -luser32
> .lib -lkernel32.lib -ladvapi32.lib -lshell32.lib -lmingw32.lib
> -lmoldname.lib -lmingwex.lib -lmsvcrt.lib -lgfortran -lmi
> ngw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -luser32 -lkernel32
> -ladvapi32 -lshell32 -lmingw32 -lgcc_s -lgcc -lmol
> dname -lmingwex -lmsvcrt c:/mingw/bin/../lib/gcc/mingw32/4.5.2/crtend.o
> c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe:
> cannot find -lmingw32.lib
> c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe:
> cannot find -lmoldname.lib
> c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe:
> cannot find -lmingwex.lib
> c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe:
> cannot find -lmsvcrt.lib
> c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe:
> cannot find -luser32.lib
> c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe:
> cannot find -lkernel32.lib
> c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe:
> cannot find -ladvapi32.lib
> c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe:
> cannot find -lshell32.lib
> c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe:
> cannot find -lmingw32.lib
> c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe:
> cannot find -lmoldname.lib
> c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe:
> cannot find -lmingwex.lib
> c:/mingw/bin/../lib/gcc/mingw32/4.5.2/../../../../mingw32/bin/ld.exe:
> cannot find -lmsvcrt.lib
> collect2: ld returned 1 exit status
>
> -------------------------------------------------------------------------------------------------------
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110519/85a3818a/attachment-0001.htm>


More information about the CMake mailing list