public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* linker error libcygwin
@ 2011-11-10 20:39 Kraus Philipp
  2011-11-10 21:04 ` Marco Atzeri
  2011-11-10 21:12 ` Greg Chicares
  0 siblings, 2 replies; 9+ messages in thread
From: Kraus Philipp @ 2011-11-10 20:39 UTC (permalink / raw)
  To: cygwin

Hello,

I try to build a program with g++ under Cygwin. I added this libraries to the linker:
-lcygboost_system
-lcygboost_thread
-lcygboost_iostreams
-lcygboost_regex
-lcygboost_program_options
-lboost_exception
-lcygboost_filesystem
-llapack
-lcblas
-lf77blas
-latlas
-lgfortran
-lhdf5_cpp
-lhdf5

The linker create the error:

/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../libcygwin.a(libcmain.o):(.text+0xa9):
 undefined reference to `_WinMain@16'
collect2: ld returned 1 exit status

How can I find out, why / where the problem is? Can the order of my -l flags create the 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] 9+ messages in thread

* Re: linker error libcygwin
  2011-11-10 20:39 linker error libcygwin Kraus Philipp
@ 2011-11-10 21:04 ` Marco Atzeri
  2011-11-10 21:20   ` Philipp Kraus
  2011-11-10 21:12 ` Greg Chicares
  1 sibling, 1 reply; 9+ messages in thread
From: Marco Atzeri @ 2011-11-10 21:04 UTC (permalink / raw)
  To: cygwin

On 11/10/2011 9:39 PM, Kraus Philipp wrote:
> Hello,
>
> I try to build a program with g++ under Cygwin. I added this libraries to the linker:
> -lcygboost_system
> -lcygboost_thread
> -lcygboost_iostreams
> -lcygboost_regex
> -lcygboost_program_options
> -lboost_exception
> -lcygboost_filesystem
> -llapack
> -lcblas
> -lf77blas
> -latlas
> -lgfortran
> -lhdf5_cpp
> -lhdf5
>
> The linker create the error:
>
> /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../libcygwin.a(libcmain.o):(.text+0xa9):
>   undefined reference to `_WinMain@16'
> collect2: ld returned 1 exit status

http://cygwin.com/faq-nochunks.html#faq.programming.winmain

>
> How can I find out, why / where the problem is? Can the order of my -l flags create the problem?

always on windows

>
> Thanks
>
> Phil

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] 9+ messages in thread

* Re: linker error libcygwin
  2011-11-10 20:39 linker error libcygwin Kraus Philipp
  2011-11-10 21:04 ` Marco Atzeri
@ 2011-11-10 21:12 ` Greg Chicares
  2011-11-10 21:25   ` Philipp Kraus
  1 sibling, 1 reply; 9+ messages in thread
From: Greg Chicares @ 2011-11-10 21:12 UTC (permalink / raw)
  To: cygwin

On 2011-11-10 20:39Z, Kraus Philipp wrote:
> 
> I try to build a program with g++ under Cygwin. I added this libraries to the linker:
> -lcygboost_system

Shouldn't that be '-lboost_system'? Run 'info ld' and search for
'--dll-search-prefix': 'cyg-' is a typical default prefix that
the '-l' option should recognize without your specifying it.

> /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../libcygwin.a(libcmain.o):(.text+0xa9):
>  undefined reference to `_WinMain@16'
> collect2: ld returned 1 exit status

Does this thread
  http://cygwin.com/ml/cygwin/2011-10/threads.html#00440
contain the answer? If this is a console application, does it have
an implementation of main()? Or if it's a windows GUI application,
is WinMain() implemented in some object file passed to the linker?

--
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] 9+ messages in thread

* Re: linker error libcygwin
  2011-11-10 21:04 ` Marco Atzeri
