ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
well it's perfectly possible... nearly any programming or scripting language can do this, you just need to use it right... did you have any useful specifics???
I want to be able to do it in C++. I don't think it is possible without linking to the kernel source, but I am not sure which header files are necessary or which functions are available.
You don't need the kernel source to write simple C or C++ programs. You need the kernel source only when you compile programs using kernel headers and such things.
Here's a small demo.
If you're doing CPP you need g++ and cpp extensions:
cd /tmp
cat << _EOF_ > hello.cpp
#include <stdio.h>
int main (void)
{
printf( "hello world in CPP!\n" );
}
_EOF_
g++ hello.cpp -o hellocpp
./hellocpp
If you write C programs use .c extensions and gcc.
cd /tmp
cat << _EOF_ > hello.c
#include <stdio.h>
int main (void)
{
printf( "hello world in C!\n" );
}
_EOF_
g++ hello.c -o helloc
./helloc
thanks for the reply, but i am asking how to read and write the directory tree with c++. for instance, i would like to be able to display all of the directories and their contents in the file system.
Originally posted by juanbobo thanks for the reply, but i am asking how to read and write the directory tree with c++. for instance, i would like to be able to display all of the directories and their contents in the file system.
Well there were two questions:
1- is it possible to compile w/o kernel source
2- how to process file trees in cpp
I answered 1 by explaining how to compile a simple cpp prog. It it works for you too it prooves you can write your program on your system.
You'll find answer to question #2 by reading the language reference. If what you need to is not too complex, then you should learn bash scripting or similar languages (python, perl).
thanks alred, i was looking for the C/C++ commands to do so. i searched google for the functions you suggested and found they are available in "dirent.h" in the kernel source.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.