This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Using main() from a shared library in Cygwin 1.7


Hi,

I have an application, which links with a shared library (fairly common
situation :)).  This shared library provides the main() function.  This
approach works well on Linux/Solaris machines, but on Cygwin 1.7
I get the following link error:

/usr/lib/gcc/i686-pc-cygwin/4.3.4/../../../libcygwin.a(libcmain.o):(.text+0xa9):
undefined reference to `_WinMain@16'

I created my shared library with:
g++ -c -fPIC main_in_shared.cpp
g++ -shared -fPIC -o libmain_in_shared.dll.a main_in_shared.o

And finally:
g++ -fPIC -o app app.cpp libmain_in_shared.dll.a, which fails...

Some additional info:
CYGWIN_NT-6.0 EVD8D3859A6470 1.7.2(0.225/5/3) 2010-03-24 21:12 i686 Cygwin
gcc version 4.3.4 20090804 (release) 1 (GCC)

$ nm libmain_in_shared.dll.a | grep main
70b41270 T ___main
70b460d8 I __imp____main
70b41c40 T _cygwin_premain0
70b41c50 T _cygwin_premain1
70b41c60 T _cygwin_premain2
70b41c70 T _cygwin_premain3
70b410f0 T _main

With static libraries it links fine, so I don't think that the order of
the libraries (as I see the output of `g++ -v') matters here.

Could somebody please explain what's going on here?  I couldn't find anything
really relevant after a few hours of Google-ing...

Thanks in advance!

Cheers,
Ferenc

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]