I'm trying to build CGAL for windows to use in my project under Visual Studio 2010. CGAL requires GMP and MPFR libraries and provides them in distribution. However, it provides them as a lib+dll bundle, while I want them to be compiled statically in form of a single .lib file.
So now I'm trying to build GMP and MPFR as a static library under windows. I'm using cygwin for this purpose as suggested here. After call to configure
and make
I have output libs with .a
extension with additional .la
file. I don't really know much about static libraries for Unix, so I suggested it is the same as .lib
with just different extension. I renamed it to .lib and linked to my project - it fitted well.
The first question: was I correct doing so? Are the .a and .lib files really the same? I saw this question, but didn't find it useful enough.
Then problem arose: I had
error LNK2019: unresolved external symbol ___getreent referenced in function ___gmp_default_reallocate
Seems like some cygwin functions are not linked in resulting gmp.lib
. I found here, that getreent
may be exported from libcygwin.a
. So I copied it to libcygwin.lib
and linked to my project. Not surprisingly, I received the following error:
error LNK2005: _strcpy already defined in libcygwin.lib(t-d001719.o) in libcmtd.lib(strcat.obj)
Of course, I cannot know what functions and how are declared in this library and seems like strcpy
is conflicting with one from Visual Studio. What I really want to happen is gmp.lib
would be smart enough to link this function statically. So,
The second question: how to force GMP to link library dependencies? or How to properly build GMP for windows without using cygwin?