* g++ linker problem with libcygwin.a
@ 2011-10-22 19:19 Philipp Kraus
2011-10-22 20:17 ` René Berber
2011-10-23 18:22 ` Csaba Raduly
0 siblings, 2 replies; 14+ messages in thread
From: Philipp Kraus @ 2011-10-22 19:19 UTC (permalink / raw)
To: cygwin
Hello,
I use Cygwin with g++ for compiling my source codes and on some codes I
get the error:
/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../libcygwin.a(libcmain.o):(.text+0xa9):
undefined reference to `_WinMain@16'
I link my sources to libraries like Boost, Atlas, LAPack...
All codes can be compiled under OSX and Linux without any warning /
error. I've found the information that the
error is thrown, if the main method is not found, but all programs have
the main methode like int main(int argc, char* argv[])
I try to solve the problem with a full reinstall of Cygwin but it does
not run. The linker command
shows like:
g++ -o build/test.exe -enable-stdcall-fixup examples/test.o
-L/usr/local/bin -L/usr/bin -L/cygdrive/c/Windows/system32
-L/cygdrive/c/Windows -L/cygdrive/c/Windows/system32/Wbem
-L/cygdrive/c/Windows/system32/WindowsPowerShell/v1.0
"-L/cygdrive/c/Program Files/TortoiseSVN/bin" "-L/cygdrive/c/Program
Files/Java/jdk1.6.0_29/bin" -L/usr/binÂ
-L/cygdrive/c/opt/library/atlas/3.9.51/lib
-L/cygdrive/c/opt/library/hdf/1.8.7/lib
-L/cygdrive/c/opt/library/xml2/2.7.8/bin
-L/cygdrive/c/opt/library/boost/1.47.0/bin -L/cygdrive/c/opt/library/boo
st/1.47.0/lib -L/cygdrive/c/opt/library/jsoncpp/0.5.0/lib
-L/cygdrive/c/opt/scons/bin
-lcygboost_system -lcygboost_thread -lcygboost_iostreams
-lcygboost_regex -lcygboost_program_options -lboost_exception
-lcygboost_filesystem -llapack -lcblas -lf77blas -latlas -lgfortran
-lhdf5_cpp -lhdf5
All depend libraries are build with Cygwin Gcc / G++ / GFortran also.
I've found a lot of posting with the similar / equal problem, but no
solution. Does anybody know a solution for the linker problem?
Thanks
Phil
--
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: g++ linker problem with libcygwin.a
2011-10-22 19:19 g++ linker problem with libcygwin.a Philipp Kraus
@ 2011-10-22 20:17 ` René Berber
2011-10-22 20:37 ` Philipp Kraus
2011-10-23 18:22 ` Csaba Raduly
1 sibling, 1 reply; 14+ messages in thread
From: René Berber @ 2011-10-22 20:17 UTC (permalink / raw)
To: cygwin
On 10/22/2011 2:18 PM, Philipp Kraus wrote:
> I use Cygwin with g++ for compiling my source codes and on some codes I
> get the error:
>
> /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../libcygwin.a(libcmain.o):(.text+0xa9):
> undefined reference to `_WinMain@16'
[snip]
That means the linking is being done for a GUI application. I guess you
wanted to build a console application, so you should learn what these
options for the linker mean:
-Wl,-subsystem,console
-Wl,-subsystem,windows
There are equivalent options used with the compiler g++, I think they are:
-mconsole
-mwindows
In general there are many options that apply only to Windows builds, for
instance building Qt GUI applications I use these for the linker:
-Wl,-enable-stdcall-fixup -Wl,-enable-auto-import
-Wl,-enable-runtime-pseudo-reloc -Wl,-as-needed
but they are not for solving linking errors, just to quiet the warnings,
and try to optimize the result.
--
René Berber
--
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: g++ linker problem with libcygwin.a
2011-10-22 20:17 ` René Berber
@ 2011-10-22 20:37 ` Philipp Kraus
2011-10-22 21:44 ` René Berber
0 siblings, 1 reply; 14+ messages in thread
From: Philipp Kraus @ 2011-10-22 20:37 UTC (permalink / raw)
To: cygwin
Thanks for your great answer.
On 2011-10-22 22:17:06 +0200, René Berber said:
> On 10/22/2011 2:18 PM, Philipp Kraus wrote:
>
>> I use Cygwin with g++ for compiling my source codes and on some codes I
>> get the error:
>>
>> /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../libcygwin.a(libcmain.o):(.text+0xa9):
>>
>> undefined reference to `_WinMain@16'
> [snip]
>
> That means the linking is being done for a GUI application. I guess you
> wanted to build a console application, so you should learn what these
> options for the linker mean:
>
> -Wl,-subsystem,console
> -Wl,-subsystem,windows
>
> There are equivalent options used with the compiler g++, I think they are:
>
> -mconsole
> -mwindows
Yes I would build a console application (or a shared library, I can
build the library).
I have tried both commands -mconsole and -Wl,-subsystem,console but the error
is created again. Should I rebuild my libraries with the -mconsole
option, at the time
I have build them only with configure, make, make install?
Thanks
Phil
--
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: g++ linker problem with libcygwin.a
2011-10-22 20:37 ` Philipp Kraus
@ 2011-10-22 21:44 ` René Berber
2011-10-22 22:49 ` Philipp Kraus
0 siblings, 1 reply; 14+ messages in thread
From: René Berber @ 2011-10-22 21:44 UTC (permalink / raw)
To: cygwin
On 10/22/2011 3:37 PM, Philipp Kraus wrote:
[snip]
> error
> is created again. Should I rebuild my libraries with the -mconsole
> option, at the time
> I have build them only with configure, make, make install?
You can check which libraries have a reference to _WinMain@16 by using nm.
$ nm /usr/local/bin/<your_library>.dll | grep WinMain
then rebuild only those.
--
René Berber
--
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: g++ linker problem with libcygwin.a
2011-10-22 21:44 ` René Berber
@ 2011-10-22 22:49 ` Philipp Kraus
2011-10-22 23:29 ` René Berber
0 siblings, 1 reply; 14+ messages in thread
From: Philipp Kraus @ 2011-10-22 22:49 UTC (permalink / raw)
To: cygwin
On 2011-10-22 23:43:32 +0200, René Berber said:
> On 10/22/2011 3:37 PM, Philipp Kraus wrote:
>
> [snip]
>> error
>> is created again. Should I rebuild my libraries with the -mconsole
>> option, at the time
>> I have build them only with configure, make, make install?
>
> You can check which libraries have a reference to _WinMain@16 by using nm.
>
> $ nm /usr/local/bin/<your_library>.dll | grep WinMain
>
> then rebuild only those.
I have checked each library (*.dll, *.a, *.dll.a) but no library file
as got a reference to the _WinMain
and I use the -mconsole linker flag. I don't understand why the linker
creates the error on some
codes and on other code there is no error. Linker options are the same
Thx
Phil
--
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: g++ linker problem with libcygwin.a
2011-10-22 22:49 ` Philipp Kraus
@ 2011-10-22 23:29 ` René Berber
2011-10-22 23:37 ` René Berber
2011-10-23 10:07 ` Philipp Kraus
0 siblings, 2 replies; 14+ messages in thread
From: René Berber @ 2011-10-22 23:29 UTC (permalink / raw)
To: cygwin
On 10/22/2011 5:48 PM, Philipp Kraus wrote:
> I have checked each library (*.dll, *.a, *.dll.a) but no library file as
> got a reference to the _WinMain
> and I use the -mconsole linker flag. I don't understand why the linker
> creates the error on some
> codes and on other code there is no error. Linker options are the same
Sorry I missed the obvious, from your first message the library in
question is libcygwin.a :
$ nm /usr/lib/libcygwin.a | grep WinMain
U _WinMain@16
I'm not sure why this static library is pulled. I also don't know what
it is, cygwin1.dll doesn't have the reference.
--
René Berber
--
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: g++ linker problem with libcygwin.a
2011-10-22 23:29 ` René Berber
@ 2011-10-22 23:37 ` René Berber
2011-10-23 10:38 ` Philipp Kraus
2011-10-23 10:07 ` Philipp Kraus
1 sibling, 1 reply; 14+ messages in thread
From: René Berber @ 2011-10-22 23:37 UTC (permalink / raw)
To: cygwin
On 10/22/2011 6:28 PM, René Berber wrote:
> I also don't know what it is [libcygwin.a]
Looking at where it came from, libg.a is a symlink to this one, and libg
is known as "special debugging-enabled C library".
Still don't know what its doing in your program.
--
René Berber
--
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: g++ linker problem with libcygwin.a
2011-10-22 23:29 ` René Berber
2011-10-22 23:37 ` René Berber
@ 2011-10-23 10:07 ` Philipp Kraus
2011-10-23 17:53 ` René Berber
1 sibling, 1 reply; 14+ messages in thread
From: Philipp Kraus @ 2011-10-23 10:07 UTC (permalink / raw)
To: cygwin
On 2011-10-23 01:28:37 +0200, René Berber said:
> I'm not sure why this static library is pulled.
yes *g* that my problem also. My cygwin g++ / ld
links it automatically
Phil
--
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: g++ linker problem with libcygwin.a
2011-10-22 23:37 ` René Berber
@ 2011-10-23 10:38 ` Philipp Kraus
0 siblings, 0 replies; 14+ messages in thread
From: Philipp Kraus @ 2011-10-23 10:38 UTC (permalink / raw)
To: cygwin
On 2011-10-23 01:37:19 +0200, René Berber said:
> On 10/22/2011 6:28 PM, René Berber wrote:
>
>> I also don't know what it is [libcygwin.a]
>
> Looking at where it came from, libg.a is a symlink to this one, and libg
> is known as "special debugging-enabled C library".
>
> Still don't know what its doing in your program.
If I add #include <windows.h> to the program compiling and linking works fine,
but I don't understand it....
Phil
--
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: g++ linker problem with libcygwin.a
2011-10-23 10:07 ` Philipp Kraus
@ 2011-10-23 17:53 ` René Berber
2011-10-23 17:58 ` René Berber
0 siblings, 1 reply; 14+ messages in thread
From: René Berber @ 2011-10-23 17:53 UTC (permalink / raw)
To: cygwin
On 10/23/2011 5:07 AM, Philipp Kraus wrote:
> On 2011-10-23 01:28:37 +0200, René Berber said:
>
>> I'm not sure why this static library is pulled.
>
> yes *g* that my problem also. My cygwin g++ / ld
> links it automatically
Where it comes from? The compiler specs:
$ g++ -dumpspecs
...
*lib:
%{pg:-lgmon} %{!mno-cygwin:-lcygwin} ...
Its always linked and needed, and it doesn't cause the "undefined
reference to _WinMain" problem in other compilations.
There must be something else that uses something that pulls _WinMain.
Perhaps looking at the link map will clarify what is going on:
g++ -Wl,-M ... > link-map.txt
--
René Berber
--
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: g++ linker problem with libcygwin.a
2011-10-23 17:53 ` René Berber
@ 2011-10-23 17:58 ` René Berber
2014-03-17 1:57 ` zosrothko
0 siblings, 1 reply; 14+ messages in thread
From: René Berber @ 2011-10-23 17:58 UTC (permalink / raw)
To: cygwin
On 10/23/2011 12:52 PM, René Berber wrote:
> Perhaps looking at the link map will clarify what is going on:
>
> g++ -Wl,-M ... > link-map.txt
Or better, use the linker trace symbol functionality:
g++ -Wl,-trace-symbol=_WinMain ...
--
René Berber
--
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: g++ linker problem with libcygwin.a
2011-10-22 19:19 g++ linker problem with libcygwin.a Philipp Kraus
2011-10-22 20:17 ` René Berber
@ 2011-10-23 18:22 ` Csaba Raduly
1 sibling, 0 replies; 14+ messages in thread
From: Csaba Raduly @ 2011-10-23 18:22 UTC (permalink / raw)
To: cygwin
On Sat, Oct 22, 2011 at 9:18 PM, Philipp Kraus wrote:
> Hello,
>
> I use Cygwin with g++ for compiling my source codes and on some codes I get
> the error:
>
> /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../libcygwin.a(libcmain.o):(.text+0xa9):
> undefined reference to `_WinMain@16'
If there is no main(), libcygwin.a gives you a last chance: maybe
there is a WinMain function defined in your code, which will be called
by libc to start the program.
(or something like that)
Csaba
--
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds
--
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: g++ linker problem with libcygwin.a
2011-10-23 17:58 ` René Berber
@ 2014-03-17 1:57 ` zosrothko
2014-03-17 2:28 ` Marco Atzeri
0 siblings, 1 reply; 14+ messages in thread
From: zosrothko @ 2014-03-17 1:57 UTC (permalink / raw)
To: cygwin
Hi
Here the definition of the cmain.c program, part of libcygwin.a. This code
has a "main" entry point which is calling the WinMain by the end.... So the
question remains: Why g++/ld links with this "main" entry instead of the one
of the user's main program?
zos
/* libcmain.c
Copyright 1996, 1997, 1998, 2000, 2001, 2006, 2009 Red Hat, Inc.
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include <windows.h>
#define SP " \t\n"
/* Allow apps which don't have a main to work, as long as they define
WinMain */
int
main ()
{
HMODULE x = GetModuleHandle (0);
char *s = GetCommandLine ();
STARTUPINFO si;
char *nexts;
s += strspn (s, SP);
if (*s != '"')
nexts = strpbrk (s, SP);
else
while ((nexts = strchr (s + 1, '"')) != NULL && nexts[-1] == '\\')
s = nexts;
if (!nexts)
nexts = strchr (s, '\0');
else
nexts += strspn (nexts + 1, SP);
GetStartupInfo (&si);
return WinMain (x, 0, nexts,
((si.dwFlags & STARTF_USESHOWWINDOW) != 0
? si.wShowWindow
: SW_SHOWNORMAL));
}
--
View this message in context: http://cygwin.1069669.n5.nabble.com/g-linker-problem-with-libcygwin-a-tp37812p107147.html
Sent from the Cygwin list mailing list archive at Nabble.com.
--
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: g++ linker problem with libcygwin.a
2014-03-17 1:57 ` zosrothko
@ 2014-03-17 2:28 ` Marco Atzeri
0 siblings, 0 replies; 14+ messages in thread
From: Marco Atzeri @ 2014-03-17 2:28 UTC (permalink / raw)
To: cygwin
On 16/03/2014 18:03, zosrothko wrote:
> Hi
Dear,
re-opening a thread dead 3 years ago, is NOT a good way to have
any answer here.
If you have any problem, please follow
> Problem reports: http://cygwin.com/problems.html
start a new thread and clarify your need or doubts
Regards
Marco
--
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
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2014-03-16 17:27 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-22 19:19 g++ linker problem with libcygwin.a Philipp Kraus
2011-10-22 20:17 ` René Berber
2011-10-22 20:37 ` Philipp Kraus
2011-10-22 21:44 ` René Berber
2011-10-22 22:49 ` Philipp Kraus
2011-10-22 23:29 ` René Berber
2011-10-22 23:37 ` René Berber
2011-10-23 10:38 ` Philipp Kraus
2011-10-23 10:07 ` Philipp Kraus
2011-10-23 17:53 ` René Berber
2011-10-23 17:58 ` René Berber
2014-03-17 1:57 ` zosrothko
2014-03-17 2:28 ` Marco Atzeri
2011-10-23 18:22 ` Csaba Raduly
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).