[vtkusers] Problems compiling VTK 4 under cygwin with shared libs

Carl Hetherington lists at carlh.net
Thu Dec 20 05:50:48 EST 2001


On Wed, 19 Dec 2001, Mumit Khan wrote:

> On Wed, 19 Dec 2001, Carl Hetherington wrote:
[snip] 
> > c++    -g -O2 -mwin32 -o \
> >   /usr/local/src/VTK/CVS-nightly/VTK/bin/libvtkzlib \
> >   adler32.o gzio.o inftrees.o uncompr.o compress.o infblock.o infutil.o
> > zutil.o crc32.o infcodes.o deflate.o inffast.o inflate.o trees.o
> > -L/usr/local/src/VTK/CVS-nightly/VTK/bin/ -lpthread -lm
> > /usr/lib/libpthread.a(libcmain.o)(.text+0x6a): undefined reference to
> > `WinMain at 16'
> 
> Take out -lpthread and -lm, and if that fixes the problem, then I know
> what the problem is. There is a long standing problem that if you link
> a C++ application with a library that is a link to libcygwin1.a (which
> libpthread.a and libm.a are), you get link errors. All the pthread code
> is already in libcygwin1.a, which is linked in implicitly. Be aware that
> the POSIX threading code in Cygwin is incomplete.

Thanks Mumit.

Removing -lpthread and -lm does not fix the problem, unfortunately.

I note that the "undefined reference to WinMain at 16" error is exactly what
is returned when I try to link any code which does not contain a main() or
WinMain() routine.  It seems to me that the link step for libvtkzlib
should be a /partial/ linkage, not one that tries to create an executable.

For example:

% cat test.cxx
#include <iostream>
int thing()
{
  cout << "Hello" << endl;
}

% c++ -c -o test.o test.cxx
% c++ -o test test.o
/usr/lib/libcygwin.a(libcmain.o)(.text+0x6a): undefined reference to
`WinMain at 16'
collect2: ld returned 1 exit status

It seems that the Makefile has not been built correctly and that the c++
command for linking this library should be replaced by something else
(e.g. an ar?)

Any comments would be welcome (especially if I am on completely the wrong
track!)

Cheers
Carl






More information about the vtkusers mailing list