title: Could not Load Shared Library Symbols, GDB
body: <p>I am calling a shared library (<code>QSP.so</code>) from MATLAB. The library is written in C and using a mex gateway, the data are passed the shared library. It seems that there is some bug in my C code as I have following problems:</p>
  
  <p>1) In MATLAB, when I call the gateway function, MATLAB freezes most of the time.
  2) When I use GDB to debug the code, as described <a href="http://www.mathworks.com/help/matlab/matlab_external/debugging-c-c-language-mex-files.html" rel="nofollow">Here</a>, and set a breakpoint at the entry function (<code>QSP</code>), GDB does not stop at the breakpoint and creates following error:</p>
  
  <pre><code>warning: Could not load shared library symbols for ./QSP.so.
  Do you need "set solib-search-path" or "set sysroot"?
  
  Program received signal SIGSEGV, Segmentation fault.
  [Switching to Thread 0xb289db40 (LWP 4234)]
  0xb72a7a0e in ?? () from /lib/i386-linux-gnu/libc.so.6
  </code></pre>
  
  <p>I am pretty sure there is nothing wrong with the gateway as when I do not call the shared library, everything is fine. Without any debugger, on the other hand, it would be too hard to find the problem. So, I would like to know how I can get GDB stop at the breakpoint.</p>
  
  <p>Also, following is my Makefile:</p>
  
  <pre><code>CC = gcc
  CFLAGS = -c -fpic -Wall -Werror -O3 -g
  
  all: QSP.o ExtraRoutines.o
      $(CC) -shared -o QSP.so -g $^
  
  QSP.o: QSP.c ExtraRoutines.c QSP.h 
      $(CC) $(CFLAGS) $^
  
  ExtraRoutines.o: ExtraRoutines.c QSP.h
      $(CC) $(CFLAGS) $^
  
  Moving:
      mv -f QSP.so ../
  
  Clean:
      rm *.o
  </code></pre>
  
  <p>As can be seen, I use <code>-g</code> flag for both <code>.o</code> and <code>.so</code> files</p>
  
  <p>Any help is appreciated and thanks in advance.</p>