LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [LINUX-KERNEL] C++ in linux kernel
@ 2008-02-08 5:21 rohit h
2008-02-08 5:28 ` KOSAKI Motohiro
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: rohit h @ 2008-02-08 5:21 UTC (permalink / raw)
To: linux-kernel
Hi,
I am a kernel newbie.
I tried to insmod a C++ module containing classes, inheritance.
I am getting 'unresolved symbol' error when I use the 'new' keyword.
What could the problem be?
What kind of runtime support is needed ( arm linux kernel)? Is a
patch available for it?
Thanks,
Rohit
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: C++ in linux kernel
2008-02-08 5:21 [LINUX-KERNEL] C++ in linux kernel rohit h
@ 2008-02-08 5:28 ` KOSAKI Motohiro
2008-02-08 10:17 ` [LINUX-KERNEL] " Bernd Petrovitsch
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: KOSAKI Motohiro @ 2008-02-08 5:28 UTC (permalink / raw)
To: rohit h; +Cc: kosaki.motohiro, linux-kernel
Hi
> I am a kernel newbie.
> I tried to insmod a C++ module containing classes, inheritance.
> I am getting 'unresolved symbol' error when I use the 'new' keyword.
> What could the problem be?
under using gcc, new operator use malloc by default.
but linux doesn't have malloc.
Could you create custom allocater?
> What kind of runtime support is needed ( arm linux kernel)? Is a
> patch available for it?
may be nothing.
- kosaki
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [LINUX-KERNEL] C++ in linux kernel
2008-02-08 5:21 [LINUX-KERNEL] C++ in linux kernel rohit h
2008-02-08 5:28 ` KOSAKI Motohiro
@ 2008-02-08 10:17 ` Bernd Petrovitsch
2008-02-08 13:39 ` Andi Kleen
2008-02-08 15:14 ` [LINUX-KERNEL] " Joonwoo Park
3 siblings, 0 replies; 10+ messages in thread
From: Bernd Petrovitsch @ 2008-02-08 10:17 UTC (permalink / raw)
To: rohit h; +Cc: linux-kernel
On Fre, 2008-02-08 at 10:51 +0530, rohit h wrote:
> Hi,
> I am a kernel newbie.
> I tried to insmod a C++ module containing classes, inheritance.
> I am getting 'unresolved symbol' error when I use the 'new' keyword.
> What could the problem be?
That you used C++ is the problem. Use plain C and the gcc.
> What kind of runtime support is needed ( arm linux kernel)? Is a
> patch available for it?
Google for "linux kernel c++" and read on - this has been discussed
several times on this list.
Bernd
--
Firmix Software GmbH http://www.firmix.at/
mobil: +43 664 4416156 fax: +43 1 7890849-55
Embedded Linux Development and Services
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: C++ in linux kernel
2008-02-08 5:21 [LINUX-KERNEL] C++ in linux kernel rohit h
2008-02-08 5:28 ` KOSAKI Motohiro
2008-02-08 10:17 ` [LINUX-KERNEL] " Bernd Petrovitsch
@ 2008-02-08 13:39 ` Andi Kleen
2008-02-08 15:14 ` [LINUX-KERNEL] " Joonwoo Park
3 siblings, 0 replies; 10+ messages in thread
From: Andi Kleen @ 2008-02-08 13:39 UTC (permalink / raw)
To: rohit h; +Cc: linux-kernel
"rohit h" <hrohit85@gmail.com> writes:
> Hi,
> I am a kernel newbie.
> I tried to insmod a C++ module containing classes, inheritance.
> I am getting 'unresolved symbol' error when I use the 'new' keyword.
> What could the problem be?
If you want to use C++ in the kernel you would need to provide
all the run time library support for it youself. It's possible,
but not easy and encouraged
-Andi
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [LINUX-KERNEL] C++ in linux kernel
2008-02-08 5:21 [LINUX-KERNEL] C++ in linux kernel rohit h
` (2 preceding siblings ...)
2008-02-08 13:39 ` Andi Kleen
@ 2008-02-08 15:14 ` Joonwoo Park
2008-02-08 15:54 ` Jan Engelhardt
3 siblings, 1 reply; 10+ messages in thread
From: Joonwoo Park @ 2008-02-08 15:14 UTC (permalink / raw)
To: rohit h; +Cc: linux-kernel
2008/2/8, rohit h <hrohit85@gmail.com>:
> Hi,
> I am a kernel newbie.
> I tried to insmod a C++ module containing classes, inheritance.
> I am getting 'unresolved symbol' error when I use the 'new' keyword.
> What could the problem be?
>
> What kind of runtime support is needed ( arm linux kernel)? Is a
> patch available for it?
>
> Thanks,
> Rohit
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
Rohit,
Please take a look at click modular router which is using c++ as a
linux kernel module.
http://www.read.cs.ucla.edu/click/
The lib/glue.cc provides custom operator new.
Thanks,
Joonwoo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [LINUX-KERNEL] C++ in linux kernel
2008-02-08 15:14 ` [LINUX-KERNEL] " Joonwoo Park
@ 2008-02-08 15:54 ` Jan Engelhardt
2008-02-09 0:45 ` Joonwoo Park
2008-02-11 11:37 ` rohit h
0 siblings, 2 replies; 10+ messages in thread
From: Jan Engelhardt @ 2008-02-08 15:54 UTC (permalink / raw)
To: Joonwoo Park; +Cc: rohit h, linux-kernel
On Feb 9 2008 00:14, Joonwoo Park wrote:
>2008/2/8, rohit h <hrohit85@gmail.com>:
>> Hi,
>> I am a kernel newbie.
>> I tried to insmod a C++ module containing classes, inheritance.
>> I am getting 'unresolved symbol' error when I use the 'new' keyword.
>> What could the problem be?
>>
>> What kind of runtime support is needed ( arm linux kernel)? Is a
>> patch available for it?
>>
>Please take a look at click modular router which is using c++ as a
>linux kernel module.
>http://www.read.cs.ucla.edu/click/
>The lib/glue.cc provides custom operator new.
Uh, let's not make the world worse :)
Just call malloc from C++, and carefully select what C++ features
you are going to use. The VMware source for example does it right.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [LINUX-KERNEL] C++ in linux kernel
2008-02-08 15:54 ` Jan Engelhardt
@ 2008-02-09 0:45 ` Joonwoo Park
2008-02-11 11:37 ` rohit h
1 sibling, 0 replies; 10+ messages in thread
From: Joonwoo Park @ 2008-02-09 0:45 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: rohit h, linux-kernel
2008/2/9, Jan Engelhardt <jengelh@computergmbh.de>:
>
> On Feb 9 2008 00:14, Joonwoo Park wrote:
> >2008/2/8, rohit h <hrohit85@gmail.com>:
> >> Hi,
> >> I am a kernel newbie.
> >> I tried to insmod a C++ module containing classes, inheritance.
> >> I am getting 'unresolved symbol' error when I use the 'new' keyword.
> >> What could the problem be?
> >>
> >> What kind of runtime support is needed ( arm linux kernel)? Is a
> >> patch available for it?
> >>
> >Please take a look at click modular router which is using c++ as a
> >linux kernel module.
> >http://www.read.cs.ucla.edu/click/
> >The lib/glue.cc provides custom operator new.
>
> Uh, let's not make the world worse :)
> Just call malloc from C++, and carefully select what C++ features
> you are going to use. The VMware source for example does it right.
>
Yep, also I think that if kmalloc is possible it would better than the
operator new.
Rohit,
Compiling the kernel module with g++ is not a simple work, you may
need big patch for kernel itself.
The c++ has more internal keywords than c.
e.g) new, delete, and ::
The new and delete should be re-spelled with another names.
The '::' is used in inline assembly however in c++ it means global namespace.
In conclusion, I don't recommand c++ for linux kernel without very
special goal like the click project :)
Joonwoo
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [LINUX-KERNEL] C++ in linux kernel
2008-02-08 15:54 ` Jan Engelhardt
2008-02-09 0:45 ` Joonwoo Park
@ 2008-02-11 11:37 ` rohit h
2008-02-11 11:49 ` vignesh babu bm
2008-02-11 12:20 ` Bernd Petrovitsch
1 sibling, 2 replies; 10+ messages in thread
From: rohit h @ 2008-02-11 11:37 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: Joonwoo Park, linux-kernel
On Feb 8, 2008 9:24 PM, Jan Engelhardt <jengelh@computergmbh.de> wrote:
>
> On Feb 9 2008 00:14, Joonwoo Park wrote:
> >2008/2/8, rohit h <hrohit85@gmail.com>:
> >> Hi,
> >> I am a kernel newbie.
> >> I tried to insmod a C++ module containing classes, inheritance.
> >> I am getting 'unresolved symbol' error when I use the 'new' keyword.
> >> What could the problem be?
> >>
> >> What kind of runtime support is needed ( arm linux kernel)? Is a
> >> patch available for it?
> >>
> >Please take a look at click modular router which is using c++ as a
> >linux kernel module.
> >http://www.read.cs.ucla.edu/click/
> >The lib/glue.cc provides custom operator new.
>
> Uh, let's not make the world worse :)
> Just call malloc from C++, and carefully select what C++ features
> you are going to use. The VMware source for example does it right.
>
>From the links given, I dig that following C++ features need runtime support:
a. Pure virtual functions
b. Global objects : Needs compiler dependent changes
c. new & delete : Can use kmalloc / kfree instead
d. Run time type info
e. Exceptions
I guess features d & e need considerable effort.
Apart from these, am I free to use other C++ features?
Where could I see the VMWare sources?
> Compiling the kernel module with g++ is not a simple work, you may
> need big patch for kernel itself.
I don't want to compile entire kernel.
I only want to compile my module with g++ and insmod it.
Any hint on how to write the Makefile.
Thanks in advance,
Rohit
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [LINUX-KERNEL] C++ in linux kernel
2008-02-11 11:37 ` rohit h
@ 2008-02-11 11:49 ` vignesh babu bm
2008-02-11 12:20 ` Bernd Petrovitsch
1 sibling, 0 replies; 10+ messages in thread
From: vignesh babu bm @ 2008-02-11 11:49 UTC (permalink / raw)
To: rohit h; +Cc: Jan Engelhardt, Joonwoo Park, linux-kernel
http://www.vmware.com/download/server/open_source.html
On Feb 11, 2008 5:07 PM, rohit h <hrohit85@gmail.com> wrote:
>
> On Feb 8, 2008 9:24 PM, Jan Engelhardt <jengelh@computergmbh.de> wrote:
> >
> > On Feb 9 2008 00:14, Joonwoo Park wrote:
> > >2008/2/8, rohit h <hrohit85@gmail.com>:
> > >> Hi,
> > >> I am a kernel newbie.
> > >> I tried to insmod a C++ module containing classes, inheritance.
> > >> I am getting 'unresolved symbol' error when I use the 'new' keyword.
> > >> What could the problem be?
> > >>
> > >> What kind of runtime support is needed ( arm linux kernel)? Is a
> > >> patch available for it?
> > >>
> > >Please take a look at click modular router which is using c++ as a
> > >linux kernel module.
> > >http://www.read.cs.ucla.edu/click/
> > >The lib/glue.cc provides custom operator new.
> >
> > Uh, let's not make the world worse :)
> > Just call malloc from C++, and carefully select what C++ features
> > you are going to use. The VMware source for example does it right.
> >
>
> From the links given, I dig that following C++ features need runtime support:
> a. Pure virtual functions
> b. Global objects : Needs compiler dependent changes
> c. new & delete : Can use kmalloc / kfree instead
> d. Run time type info
> e. Exceptions
> I guess features d & e need considerable effort.
> Apart from these, am I free to use other C++ features?
> Where could I see the VMWare sources?
>
>
>
> > Compiling the kernel module with g++ is not a simple work, you may
> > need big patch for kernel itself.
>
> I don't want to compile entire kernel.
> I only want to compile my module with g++ and insmod it.
> Any hint on how to write the Makefile.
>
> Thanks in advance,
> Rohit
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
--
----------------------------------------------
"Why is it that every time I'm with you, makes me believe in magic?"
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [LINUX-KERNEL] C++ in linux kernel
2008-02-11 11:37 ` rohit h
2008-02-11 11:49 ` vignesh babu bm
@ 2008-02-11 12:20 ` Bernd Petrovitsch
1 sibling, 0 replies; 10+ messages in thread
From: Bernd Petrovitsch @ 2008-02-11 12:20 UTC (permalink / raw)
To: rohit h; +Cc: Jan Engelhardt, Joonwoo Park, linux-kernel
On Mon, 2008-02-11 at 17:07 +0530, rohit h wrote:
> On Feb 8, 2008 9:24 PM, Jan Engelhardt <jengelh@computergmbh.de> wrote:
[...]
> > Compiling the kernel module with g++ is not a simple work, you may
> > need big patch for kernel itself.
>
> I don't want to compile entire kernel.
> I only want to compile my module with g++ and insmod it.
> Any hint on how to write the Makefile.
You really should learn on the differences at run-time between between
- pure C in a hosted environment (read: you have a full libc),
- pure C in a standalone environment (read: e.g. the Linux kernel), and
- C++ in both variants.
Bernd
--
Firmix Software GmbH http://www.firmix.at/
mobil: +43 664 4416156 fax: +43 1 7890849-55
Embedded Linux Development and Services
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2008-02-11 12:21 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-08 5:21 [LINUX-KERNEL] C++ in linux kernel rohit h
2008-02-08 5:28 ` KOSAKI Motohiro
2008-02-08 10:17 ` [LINUX-KERNEL] " Bernd Petrovitsch
2008-02-08 13:39 ` Andi Kleen
2008-02-08 15:14 ` [LINUX-KERNEL] " Joonwoo Park
2008-02-08 15:54 ` Jan Engelhardt
2008-02-09 0:45 ` Joonwoo Park
2008-02-11 11:37 ` rohit h
2008-02-11 11:49 ` vignesh babu bm
2008-02-11 12:20 ` Bernd Petrovitsch
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 NNTP newsgroup(s).