This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: what is the difference of these two compile methods ?
- From: Christopher Faylor <cgf-no-personal-reply-please at cygwin dot com>
- To: cygwin at cygwin dot com
- Date: Wed, 2 Aug 2006 21:29:54 -0400
- Subject: Re: what is the difference of these two compile methods ?
- References: <bc95423d0608021734q67b5bc52x3651774154a50043@mail.gmail.com>
- Reply-to: cygwin at cygwin dot com
On Thu, Aug 03, 2006 at 08:34:46AM +0800, ???? wrote:
>source file is a very simple cpp file like "hello world" whose name is
>main.cpp
>when i compile it with:
>g++ -o test.exe main.cpp
>it works fine
>
>but when i compile it with:
> g++ -c -o main.o main.cpp
> ld -o test.exe main.o
>it will report "undefined reference" error at step 2, it looks like ld
>can not locate any library, if i replace ld with g++, it works fine.
That is absolutely correct. ld isn't meant to be used by itself unless
you really know what you're doing and you don't really know what you're
doing.
So, use g++ for linking.
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/