Re: [CMake] Fwd: Fwd: Is it necessary to link a executable file?

2009-02-04 Thread Nick Ogden
That's because a library doesn't need a main() function. It's just a set of 
functions that may be called by applications and is never executed by itself, 
however an executable needs a point of entry and therefore needs a main() 
function.

On Wednesday 04 February 2009 10:51:31 ankit jain wrote:
> 2009/2/4 Eric Noulard 
>
> > 2009/2/4 ankit jain :
> > > The CMakeLists iam using contains:
> > >
> > > PROJECT(hello)
> > >
> > > ADD_EXECUTABLE(hello h1.C)
> > >
> > > Error iam getting is:
> > >
> > > Linking CXX executable hello
> > > /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/../../../crt1.o(.text+0x18):
> > > In
> > >
> > > function `_start':
> > > : undefined reference to `main'
> >
> > This is not a CMake error this is a C++ error
> > your source file is lacking the main() function thus
> > the compiler cannot produce an executable.
> >
> > I bet that if you search for " undefined reference to `main' " on the Web
> > you'll find the answer to such question.
> >
> > --
> > Erk
>
> But if i replace ADD_EXECUTABLE by ADD_LIBRARY there is no error and a
> library get successfully built.
>
>
> AJ

-- 
Nick Ogden

Email: n...@nickogden.net  PGP: 2598FFE4
Web:   www.nickogden.net


signature.asc
Description: This is a digitally signed message part.
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Fwd: Fwd: Is it necessary to link a executable file?

2009-02-04 Thread ankit jain
2009/2/4 Eric Noulard 

> 2009/2/4 ankit jain :
> >
> > The CMakeLists iam using contains:
> >
> > PROJECT(hello)
> >
> > ADD_EXECUTABLE(hello h1.C)
> >
> > Error iam getting is:
> >
> > Linking CXX executable hello
> > /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/../../../crt1.o(.text+0x18): In
> > function `_start':
> > : undefined reference to `main'
>
> This is not a CMake error this is a C++ error
> your source file is lacking the main() function thus
> the compiler cannot produce an executable.
>
> I bet that if you search for " undefined reference to `main' " on the Web
> you'll find the answer to such question.
>
> --
> Erk
>

But if i replace ADD_EXECUTABLE by ADD_LIBRARY there is no error and a
library get successfully built.


AJ
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Re: [CMake] Fwd: Fwd: Is it necessary to link a executable file?

2009-02-04 Thread Eric Noulard
2009/2/4 ankit jain :
>
> The CMakeLists iam using contains:
>
> PROJECT(hello)
>
> ADD_EXECUTABLE(hello h1.C)
>
> Error iam getting is:
>
> Linking CXX executable hello
> /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/../../../crt1.o(.text+0x18): In
> function `_start':
> : undefined reference to `main'

This is not a CMake error this is a C++ error
your source file is lacking the main() function thus
the compiler cannot produce an executable.

I bet that if you search for " undefined reference to `main' " on the Web
you'll find the answer to such question.

-- 
Erk
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake