On 27.11.2012 22:28, green fox wrote:
> Enviroment:
> OS Windows7 , cygwin 1.7.14(0.260/5/3) , gcc 4.5.3
> Used ./configure --enable-threads --prefix=/usr --host=x86_64-w64-mingw32-gcc

First of all, I second what Ian wrote: if you want to build Windows
native apps, it's far better (today) to use MinGW than to use Cygwin
with MinGW cross compiler tools. Compiling is faster, and usually you
have less problems. I used to use Cygwin at times when MinGW didn't
have an installer (now it has mingw-get, similar to apt-get), and
when Cygwin had the gcc -mno-cygwin option. These times are gone,
and the Cygwin folks even seem to prefer to build "Cygwin" apps instead
of native Windows apps - nowadays the default FLTK build under Cygwin
would be to use X as the window system, not native Windows (GDI).

So I recommend to switch over to MinGW to build native (Windows) FLTK
apps, it's faster and easier today. Use mingw-get-inst for the first
installation (see the MinGW web site) and mingw-get for later upgrades.

That said, I (still) have my Cygwin setup on Win7 with the MinGW cross
tools, and compiling / linking with threads works for me:

$ uname -a
CYGWIN_NT-6.1-WOW64 as-w7 1.7.15(0.260/5/3) 2012-05-09 10:25 i686 Cygwin
$ x86_64-w64-mingw32-gcc --version | head -n1
x86_64-w64-mingw32-gcc (GCC) 4.5.3

Configure usage (with or w/o --enable-threads doesn't matter!):

$ MY_PREFIX="/usr/local/fltk-1.3-cygwin"
$ CXXFLAGS="" \
   LDFLAGS="-static-libgcc -static-libstdc++" \
   ./configure \
   --enable-threads \
   --host=x86_64-w64-mingw32 \
   --build=i686-pc-cygwin \
   --prefix=${MY_PREFIX}-w64

After running configure, config.h doesn't have HAVE_PTHREAD_H defined
(correct), and the thread demo builds and runs w/o problems.

$ grep -i1 thread config.h
/*
  * Do we have POSIX threading?
  */

/* #undef HAVE_PTHREAD */
/* #undef HAVE_PTHREAD_H */


> Problem:
> Dies when compiling threads.cxx... with
> threads.h:56:74: error: `_beginthread' was not declared in this scope
> Due to headers for _beginthread() missing in some mingw packages.

What does this mean, "in some mingw packages"? What about the one you
have? Can you upgrade it?

> MingW packages are supposed to have them.But current cygwin package
> somehow does not have it.

Mine seems to have it!

> Digging around cygwin mailing list, there appears to be fix on the
> next release, however ETA is unknown.
> Using gcc3 is a workaround, but defeats the whole purpose of
> mingw-gcc4, and -mno-cygwin is long gone.
> For the current situation, most likely one has pthread, so the logical option
> is to use pthreads instead of the native _beginthread(). Am I on the
> right track ?
>
> What would be the better option
>
> 1) Patch configure.in so that it has --enable-pthreads or such
>      Patch towards 1.3.1 ? or would it be better to do work on the 1.4/3.0?
> 2) Fiddle with config.h for HAVE_PTHREAD_H 1
> 3) Throw away cygwin :-)

As Ian said, better to use MinGW...

> To recreate situation:
> Under cygwin, -mno-cygwin option is no longer supported and users are
> supposed to use mingw-64 cross compilers.
> # Avoid conflict of /lib/libuuid.a and /lib/w32api/libuuid.a
> apt-cyg remove libuuid-devel
> apt-cyg remove libuuid1

Hmm, apt-cyg? Is this official? I don't think so.

> # We use gcc4, -mno-cygwin option is removed
> /bin/set-gcc-default-4.sh
> ./configure --enable-threads --prefix=/usr --host=x86_64-w64-mingw32-gcc && 
> make
> And I get the following error
> ...
> Linking tabs.exe...
> Compiling threads.cxx...
> In file included from threads.cxx:27:0:
> threads.h: In function `int fl_create_thread(Fl_Thread&, void*
> (*)(void*), void*)':
> threads.h:56:74: error: `_beginthread' was not declared in this scope
> threads.h:57:1: warning: control reaches end of non-void function
> ../makeinclude:148: recipe for target `threads.o' failed
> make[1]: *** [threads.o] Error 1
> Makefile:24: recipe for target `all' failed
> make: *** [all] Error 1

Something seems to be broken, indeed. Did you try to upgrade w32api?

> My limited knowledge tells me that _beginthread() is defined in <process.h>
>   http://msdn.microsoft.com/en-gb/library/kdzttdcb%28VS.80%29.aspx
> And looking at ./test/threads.h , under #elif defined(WIN32) &&
> !defined(__WATCOMC__)
> we have #include <process.h> , so all is good.
> We have 
> mingw64-x86_64-{gcc,gcc-core,gcc-g++,gcc-objc,headers,pthreads,runtime}
> installed, good.
> But we do not have _beginthread() anywhere. So I need a header for that, or
> if we can use pthread,that can provide equlavant.
> grep /usr/include/pthread.h tells me it has pthread_create() so all is good.
>
> So, unless configure.in is fixed, I need to enable HAVE_PTHREAD_H
> somehow, or instal missing headers (I dont think this is going to be a
> fun thing to do, esp when we have 4 options on main mingw site, 1
> available and 1 unpackaged cygwin varant of mingw, and with
> possibility of mess regarding the package manager).
> To enable pthread, editing config.h with #define HAVE_PTHREAD_H 1 was enough.
> Compiles and tests runs fine.
> Could there be a better way... prahaps ./configure --enable-pthreads or such ?

As Ian said, I wouldn't mix runtimes. Also, if you use (Cygwin?)
pthreads, don't you need the Cygwin dll and so also the Cygwin
license?


Albrecht

_______________________________________________
fltk-dev mailing list
fltk-dev@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to