by Nicolas Luck

Thursday, February 12, 2009

cygwin and undefined reference to `__getreent’

I’m trying to switch from Visual Studio to Qt Creator. Since I used qmake for the project I want to develop right from the start this should not be too dificult. But Qt Creator uses GCC (on Windows MinGW). So I’m also switching from Microsofts Compiler to MinGW.

This should not be a problem neither.. But I’m using LAPACK! More precisely CLAPACK. Somwhere on the net I found a clapack.lib when I started that project. But now I had to compile CLAPACK myself.

So I downloaded the CLAPACK sources and compiled them in cygwin (perhaps that was the problem. should have used the MinGW I use in Qt Creator..? Well, compiling CLAPACK under Windows with MinGW and without Cygwin isn’t that easy). Then I copied liblapack.a, libblas.a and libf2c.a into the lib directory of my Qt Creator-MinGW installation. And then I got:
C:/Qt/QtCreator/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../libf2c.a(f77_aloc.o):(.text+0x2a): undefined reference to `__getreent’
After some googling I found out that what’s missing is libcygwin.a, which comes with cygwin (/lib in the cygwin directory). I copied this file to the MinGW installation’s lib directory and added a -lcygwin and the undefined reference was gone.

Edit:
That was not all. Now I get:
C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../libcygwin.a(d000681.o)(.text+0×0): multiple definition of `atexit’
C:/MinGW/bin/../lib/gcc/mingw32/3.4.2/../../../crt2.o(.text+0×260):crt1.c: first defined here

I solved this by overwriting MinGW’s crt2.o with cygwin’s crt0.o. Now I have a cygwinized MinGW installation with a working lapack compilation and I can use Qt Creator to compile my project! Only drawback is that I now have to deploy the cygwin.dll together with the executable.

posted by lucksus at 2:24 pm  

2 Comments »

  1. Oh man, thank you so much for cygwiniization hint..
    I solved this by overwriting MinGW’s crt2.o with cygwin’s crt0.o

    I just could not find a solution anywhere.

    Comment by Dmitry — March 10, 2009 @ 6:57 pm

  2. Thanks a lot man! It’s really helpful.

    Comment by Endru — August 13, 2010 @ 11:12 am

RSS feed for comments on this post. TrackBack URI

Leave a comment

Powered by WordPress