[CMake] Weird linking error while cross compiling

Jose jc.fernandez.navarro at gmail.com
Wed Oct 26 03:54:02 EDT 2011


Sorry for not being very specific.

This is the command that Cmake is running while linking :

/usr/bin/i686-pc-mingw32-g++  -O3 -O3    -Wl,-Bstatic -static-libgcc
-Wl,--whole-archive CMakeFiles/sqt2pin.dir/objects.a -Wl,--no-whole-archive
-o sqt2pin.exe -Wl,--out-implib,libsqt2pin.dll.a
-Wl,--major-image-version,0,--minor-image-version,0
-L/home/fedora/percolator/percolator/src/converters/../../src
libconverters.a libperclibrary_part.a MSToolkit/libMSToolkit.a
MSToolkit/RAMP/libRAMP.a -lxerces-c -lportablexdr
/home/fedora/percolator/percolator/src/converters/libs/dll/libtokyocabinet.a
-lz -lsqlite3 -Wl,-Bstatic -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32
-lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32
/usr/lib/gcc/i686-pc-mingw32/4.5.3/../../../../i686-pc-mingw32/bin/ld:
cannot find -lxerces-c
/usr/lib/gcc/i686-pc-mingw32/4.5.3/../../../../i686-pc-mingw32/bin/ld:
cannot find -lportablexdr
/usr/lib/gcc/i686-pc-mingw32/4.5.3/../../../../i686-pc-mingw32/bin/ld:
cannot find -lz
/usr/lib/gcc/i686-pc-mingw32/4.5.3/../../../../i686-pc-mingw32/bin/ld:
cannot find -lsqlite3

That is weird cos I "load" all the libraries in the same way and they all
the variables content the right paths to the libraries : (for example)

Xercesc : /usr/i686-pc-mingw32/sys-root/mingw/lib/libxerces-c.dll.a , XDR :
/usr/i686-pc-mingw32/sys-root/mingw/lib/libportablexdr.dll.a

This is how I link :

#COMPILING SQT2PIN
include_directories(. MSToolkit/RAMP MSToolkit )
add_executable(sqt2pin Sqt2Pin.cpp )
IF(STATIC AND MINGW)
  set_property(TARGET sqt2pin PROPERTY LINK_SEARCH_END_STATIC ON)
  set_target_properties(sqt2pin PROPERTIES LINK_FLAGS "-Wl,-Bstatic
-static-libgcc")
ENDIF()
message(STATUS "Xercesc : ${XERCESC_LIBRARIES} , XDR :
${PORTABLEXDR_LIBRARIES}")
target_link_libraries(sqt2pin converters perclibrary_part  MSToolkit RAMP
${XERCESC_LIBRARIES} ${PORTABLEXDR_LIBRARIES} ${TOKYOCABINET_LIBRARIES} )

I might  be missing something very stupid because I use the same prodecure
to search for the librarys....the FindXXX.cmake macros that are tested and
working with other programs.

Could it be the include_directories("library include dir") which is messing
this up? it looks like the linker disregard the path of the library that Im
pasinng and looks for -lxerces-c instead. Is that xerces-c defined somehow
before?

Thank you so much

Jose

2011/10/25 Andreas Pakulat <apaku at gmx.de>

> On 25.10.11 13:15:37, Jose wrote:
> > Hi all,
> >
> > I'm cross compiling an app under Fedora.  I get this linking errors while
> > building with cmake :
> >
> > /usr/lib/gcc/i686-pc-mingw32/4.5.3/../../../../i686-pc-mingw32/bin/ld:
> > cannot find -lxerces-c
> > /usr/lib/gcc/i686-pc-mingw32/4.5.3/../../../../i686-pc-mingw32/bin/ld:
> > cannot find -lportablexdr
> > /usr/lib/gcc/i686-pc-mingw32/4.5.3/../../../../i686-pc-mingw32/bin/ld:
> > cannot find -lz
> > /usr/lib/gcc/i686-pc-mingw32/4.5.3/../../../../i686-pc-mingw32/bin/ld:
> > cannot find -lsqlite3
> >
> >
> > The thing is that the libraries have been found,included and linked with
> > target_link_libraries. I'm adding all the necessary flags to link
> statically
> > and the libraries are the ones included in the mingw package. It shoud
> work
> > because a different part of the application that uses almost the same
> > libraries is cross compiling perfectly. The cmake files are actually
> pretty
> > much the same so I don't really know what I'm doing wrong. Cmake might be
> > missing the libraries or the path of the libraries....
>
> Hmm, -lfoo means the linker will search for a shared library. Linking
> static libraries is done by specifying the absolute path to the library
> file. How exactly are you calling target_link_libraries and assuming
> that you're passing above libraries via cmake-variables whats the
> content of those variables?
>
> Andreas
>
> --
>
> 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/20111026/88d47cf8/attachment.htm>


More information about the CMake mailing list