LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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-13-2010, 01:11 PM   #1
bahhti
LQ Newbie
 
Registered: Nov 2009
Posts: 12

Rep: Reputation: 0
kernel compiling undefined reference error


i have written a sytem call which takes two integers a arguments and returns their sum. this worked well. then i wanted to add global varible which will be initialized at boot time. mysystem call file is as follows.
Code:
#include <linux/linkage.h>
#include <linux/kernel.h>
#include <linux/init.h>


int myglobal;

asmlinkage int sys_mycall(int a, int b){
     return a+b+myglobal;
}

void __init mycall_init(void){
     
     myglobal=89;

}
until this it worked fine. then i wanted to add a second system call which will change the value of myglobal at os run time. i followed the same procedure with the firs one. i have put the .c files in the same directory. and modified makefile to - added the line : obj - y :=setmyglobal.o- anyway it gave me some errors, then i thought that i am making mistakes about defining global variables. so i changed the setmyglobal syscall just to declare a new varibale and assign the value passed to it. which is simpler than the first syscall at least for me.
it is as :

Code:
#include <linux/linkage.h>

asmlinkage long sys_setmyglobal(int number)
{
    int temp;
    temp=number;
    return temp;

}
and weirdlly i get the foolowing error.
Code:
init/built-in.o: In function 'start_kernel':
/usr/src/linux/init/main.c:619: undefined reference to 'mycall_init'
arch/i386/kernel/built-in.o: In function 'sys_call_table':
/.rodata+0x500): undefined reference to 'sys_mycall'
make[1]: *** [.tmp_vmlinux1] Error 1
make[2]: Leaving directory '/usr/src/linux-2.6.20.15'
make: *** [debian/stamp-build-kernel] Error 2
init functions worked fine when i hadn't added the second syscall. but then giving errors. i haven't made anycahnges in them.
how can i fix this??
also it can be useful if you can provide me some information abour defining a global variable kernel lvel..
thanks
 
Old 01-14-2010, 02:55 PM   #2
ForzaItalia2006
Member
 
Registered: Dec 2009
Location: Walldorf, Germany
Distribution: (X)Ubuntu, Arch, Gentoo
Posts: 205

Rep: Reputation: 67
Hey,

Quote:
Originally Posted by bahhti View Post
Code:
init/built-in.o: In function 'start_kernel':
/usr/src/linux/init/main.c:619: undefined reference to 'mycall_init'
arch/i386/kernel/built-in.o: In function 'sys_call_table':
/.rodata+0x500): undefined reference to 'sys_mycall'
make[1]: *** [.tmp_vmlinux1] Error 1
make[2]: Leaving directory '/usr/src/linux-2.6.20.15'
make: *** [debian/stamp-build-kernel] Error 2
I looks like you missed the first file (including sys_mycall & mycall_init) during linking. Maybe a copy+paste error?

- Andi -
 
Old 01-15-2010, 08:03 AM   #3
bahhti
LQ Newbie
 
Registered: Nov 2009
Posts: 12

Original Poster
Rep: Reputation: 0
i haven't goet much knowledge, first to say. but i have written my second system call on the source files that i used for the first and after compilation the changes i had made to the source files were still there. but there were a lot of new .o files in this source directory. once i thought that this may be the issue and used make-kpkg clean. but it didin't work either. Maybe you can make more clear what you said. linking???
i have changed the syscall_table.S, unistd.h, syscalls.h files. Is this linking?? Excuse if this is so novice.
 
Old 01-17-2010, 01:26 PM   #4
bahhti
LQ Newbie
 
Registered: Nov 2009
Posts: 12

Original Poster
Rep: Reputation: 0
Could someone please help? This is an assignment due 21st. ant there are a lot of things more i need to do if i could manage just declaring a kernel global.
 
Old 01-18-2010, 12:16 PM   #5
bahhti
LQ Newbie
 
Registered: Nov 2009
Posts: 12

Original Poster
Rep: Reputation: 0
Luckily i found out that my makefile is errorneous.i solved the problem. Could i thank you? (!)
 
0 members found this post helpful.
Old 04-01-2010, 11:00 PM   #6
akz10
LQ Newbie
 
Registered: Apr 2010
Posts: 1
Blog Entries: 1

Rep: Reputation: 0
Hey hello my friend,

I'm having the same problem here.

could you share the way you solved this issue please?

Thanks in advance!
 
  


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
undefined reference to `yywrap' compiling PAM Mahonri Debian 5 12-30-2011 06:00 PM
Error while compiling ecryptfs utils : undefined reference to `PK11_ImportSymKey' nitinarora Linux - Kernel 3 11-24-2009 04:21 AM
Several "undefined reference to" error when compiling a C programm acer_peri Programming 8 12-11-2008 05:45 AM
Undefined reference to WxGtk libraries when compiling Xchm Darwish Linux - Software 0 09-03-2005 11:11 PM
undefined reference to `cfb_fillrect' and more when compiling kernel KR-data Linux - Software 0 09-03-2005 01:56 PM


All times are GMT -5. The time now is 07:02 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