@ 2011-11-10 21:20   ` Philipp Kraus
  0 siblings, 0 replies; 9+ messages in thread
From: Philipp Kraus @ 2011-11-10 21:20 UTC (permalink / raw)
  To: cygwin

On 2011-11-10 22:04:33 +0100, Marco Atzeri said:

> On 11/10/2011 9:39 PM, Kraus Philipp wrote:
>> Hello,
>> 
>> I try to build a program with g++ under Cygwin. I added this libraries 
>> to the linker:
>> -lcygboost_system
>> -lcygboost_thread
>> -lcygboost_iostreams
>> -lcygboost_regex
>> -lcygboost_program_options
>> -lboost_exception
>> -lcygboost_filesystem
>> -llapack
>> -lcblas
>> -lf77blas
>> -latlas
>> -lgfortran
>> -lhdf5_cpp
>> -lhdf5
>> 
>> The linker create the error:
>> 
>> /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../libcygwin.a(libcmain.o):(.text+0xa9): 
>> 
>> undefined reference to `_WinMain@16'
>> collect2: ld returned 1 exit status
> 
> http://cygwin.com/faq-nochunks.html#faq.programming.winmain
> 
>> 
>> How can I find out, why / where the problem is? Can the order of my -l 
>> flags create the problem?
> 
> always on windows

yes, but I can add the -lm flag, but it does not solve the problem

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] 9+ messages in thread

* Re: linker error libcygwin
  2011-11-10 21:12 ` Greg Chicares
@ 2011-11-10 21:25   ` Philipp Kraus
  2011-11-11  0:58     ` Greg Chicares
  0 siblings, 1 reply; 9+ messages in thread
From: Philipp Kraus @ 2011-11-10 21:25 UTC (permalink / raw)
  To: cygwin

On 2011-11-10 22:11:48 +0100, Greg Chicares said:

> On 2011-11-10 20:39Z, Kraus Philipp wrote:
>> 
>> I try to build a program with g++ under Cygwin. I added this libraries 
>> to the linker:
>> -lcygboost_system
> 
> Shouldn't that be '-lboost_system'? Run 'info ld' and search for
> '--dll-search-prefix': 'cyg-' is a typical default prefix that
> the '-l' option should recognize without your specifying it.

okay, thanks for this hint

> 
>> /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../libcygwin.a(libcmain.o):(.text+0xa9): 
>> 
>> undefined reference to `_WinMain@16'
>> collect2: ld returned 1 exit status
> 
> Does this thread
>   http://cygwin.com/ml/cygwin/2011-10/threads.html#00440
> contain the answer?

no, sorry.

>  If this is a console application, does it have
> an implementation of main()?

yes the signature of the main is in this example:
int main(int argc, char* argv[])

> Or if it's a windows GUI application,
> is WinMain() implemented in some object file passed to the linker?

No i don't use the WinMain() and I call the compiler / linker with -mconsole
but on 3 examples the error with the WinMain is shown, on other examples
everything works fine, so I don't understand it

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] 9+ messages in thread

* Re: linker error libcygwin
  2011-11-10 21:25   ` Philipp Kraus
@ 2011-11-11  0:58     ` Greg Chicares
  2011-11-11 11:48       ` Philipp Kraus
  2011-11-13 11:44       ` Philipp Kraus
  0 siblings, 2 replies; 9+ messages in thread
From: Greg Chicares @ 2011-11-11  0:58 UTC (permalink / raw)
  To: cygwin

On 2011-11-10 21:22Z, Philipp Kraus wrote:
> On 2011-11-10 22:11:48 +0100, Greg Chicares said:
> 
>> On 2011-11-10 20:39Z, Kraus Philipp wrote:
>>> 
>>> undefined reference to `_WinMain@16'
>>> collect2: ld returned 1 exit status
>> 
>> Does this thread
>>   http://cygwin.com/ml/cygwin/2011-10/threads.html#00440
>> contain the answer?
> 
> no, sorry.
> 
>>  If this is a console application, does it have
>> an implementation of main()?
> 
> yes the signature of the main is in this example:
> int main(int argc, char* argv[])

Please show the full linker command, and indicate the name of
the object file that contains main().

--
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] 9+ messages in thread

* Re: linker error libcygwin
  2011-11-11  0:58     ` Greg Chicares
