undefined reference to "omp"

Hello,
I amend my TCP/IP source code,
in /usr/src/sys/netinet/tcp_output.c
add
Code:
#include<sys/omp.h>
and add below code in function of
int tcp_output(struct tcpcb *tp)d

Code:
int tid;
omp_set_num_threads(4);
#pragma omp parallel
{
   tid=omp_get_thread_num();
   printf("%d\n",tid)
}

of course,I add -fopenmp in /usr/src/sys/conf/kern.pre.mk
but get the error as below:

Code:
linking kernel.debug
tcp_output.o(.text+0x477):In function 'tcp_output':
/usr/src/sys/netinet/tcp_output.c:162:undefined reference to 'omp_set_num_threads'
tcp_output.o(.text+0x4a2):/usr/src/sys/netinet/tcp_output.c:148:undefined reference to 'GOMP_parallel_start'
tcp_output.o(.text+0x4a2):/usr/src/sys/netinet/tcp_output.c:148:undefined reference to 'GOMP_parallel_end'
/usr/src/sys/netinet/tcp_output.c:165:undefined reference to 'omp_get_num_threads'

What's wrong to my kernel?

Thank you for replies.

Cheers,

-- Wang
 
I'm no kernel hacker but I'm quite sure you can't just go around linking external libraries to it and expect it to work.
 
SirDice said:
I'm no kernel hacker but I'm quite sure you can't just go around linking external libraries to it and expect it to work.

If not add -fopenmp in the linking,it can't identify #pragma omp parallel
so,whether or not it run short of some compilations?
 
Tu22M3 said:
If not add -fopenmp in the linking,it can't identify #pragma omp parallel
Yes, which also means you can't use it. Kernel programming is an entirely different beast compared to userland programming.
 
Remove the code you added. What exactly are you trying to accomplish?
 
I want to add parallel OpenMP for TCP/IP code.Initially, I think if add the support of lib,it may be succesful.
 
Thanks!
I just want to kown how to use OpenMP in TCP/IP code. Although it have enhance the performance of the FreeBSD network stack,there may be another way to improve network stack. And OpenMP is much more simply.
Now, I have found these files and directory have important effect to compiler.
Code:
/usr/src/sys/conf/kern.pre.mk,
/usr/src/sys/conf/kern.post.mk,
/usr/src/sys/conf/kern.mk,
/usr/src/sys/conf/kmod.mk,
/usr/src/contrib/gcclibs/libgomp/

The compiler can't build tcp_output.o
 
It's throwing errors like undefined reference to omp_set_num_threads in MINGW gcc 4.6.2 version. When I am trying the execution with gcc -fopenmp title.c. It's giving undefined reference to printf, scanf and many things indireclty stdio.h not in a working condition. Please help me. What I should do? I changed the PATH variable for windows to C:\MinGW\lib\gcc\4.6.2\.
 
Back
Top