LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-10-2009, 05:04 PM   #16
sulacco
Member
 
Registered: Apr 2006
Posts: 46

Original Poster
Rep: Reputation: 15

Quote:
Originally Posted by map250r View Post
If I google linux/types.h:198: error: expected, I get several results.
http://lkml.indiana.edu/hypermail/li...10.1/1854.html

What I searched for is part of the first line with an error.

Assuming the link I provided helps, the problem is that you compiled in the same directory that the source is in. You're allowed to, but I think it's frowned upon. What I do is to use O=../build2.6.28 as one of the args for make each time. (do mkdir ../build2.6.28 first though!)
I feel you are very close at it. Can you explain more. How do I know if
i compiled in the same directory that sources are?
I feel something wrong with symlink too. That is the major part of
errors in compilation of my driver.
Though you link didn't help, cause `make mrproper` dont work.
there are no such option in makefile mrproper i think

Last edited by sulacco; 01-10-2009 at 05:07 PM.
 
Old 01-11-2009, 08:48 AM   #17
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 227Reputation: 227Reputation: 227
Ok - this is very odd. I have an even simpler Makefile which will require some command line arguments to make. You should change directory to the directory of hello.c and create a file called, for example, hello.sh. Then make it executable with
Code:
chmod +x hello.sh
Then run it with
Code:
./hello.sh
Be aware that if you already have a subdirectory temp/ off the hello.c directory then it will be erased. This will create a new directory temp/ off the hello.c directory, create a Makefile and run it. It should produce a module hello.ko which should be listed at the end of the make run. Here is the hello.sh to create :

Code:
#!/bin/bash
rm -rf temp/
mkdir temp
cp hello.c temp/
cd temp
cat > Makefile << EOF
obj-m := hello.o

EOF
make -C /lib/modules/$(uname -r)/build  M=$(pwd) modules
ls -al hello*
exit 0
 
Old 01-11-2009, 02:16 PM   #18
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 115Reputation: 115
Quote:
Originally Posted by sulacco View Post
2bgeddy

if I run only:
Code:
make
here what I've got for answer:
Code:
make: Nothing to be done for `default'.
Delete all .o files in the directory, then run make again. The makefile you have been given is correct and is what you want to use for a kernel driver. There is no problem compiling into the same directory. The message basically was just telling you that make thinks your executable is up to date.
 
Old 01-11-2009, 04:53 PM   #19
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 227Reputation: 227Reputation: 227
Quote:
Delete all .o files in the directory, then run make again.
I have already told the OP to do this - here was my message :
Quote:
Just to be sure all is well try this :

Quote:
rm hello.{mod.*,o,ko}
make
I hope he/she hasn't been ignoring my advice as this would explain the confusion.
 
Old 01-12-2009, 09:24 PM   #20
sulacco
Member
 
Registered: Apr 2006
Posts: 46

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by bgeddy View Post
I have already told the OP to do this - here was my message :


I hope he/she hasn't been ignoring my advice as this would explain the confusion.
tnx. I'm not ignoring just there so many details while trying to compile in linux world...
 
Old 01-12-2009, 09:35 PM   #21
sulacco
Member
 
Registered: Apr 2006
Posts: 46

Original Poster
Rep: Reputation: 15
there are no files .o, mod.*, *.ko and still when I try to send command
`make` there is answer:
make: Nothing to be done for `default'.
 
Old 01-12-2009, 11:01 PM   #22
sulacco
Member
 
Registered: Apr 2006
Posts: 46

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by bgeddy View Post
Ok - this is very odd. I have an even simpler Makefile which will require some command line arguments to make. You should change directory to the directory of hello.c and create a file called, for example, hello.sh. Then make it executable with
Code:
chmod +x hello.sh
Then run it with
Code:
./hello.sh
Be aware that if you already have a subdirectory temp/ off the hello.c directory then it will be erased. This will create a new directory temp/ off the hello.c directory, create a Makefile and run it. It should produce a module hello.ko which should be listed at the end of the make run. Here is the hello.sh to create :

Code:
#!/bin/bash
rm -rf temp/
mkdir temp
cp hello.c temp/
cd temp
cat > Makefile << EOF
obj-m := hello.o

EOF
make -C /lib/modules/$(uname -r)/build  M=$(pwd) modules
ls -al hello*
exit 0
UNBELIEVABLE!!! This is your last advice is REAL GOLDEN!!.
Thank you very much it worked now! It compiled and created bunch of
files with .ko, .o and so on!!!
 
Old 01-13-2009, 10:11 PM   #23
sulacco
Member
 
Registered: Apr 2006
Posts: 46

Original Poster
Rep: Reputation: 15
2bgeddy
can you explain pleas what it does?