@ 2011-11-11 11:48       ` Philipp Kraus
  2011-11-13 11:44       ` Philipp Kraus
  1 sibling, 0 replies; 9+ messages in thread
From: Philipp Kraus @ 2011-11-11 11:48 UTC (permalink / raw)
  To: cygwin

On 2011-11-11 01:57:48 +0100, Greg Chicares said:

> On 2011-11-10 21:22Z, Philipp Kraus wrote:
>> On 2011-11-10 22:11:48 +0100, Greg Chicares said:
>> 
>>> On 2011-11-10 20:39Z, Kraus Philipp wrote:
>>>> 
>>>> undefined reference to `_WinMain@16'
>>>> collect2: ld returned 1 exit status
>>> 
>>> Does this thread
>>> http://cygwin.com/ml/cygwin/2011-10/threads.html#00440
>>> contain the answer?
>> 
>> no, sorry.
>> 
>>> If this is a console application, does it have
>>> an implementation of main()?
>> 
>> yes the signature of the main is in this example:
>> int main(int argc, char* argv[])
> 
> Please show the full linker command, and indicate the name of
> the object file that contains main().

There is only one cpp file within the main, so there is also one object file



--
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] 9+ messages in thread

* Re: linker error libcygwin
  2011-11-11  0:58     ` Greg Chicares
  2011-11-11 11:48       ` Philipp Kraus
@ 2011-11-13 11:44       ` Philipp Kraus
  2011-11-13 12:59         ` Philipp Kraus
  1 sibling, 1 reply; 9+ messages in thread
From: Philipp Kraus @ 2011-11-13 11:44 UTC (permalink / raw)
  To: cygwin

On 2011-11-11 01:57:48 +0100, Greg Chicares said:

> On 2011-11-10 21:22Z, Philipp Kraus wrote:
>> On 2011-11-10 22:11:48 +0100, Greg Chicares said:
>> 
>>> On 2011-11-10 20:39Z, Kraus Philipp wrote:
>>>> 
>>>> undefined reference to `_WinMain@16'
>>>> collect2: ld returned 1 exit status
>>> 
>>> Does this thread
>>> http://cygwin.com/ml/cygwin/2011-10/threads.html#00440
>>> contain the answer?
>> 
>> no, sorry.
>> 
>>> If this is a console application, does it have
>>> an implementation of main()?
>> 
>> yes the signature of the main is in this example:
>> int main(int argc, char* argv[])
> 
> Please show the full linker command, and indicate the name of
> the object file that contains main().

The full linker command shows (I split the flags for a better reading):

g++ -o build/target.exe -mconsole -enable-stdcall-fixup -mthread 
examples/other/target.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/cygdrive/c/opt/scons/bin
-L/cygdrive/c/opt/library/atlas/3.9.51/lib
-L/cygdrive/c/opt/library/boost/1.47.0/bin
-L/cygdrive/c/opt/library/boost/1.47.0/lib
-L/cygdrive/c/opt/library/cln/1.3.2/lib
-L/cygdrive/c/opt/library/ginac/1.6.1/lib
-L/cygdrive/c/opt/library/hdf/5-1.8.7/lib
-L/cygdrive/c/opt/library/xml2/2.7.8/bin
-L/cygdrive/c/opt/library/xml2/2.7.8/lib
-L/cygdrive/c/opt/library/jsoncpp/0.5.0/lib

-lboost_system
-lboost_thread
-lboost_iostreams
-lboost_regex
-lboost_program_options
-lboost_exception
-lboost_filesystem
-llapack
-lcblas
-lf77blas
-latlas
-lgfortran
-lhdf5_cpp
-lhdf5

