[CMake] Problems with linking on MinGW?
Hendrik Sattler
post at hendrik-sattler.de
Tue Jun 15 13:32:44 EDT 2010
Am Dienstag 15 Juni 2010, 18:25:20 schrieb Jesse Perla:
> On Tue, Jun 15, 2010 at 12:01 PM, Hendrik Sattler
>
> <post at hendrik-sattler.de>wrote:
> > Your library name is NOT "libetk-mgw45". Try "etk-mgw45" instead and read
> > about library file names.
>
> Thanks for your help. Alas, on MSVC10 and Intel11.1 windows, the
> "link_directories" and "target_link_libraries" approach I used above (with
> the full filename) worked fine and hence never tried other methods
>
> I had tried the "etk-mgw45" without the "lib" and it didn't seem to work.
gcc and msvc differ in their library naming. While gcc uses libfoo.a, msvc
uses foo.lib. So your library must have the right naming according to the
compiler you are going to use. To avoid other problems, you should have used
the same compiler for the library.
> Also, do not use link_directories() but use find_library() and the value
> you
>
> > get from it.
>
> I have tried a few permutations with find_library, but not having a lot of
> luck. Here is the current section of code I am testing with.
>
> link_directories( "c:/working/etk_binaries")
> find_library(LIB_NAME "etk-mgw45-d" "c:/working/etk_binaries")
You are not using find_library() correctly!:
find_library(LIB_NAME etk-mgw45-d HINTS "c:/working/etk_binaries")
And omit the link_directories() call.
> Any ideas?
You _really_ need to read about the proper library naming for your compilers!
That's why you got confused.
HS
More information about the CMake
mailing list