Code:
#!/bin/bash
rm -rf temp/
mkdir temp
cp hello.c temp/
cd temp
cat > Makefile << EOF
obj-m := hello.o

EOF
make -C /lib/modules/$(uname -r)/build  M=$(pwd) modules
ls -al hello*
exit 0
next commands escape my understanding:
Code:
cat > Makefile << EOF
obj-m := hello.o
EOF
make -C /lib/modules/$(uname -r)/build  M=$(pwd) modules
Those four lines, I just don't get it.
 
Old 01-14-2009, 07:54 AM   #24
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 227Reputation: 227Reputation: 227
Quote:
cat > Makefile << EOF
obj-m := hello.o
EOF
This is what's known as a "here document". It creates a file called "Makefile" with one line "obj-m: hello.o"
Quote:
make -C /lib/modules/$(uname -r)/build M=$(pwd) modules
This runs make with the target "modules" for the module in the current directory "$(pwd)" and the kernel source at "/lib/modules/$(uname -r)/build". Make changes directory to this before running the make.
 
Old 01-15-2009, 02:06 PM   #25
sulacco
Member
 
Registered: Apr 2006
Posts: 46

Original Poster
Rep: Reputation: 15
I'm very sorry, but driver again refused to compile!!!

Code:
 CC [M]  /home/ushka/temp/hello.o
In file included from /usr/src/linux-2.6.28/arch/x86/include/asm/processor.h:19,
                 from include/linux/prefetch.h:15,
                 from include/linux/list.h:7,
                 from include/linux/module.h:10,
                 from /home/ushka/temp/hello.c:4:
/usr/src/linux-2.6.28/arch/x86/include/asm/page.h: In function ‘native_pte_flags’:
/usr/src/linux-2.6.28/arch/x86/include/asm/page.h:152: error: ‘phys_addr_t’ undeclared (first use in this function)
/usr/src/linux-2.6.28/arch/x86/include/asm/page.h:152: error: (Each undeclared identifier is reported only once
/usr/src/linux-2.6.28/arch/x86/include/asm/page.h:152: error: for each function it appears in.)
make[1]: *** [/home/ushka/temp/hello.o] Error 1
make: *** [_module_/home/ushka/temp] Error 2
make: Leaving directory `/usr/src/linux-2.6.28'
-rw-r--r-- 1 root root 916 2009-01-15 17:57 hello.c
 
Old 01-15-2009, 03:44 PM   #26
sulacco
Member
 
Registered: Apr 2006
Posts: 46

Original Poster
Rep: Reputation: 15
Interesting thing when I have tried to compile kernel: linux-2.6.28 with make utility
the same error in page.h was up. Funny thing linux!!!
 
Old 01-16-2009, 09:48 AM   #27
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 227Reputation: 227Reputation: 227
Quote:
Interesting thing when I have tried to compile kernel: linux-2.6.28 with make utility
the same error in page.h was up. Funny thing linux!!!
Do you mean you haven't been able to successfully compile a kernel ? If this is the case then you really should have mentioned it earlier.

Installing and building a kernel source tree is the FIRST THING you should do when wanting to compile you own modules ! If the build process for the kernel fails then you will have problems with your modules.

Quote:
While trying to compile a this simple piece of software I have went through many difficulties such as compiling and installing kernel and
learned much things but still have errors. I learned that some headers needed to be installed, but there so many Linux clones and everyone of them use different schedules to do this.
I took this to mean that you had successfully built a kernel from source. It would seem not.

You must concentrate on successfully building a kernel first eliminating any build errors before continuing. I just wish you would have made this clear at the outset.

Actually this is getting highly confusing as :-
Quote:
UNBELIEVABLE!!! This is your last advice is REAL GOLDEN!!.
Thank you very much it worked now! It compiled and created bunch of
files with .ko, .o and so on!!!
reads like the device driver build worked. Are you saying it worked and now doesn't or it never worked at all ? If the process resulted in a .ko (module) file then it worked. This latest post implies that it didn't.

Before continuing I suggest you study The Linux Kernel in a Nutshell and Linx Device Drivers third edition and in future please give out relevant information at the outset - it would save a lot of time all round.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to keep re-installing NVIDIA Dirver ? bogzab Slackware 9 06-12-2007 09:44 AM
problem with suse 9.3 nvidia dirver dred Suse/Novell 11 07-12-2005 08:19 AM
intel 537ep dirver on feodra core 3 Gonto Linux - Hardware 6 05-18-2005 07:04 PM
Trouble Compiling a simple Hellow World on Solaris 9 with GCC 3.4.2 jitendra64 Solaris / OpenSolaris 4 10-11-2004 02:57 PM
video dirver for quake3 (demo) Smerk Linux - Games 10 12-19-2003 01:56 PM


All times are GMT -5. The time now is 10:24 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration