title: I can't compile this code of mongoose web server's sample example
body: <p>Short Intro :- (GCC version 4.6.3, OS-Ubuntu 12.04 ,working around mongoose web server program so when I run "make" command to compile and install mongoose , it has done the task fine ).</p>
  
  <p><strong>[Part 1 of question]</strong>
  This question is in reference to this post on stackowerflow.</p>
  
  <p><a href="https://stackoverflow.com/questions/5093330/mongoose-web-server-helloworld-program?rq=1">mongoose web server helloworld program</a></p>
  
  <p>Valenok has answered on this post by giving a link to hello sample program.</p>
  
  <p>basically, I am trying to compile the sample hello program code given on this link :-</p>
  
  <p><a href="http://code.google.com/p/mongoose/source/browse/examples/hello.c" rel="nofollow noreferrer">http://code.google.com/p/mongoose/source/browse/examples/hello.c</a></p>
  
  <p>and put this code in already compiled directory of mongoose.(directory has mongoose.h file)</p>
  
  <p>Following is command line output for my compilation of hello program.</p>
  
  <pre><code>akshay@akshay-Inspiron-N5010:~$ gcc mongoose/hello.c -o mongoose/hello
  /tmp/ccroC5Z6.o: In function `callback':
  hello.c:(.text+0x32): undefined reference to `mg_get_request_info'
  hello.c:(.text+0x96): undefined reference to `mg_printf'
  /tmp/ccroC5Z6.o: In function `main':
  hello.c:(.text+0xee): undefined reference to `mg_start'
  hello.c:(.text+0x103): undefined reference to `mg_stop'
  collect2: ld returned 1 exit status
  akshay@akshay-Inspiron-N5010:~$ 
  </code></pre>
  
  <p><strong>[Part 2 of question]</strong></p>
  
  <p>Now , I find implementations of mg_stop , mg_start,mg_printf and mg_get_request_info in mongoose.c file , so I compile mongoose.c file with -c option as :
    gcc -c -o mongoose.o mongoose.c </p>
  
  <p>I think my question is similar to :-</p>
  
  <p><a href="https://stackoverflow.com/questions/7433984/undefined-reference-to-function-declared-in-h-file-c-language">undefined reference to function declared in *.h file</a></p>
  
  <p>but then when I link libmongoose.so with -L option on gcc I get following errors:-
  (libmongoose.so is present in same directory ,my cwd)</p>
  
  <pre><code>akshay@akshay-Inspiron-N5010:~/mongoose$ gcc -L libmongoose.so -o hello hello.o mongoose.o
  mongoose.o: In function `mg_start_thread':
  mongoose.c:(.text+0x1369): undefined reference to `pthread_create'
  mongoose.o: In function `load_dll':
  mongoose.c:(.text+0xa955): undefined reference to `dlopen'
  mongoose.c:(.text+0xa9b4): undefined reference to `dlsym'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>also , I continue to get above ^^ errors when I compile without using libmongoose.so</p>
  
  <p><strong>[EDIT]</strong> : added -pthread option on gcc, still shows errors :-
  mongoose.o: In function <code>load_dll':
  mongoose.c:(.text+0xa955): undefined reference to</code>dlopen'
  mongoose.c:(.text+0xa9b4): undefined reference to `dlsym'
  collect2: ld returned 1 exit status</p>
  
  <p>For part 1 and part 2 of my question : I want to get rid of these errors and successfully run hello.c program sample successfully.
  Thanks in advance .</p>