I have tested the same call with another example (only the *.cpp / *.o 
file changes) and it works. The difference is the cpp code, but
a compiler call run's without an error. I don't understand why 
different sources with the same linker command creates different 
results.
The linking process should be deterministic, so the compiled object 
code creates the same linker calls.

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] 9+ messages in thread

* Re: linker error libcygwin
  2011-11-13 11:44       ` Philipp Kraus
@ 2011-11-13 12:59         ` Philipp Kraus
  0 siblings, 0 replies; 9+ messages in thread
From: Philipp Kraus @ 2011-11-13 12:59 UTC (permalink / raw)
  To: cygwin

On 2011-11-13 12:43:37 +0100, Philipp Kraus said:

> On 2011-11-11 01:57:48 +0100, Greg Chicares said:
> 
>> On 2011-11-10 21:22Z, Philipp Kraus wrote:
>>> On 2011-11-10 22:11:48 +0100, Greg Chicares said:
>>> 
>>>> On 2011-11-10 20:39Z, Kraus Philipp wrote:
>>>>> 
>>>>> undefined reference to `_WinMain@16'
>>>>> collect2: ld returned 1 exit status
>>>> 
>>>> Does this thread
>>>> http://cygwin.com/ml/cygwin/2011-10/threads.html#00440
>>>> contain the answer?
>>> 
>>> no, sorry.
>>> 
>>>> If this is a console application, does it have
>>>> an implementation of main()?
>>> 
>>> yes the signature of the main is in this example:
>>> int main(int argc, char* argv[])
>> 
>> Please show the full linker command, and indicate the name of
>> the object file that contains main().
> 
> The full linker command shows (I split the flags for a better reading):
> 
> g++ -o build/target.exe -mconsole -enable-stdcall-fixup -mthread 
> examples/other/target.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/cygdrive/c/opt/scons/bin
> -L/cygdrive/c/opt/library/atlas/3.9.51/lib
> -L/cygdrive/c/opt/library/boost/1.47.0/bin
> -L/cygdrive/c/opt/library/boost/1.47.0/lib
> -L/cygdrive/c/opt/library/cln/1.3.2/lib
> -L/cygdrive/c/opt/library/ginac/1.6.1/lib
> -L/cygdrive/c/opt/library/hdf/5-1.8.7/lib
> -L/cygdrive/c/opt/library/xml2/2.7.8/bin
> -L/cygdrive/c/opt/library/xml2/2.7.8/lib
> -L/cygdrive/c/opt/library/jsoncpp/0.5.0/lib
> 
> -lboost_system
> -lboost_thread
> -lboost_iostreams
> -lboost_regex
> -lboost_program_options
> -lboost_exception
> -lboost_filesystem
> -llapack
> -lcblas
> -lf77blas
> -latlas
> -lgfortran
> -lhdf5_cpp
> -lhdf5
> 
> I have tested the same call with another example (only the *.cpp / *.o 
> file changes) and it works. The difference is the cpp code, but
> a compiler call run's without an error. I don't understand why 
> different sources with the same linker command creates different 
> results.
> The linking process should be deterministic, so the compiled object 
> code creates the same linker calls.

I have checked my sources, but some examples must have this preprocessor part:
#if defined(_WIN32) || defined(__CYGWIN__)
#include <windows.h>
#endif

and some examples must not have this part (same linker / compiler call)



--
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] 9+ messages in thread

end of thread, other threads:[~2011-11-13 12:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-10 20:39 linker error libcygwin Kraus Philipp
2011-11-10 21:04 ` Marco Atzeri
2011-11-10 21:20   ` Philipp Kraus
2011-11-10 21:12 ` Greg Chicares
2011-11-10 21:25   ` Philipp Kraus
2011-11-11  0:58     ` Greg Chicares
2011-11-11 11:48       ` Philipp Kraus
2011-11-13 11:44       ` Philipp Kraus
2011-11-13 12:59         ` Philipp Kraus

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).