I am trying to create a new thread by following this tutorial http://www.cplusplus.com/reference/thread/thread/
And following are the relevant code I wrote
Game.cpp:
Game :: Game (bool isDebug, bool startNew) {
// ...
std :: thread gameThread(Game :: tick);
}
void Game :: tick() {
std :: this_thread :: sleep_for(std :: chrono :: seconds (1));
funds += getIncomeRate();
}
Game.hpp:
#ifndef Game_hpp
#define Game_hpp
#include <thread>
using namespace std;
class Game{
public:
// ...
Game (bool, bool);
void tick();
};
#endif /* Game_hpp */
The error I get during compiling says
17:37:19 **** Incremental Build of configuration Debug for project Store Management Game ****
Info: Internal Builder is used for build
g++ -std=c++11 -O0 -g3 -Wall -c -fmessage-length=0 -o Game.o "..\\Game.cpp"
In file included from C:/Program Files/Haskell Platform/8.0.1/mingw/include/c++/5.2.0/thread:39:0,
from ..\Game.hpp:16,
from ..\Game.cpp:9:
C:/Program Files/Haskell Platform/8.0.1/mingw/include/c++/5.2.0/functional: In instantiation of 'struct std::_Bind_check_arity<void (Game::*)()>':
C:/Program Files/Haskell Platform/8.0.1/mingw/include/c++/5.2.0/functional:1538:12: required from 'struct std::_Bind_simple_helper<void (Game::*)()>'
C:/Program Files/Haskell Platform/8.0.1/mingw/include/c++/5.2.0/functional:1552:5: required by substitution of 'template<class _Callable, class ... _Args> typename std::_Bind_simple_helper<_Func, _BoundArgs>::__type std::__bind_simple(_Callable&&, _Args&& ...) [with _Callable = void (Game::*)(); _Args = {}]'
C:/Program Files/Haskell Platform/8.0.1/mingw/include/c++/5.2.0/thread:142:59: required from 'std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void (Game::*)(); _Args = {}]'
..\Game.cpp:33:46: required from here
C:/Program Files/Haskell Platform/8.0.1/mingw/include/c++/5.2.0/functional:1426:7: error: static assertion failed: Wrong number of arguments for pointer-to-member
static_assert(_Varargs::value
^
C:/Program Files/Haskell Platform/8.0.1/mingw/include/c++/5.2.0/functional: In instantiation of 'struct std::_Bind_simple<std::_Mem_fn<void (Game::*)()>()>':
C:/Program Files/Haskell Platform/8.0.1/mingw/include/c++/5.2.0/thread:142:59: required from 'std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void (Game::*)(); _Args = {}]'
..\Game.cpp:33:46: required from here
C:/Program Files/Haskell Platform/8.0.1/mingw/include/c++/5.2.0/functional:1505:61: error: no type named 'type' in 'class std::result_of<std::_Mem_fn<void (Game::*)()>()>'
typedef typename result_of<_Callable(_Args...)>::type result_type;
^
C:/Program Files/Haskell Platform/8.0.1/mingw/include/c++/5.2.0/functional:1526:9: error: no type
named 'type' in 'class std::result_of<std::_Mem_fn<void (Game::*)()>()>'
_M_invoke(_Index_tuple<_Indices...>)
^
17:37:20 Build Finished (took 583ms)
I am not very familiar with C++ and templates in general, and I really do not understand what is wrong with my code. Apologize in advance if this would be a trivial question.
You want:
std::thread gameThread(&Game::tick, this);
// ^^^ ^^^^
Since the method you are wrapping into a thread is not static (and not a free function) you need to give the thread constructor a reference to the class instance.
Related
Recently, I moved over to Linux from Windows and was trying to follow a Udemy course, originally taught using Visual Studio on Windows.
I need to use two header files glfw3.h and glew.h in the course.
I can import glfw3.h and use it just fine, but the glew.h function is showing some errors.
I used the code sudo apt-get install libglew-dev to get the library files. But still error pops up.
CODE :
#include <GLFW/glfw3.h>
#include <GL/glew.h>
int main(void)
{}
ERROR MESSAGE :
In file included from Lesson01.cpp:2:0:
/usr/include/GL/glew.h:85:2: error: #error gl.h included before glew.h
#error gl.h included before glew.h
^~~~~
In file included from Lesson01.cpp:2:0:
/usr/include/GL/glew.h:16088:93: error: conflicting declaration
‘typedef void (* PFNGLFRAGMENTLIGHTMODELFVSGIXPROC)(GLenum, GLfloat*)’
LAPIENTRY * PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, GLfloat*
params);
^
In file included from /usr/include/GL/gl.h:2055:0,
from /usr/include/GLFW/glfw3.h:171,
from Lesson01.cpp:1:
/usr/include/GL/glext.h:12070:25: note: previous declaration as
‘typedef void (* PFNGLFRAGMENTLIGHTMODELFVSGIXPROC)(GLenum, const
GLfloat*)’typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC)
(GLenum pname, const GLfloat *params);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from Lesson01.cpp:2:0:
/usr/include/GL/glew.h:16090:91: error: conflicting declaration
‘typedef void (* PFNGLFRAGMENTLIGHTMODELIVSGIXPROC)(GLenum, GLint*)’
(GLAPIENTRY * PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, GLint*
params);
^
In file included from /usr/include/GL/gl.h:2055:0,
from /usr/include/GLFW/glfw3.h:171,
from Lesson01.cpp:1:
/usr/include/GL/glext.h:12072:25: note: previous declaration as
‘typedef void (* PFNGLFRAGMENTLIGHTMODELIVSGIXPROC)(GLenum, const
GLint*)’ typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC)
(GLenum pname, const GLint *params);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As suggested by you compiler, order of included files matters:
error: #error gl.h included before glew.h
Simply invert the two first lines:
#include <GL/glew.h>
#include <GLFW/glfw3.h>
int main(void)
{
return 0;
}
By some reason MSVC DO NOT compile boost serialization example with the following code:
class MyName
{
public:
MyName(std::string _name, std::string _family_name)
:name{ _name }, family_name{ _family_name }
{ }
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{ ar & name; ar & family_name; } std::string name; std::string family_name;
};
int main()
{
// create and open a character archive for output
std::stringstream ofs;
// save data to archive
{
MyName my_name("MyName", "FamilyName");
boost::archive::text_oarchive oa(ofs);
// write class instance to archive
oa << my_name;
// archive and stream closed when destructors are called
}
// save data to archive
{
MyName my_name("afsf", "dgsass");
boost::archive::text_iarchive oa(ofs);
// write class instance to archive
oa >> my_name;
// archive and stream closed when destructors are called
}
return 0;
}
I get the follwing error:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: __thiscall boost::archive::archive_exception::archive_exception(enum boost::archive::archive_exception::exception_code,char const *,char const *)" (??0archive_exception#archive#boost##QAE#W4exception_code#012#PBD1#Z) referenced in function "protected: void __thiscall boost::archive::basic_text_iprimitive<class std::basic_istream<char,struct std::char_traits<char> > >::load<unsigned int>(unsigned int &)" (??$load#I#?$basic_text_iprimitive#V?$basic_istream#DU?$char_traits#D#std###std###archive#boost##IAEXAAI#Z) cpp11_cpp14_cpp17 D:\Projects_Programing\__Testing\cpp11_cpp14_cpp17\cpp11_cpp14_cpp17\cpp11_cpp14_cpp17.obj 1
But when I compiled it in release mode.
I have read that it could happen due to MSVC STRICT mode, but I have tried and it does not work neither.
Have anybody got such error ?
I have figured out the reason of this error.
It happens when I tried to compile with flag /Za (means zero extension from MSVC for C++).
When I removed this flag my code compiles succesfully.
#lakeweb Thank you for your help and support !!
Unfortunately I do not understand why some extensions from MSVC does allow to compile Boost, but without extentions it does not compile. It is very strange !!
Maybe it is either the bug on Boost side or on MSVC side.
Any assumption ?
I try to compile
https://github.com/personalrobotics/OpenChisel/tree/master/open_chisel
to use it for rendering on a google tango device
I've tried to compile it for Android 4.4, ndk r10e and NDK_TOOLCHAIN_VERSION=4.9 (gcc 4.9) with the following flags:
LOCAL_CFLAGS = -std=c++11 -frtti -fexceptions -fopenmp -w
LOCAL_LDLIBS = -llog -lGLESv2 -L$(SYSROOT)/usr/lib
Including the latest Eigen Version 3.2.8
I tried it also with NDK_TOOLCHAIN_VERSION=4.8 and older Eigen Versions.
But I always get for the ChunkManager.cpp file the following linker errors:
Eigen/Eigen/Core
(Unknown) In file included
Eigen/Eigen/src/Core/util/Memory.h: In instantiation of 'void Eigen::aligned_allocator::construct(Eigen::aligned_allocator::pointer, const T&) [with T = std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2u>; Eigen::aligned_allocator::pointer = std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2u>*]':
This is just an information but maybe it tells someone something
android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/alloc_traits.h
Information:(253, 4) :_Require::__construct_helper<_Tp, Args>::type> std::allocator_traits<_Alloc>::_S_construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2u>; _Args = {const Eigen::aligned_allocator}; _Alloc = Eigen::aligned_allocator, (__gnu_cxx::_Lock_policy)2u> >; std::_Require::__construct_helper<_Tp, _Args>::type> = void]'
android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/alloc_traits.h:399:57: required from 'static decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) std::allocator_traits<_Alloc>::construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2u>; _Args = {const Eigen::aligned_allocator}; _Alloc = Eigen::aligned_allocator, (__gnu_cxx::_Lock_policy)2u> >; decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) = ]'
android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/shared_ptr_base.h:620:37: required from 'std::__shared_count<_Lp>::__shared_count(std::_Sp_make_shared_tag, _Tp*, const _Alloc&, _Args&& ...) [with _Tp = chisel::Mesh; _Alloc = Eigen::aligned_allocator; _Args = {}; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]'
android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/shared_ptr_base.h:1090:35: required from 'std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = Eigen::aligned_allocator; _Args = {}; _Tp = chisel::Mesh; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]'
android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/shared_ptr.h:316:64: required from 'std::shared_ptr<_Tp>::shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = Eigen::aligned_allocator; _Args = {}; _Tp = chisel::Mesh]'
android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/shared_ptr.h:588:39: required from 'std::shared_ptr<_Tp1> std::allocate_shared(const _Alloc&, _Args&& ...) [with _Tp = chisel::Mesh; _Alloc = Eigen::aligned_allocator; _Args = {}]'
OpenChisel/open_chisel/src/ChunkManager.cpp:105:79: required from here
Eigen/Eigen/src/Core/util/Memory.h:733:9: error: use of deleted function 'std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2u>::_Sp_counted_ptr_inplace(const std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2u>&)'
android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/shared_ptr.h
(Unknown) In file included
_Sp_counted_base(_Sp_counted_base const&) = delete;
^
class _Sp_counted_ptr_inplace final : public _Sp_counted_base<_Lp>
^
android-ndk-r10e/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/shared_ptr_base.h
Information:(494, 11) 'std::_Sp_counted_ptr_inplace, (_gnu_cxx::_Lock_policy)2u>::_Sp_counted_ptr_inplace(const std::_Sp_counted_ptr_inplace, (_gnu_cxx::_Lock_policy)2u>&)' is implicitly deleted because the default definition would be ill-formed:
Error:(203, 7) error: 'std::_Sp_counted_base<_Lp>::_Sp_counted_base(const std::_Sp_counted_base<_Lp>&) [with _gnu_cxx::_Lock_policy _Lp = (_gnu_cxx::_Lock_policy)2u]' is private
Error:(494, 11) error: within this context
Error:(494, 11) error: use of deleted function 'std::_Sp_counted_base<_Lp>::_Sp_counted_base(const std::_Sp_counted_base<_Lp>&) [with _gnu_cxx::_Lock_policy _Lp = (_gnu_cxx::_Lock_policy)2u]'
Information:(203, 7) declared here
make: * [app/src/main/obj/local/armeabi-v7a/objs/rgb_point_cloud_builder/////_/third-party/OpenChisel/open_chisel/src/ChunkManager.o] Error 1
I'm completely lost. Any suggestions are appreciated!
It seems that combination of using Eigen and shared_pointer c++11 causes the errors.
Luckily there is a patched version of chisel which uses boost shared pointer instead.
I am trying to make a threaded grabber for my OpenCV application. I am unable to figure out why this code doesn't compile. It gives me an error that I believe means that the function call is wrong. However, it is the exact same way how I start a thread using std::thread usually! I want to use std::thread to accomplish it because it will offer more platform-independent compatibility, so please don't tell me to use a platform-specific library. I also want this to be STL-based, so no Boost or DLib. In my main.cpp, I have a working thread application, the code below:
#include <iostream>
#include <fstream>
#include <string>
#include <thread>
#include <mutex>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#define read_failure_threshold 512
long grabbers_active = 0;
namespace dev
{
class grabber
{
private:
bool enabled = false;
std::mutex lock;
int capture_mode;
int capture_id;
unsigned long read_failures = 0;
std::string stream;
std::string grabber_name;
cv::Mat image;
public:
void grabber_t()
{
.......[unimportant code]........
}
grabber(std::string name, int captureMode, int captureId, std::string location)
{
.......[unimportant code]........
}
void start()
{
if(!enabled)
{
std::thread grabber_thread(grabber_t);
grabber_thread.detach();
}
enabled = true;
grabbers_active++;
}
cv::Mat getImage()
{
.......[unimportant code]........
}
};
}
[ERRORS:]
In file included from /media/storage/programming/yash101/repos/Other/STL+OpenCV/threaded_grabber_template/main.cpp:1:0:
/media/storage/programming/yash101/repos/Other/STL+OpenCV/threaded_grabber_template/template.hpp: In member function ‘void dev::grabber::start()’:
/media/storage/programming/yash101/repos/Other/STL+OpenCV/threaded_grabber_template/template.hpp:119:52: error: no matching function for call to ‘std::thread::thread(<unresolved overloaded function type>)’
std::thread grabber_thread(grabber_t);
^
/media/storage/programming/yash101/repos/Other/STL+OpenCV/threaded_grabber_template/template.hpp:119:52: note: candidates are:
In file included from /media/storage/programming/yash101/repos/Other/STL+OpenCV/threaded_grabber_template/template.hpp:4:0,
from /media/storage/programming/yash101/repos/Other/STL+OpenCV/threaded_grabber_template/main.cpp:1:
/usr/include/c++/4.8/thread:133:7: note: std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void (dev::grabber::*)(); _Args = {}]
thread(_Callable&& __f, _Args&&... __args)
^
/usr/include/c++/4.8/thread:133:7: note: no known conversion for argument 1 from ‘<unresolved overloaded function type>’ to ‘void (dev::grabber::*&&)()’
/usr/include/c++/4.8/thread:128:5: note: std::thread::thread(std::thread&&)
thread(thread&& __t) noexcept
^
/usr/include/c++/4.8/thread:128:5: note: no known conversion for argument 1 from ‘<unresolved overloaded function type>’ to ‘std::thread&&’
/usr/include/c++/4.8/thread:122:5: note: std::thread::thread()
thread() noexcept = default;
^
/usr/include/c++/4.8/thread:122:5: note: candidate expects 0 arguments, 1 provided
make[2]: *** [CMakeFiles/build.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/build.dir/all] Error 2
make: *** [all] Error 2
The error log is also at the end of the code. The only errors I am worried about are the threading ones. The other ones are simple fixes, but require me to have the threading working.
I am in Ubuntu, using g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2. I have C++0x enabled in my CMakeLists.txt. Everything works perfectly in there
My main objective is to figure out why I am getting this error. I have been googling and trying different tricks for many hours, but nothing is working!
Thanks in advanced for your help :)
Change that :
std::thread grabber_thread(grabber_t);
Into that :
std::thread grabber_thread(&grabber::grabber_t, this);
grabber_t is a reference to non-static member function, you need to pass its address, but &grabber_t can't work as you must explicitly qualify name of member function when taking its address, thus resulting in &grabber::grabber_t.
presently i am working on a research project in which we are trying to run a wireless netwok protocal namely aodvuu developed by uppasala university. The protocal was developed in linux kernel version 2.4 x and now we are trying to run it on kernel version 3.8. The following is the corresponding kernel code which is facing problem (kaodv-netlink.c).
#include <linux/module.h>
#include <net/sock.h>
#include <linux/netlink.h>
#include <linux/skbuff.h>
#define NETLINK_USER 31
struct sock *nl_sk = NULL;
static void hello_nl_recv_msg(struct sk_buff *skb) {
struct nlmsghdr *nlh;
int pid;
struct sk_buff *skb_out;
int msg_size;
char *msg="Hello from kernel";
int res;
printk(KERN_INFO "Entering: %s\n", __FUNCTION__);
msg_size=strlen(msg);
nlh=(struct nlmsghdr*)skb->data;
printk(KERN_INFO "Netlink received msg payload:%s\n",(char*)nlmsg_data(nlh));
pid = nlh->nlmsg_pid; /*pid of sending process */
skb_out = nlmsg_new(msg_size,0);
if(!skb_out)
{
printk(KERN_ERR "Failed to allocate new skb\n");
return;
}
nlh=nlmsg_put(skb_out,0,0,NLMSG_DONE,msg_size,0);
NETLINK_CB(skb_out).dst_group = 0; /* not in mcast group */
strncpy(nlmsg_data(nlh),msg,msg_size);
res=nlmsg_unicast(nl_sk,skb_out,pid);
if(res<0)
printk(KERN_INFO "Error while sending bak to user\n");
}
static int __init hello_init(void) {
printk("Entering: %s\n",__FUNCTION__);
/* This is for 3.6 kernels and above.
struct netlink_kernel_cfg cfg = {
.input = hello_nl_recv_msg,
};
nl_sk = netlink_kernel_create(&init_net, NETLINK_USER, &cfg);*/
nl_sk = netlink_kernel_create(&init_net, NETLINK_USER, 0, hello_nl_recv_msg,NULL,THIS_MODULE);
if(!nl_sk)
{
printk(KERN_ALERT "Error creating socket.\n");
return -10;
}
return 0;
}
static void __exit hello_exit(void) {
printk(KERN_INFO "exiting hello module\n");
netlink_kernel_release(nl_sk);
}
module_init(hello_init); module_exit(hello_exit);
MODULE_LICENSE("GPL");
Error i am getting is
timer_queue.o aodv_socket.o aodv_hello.o aodv_neighbor.o aodv_timeout.o routing_table.o seek_list.o aodv_rreq.o aodv_rrep.o aodv_rerr.o nl.o locality.o
make -C /home/lp3/aodvuu096/lnx KERNEL_DIR=/lib/modules/3.8.0-31-generic/build KCC=gcc XDEFS=-DDEBUG
make[1]: Entering directory `/home/lp3/aodvuu096/lnx'
make -C /lib/modules/3.8.0-31-generic/build M=/home/lp3/aodvuu096/lnx modules
make[2]: Entering directory `/usr/src/linux-headers-3.8.0-31-generic'
CC [M] /home/lp3/aodvuu096/lnx/kaodv-mod.o
CC [M] /home/lp3/aodvuu096/lnx/kaodv-debug.o
CC [M] /home/lp3/aodvuu096/lnx/kaodv-netlink.o
/home/lp3/aodvuu096/lnx/kaodv-netlink.c: In function ‘kaodv_netlink_init’:
/home/lp3/aodvuu096/lnx/kaodv-netlink.c:372:21: warning: passing argument 3 of ‘netlink_kernel_create’ from incompatible pointer type [enabled by default]
include/linux/netlink.h:48:1: note: expected ‘struct netlink_kernel_cfg *’ but argument is of type ‘void (*)(struct sk_buff *)’
/home/lp3/aodvuu096/lnx/kaodv-netlink.c:372:21: error: too many arguments to function ‘netlink_kernel_create’
include/linux/netlink.h:48:1: note: declared here
/home/lp3/aodvuu096/lnx/kaodv-netlink.c:374:13: error: invalid storage class for function ‘kaodv_netlink_rcv_sk’
/home/lp3/aodvuu096/lnx/kaodv-netlink.c: In function ‘kaodv_netlink_rcv_sk’:
/home/lp3/aodvuu096/lnx/kaodv-netlink.c:378:14: error: ‘recv_cmd’ undeclared (first use in this function)
/home/lp3/aodvuu096/lnx/kaodv-netlink.c:378:14: note: each undeclared identifier is reported only once for each function it appears in
/home/lp3/aodvuu096/lnx/kaodv-netlink.c:382:1: error: incompatible type for argument 3 of ‘netlink_kernel_create’
include/linux/netlink.h:48:1: note: expected ‘struct netlink_kernel_cfg *’ but argument is of type ‘struct netlink_kernel_cfg’
/home/lp3/aodvuu096/lnx/kaodv-netlink.c:386:3: warning: ‘return’ with a value, in function returning void [enabled by default]
/home/lp3/aodvuu096/lnx/kaodv-netlink.c:389:1: warning: ‘return’ with a value, in function returning void [enabled by default]
/home/lp3/aodvuu096/lnx/kaodv-netlink.c: In function ‘kaodv_netlink_init’:
/home/lp3/aodvuu096/lnx/kaodv-netlink.c:374:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
make[3]: *** [/home/lp3/aodvuu096/lnx/kaodv-netlink.o] Error 1
make[2]: *** [_module_/home/lp3/aodvuu096/lnx] Error 2
make[2]: Leaving directory `/usr/src/linux-headers-3.8.0-31-generic'
make[1]: *** [kaodv.ko] Error 2
make[1]: Leaving directory `/home/lp3/aodvuu096/lnx'
make: *** [kaodv] Error 2
lp3#lp3-Latitude-E5420:~/aodvuu096$
Comment out this line to fix this error.
nl_sk = netlink_kernel_create(&init_net, NETLINK_USER, 0, hello_nl_recv_msg,NULL,THIS_MODULE);