Menu

first steps: undefined reference to dlclose

Help
olli0601
2006-06-26
2013-04-22
  • olli0601

    olli0601 - 2006-06-26

    Hello, I have right now installed cppunit onto Debian kernel 2.6.8-2-386 with gcc 3.3.5.

    Everything seemed to be fine, and I tried a small hello world program, from http://pantras.free.fr/articles/helloworld.html

    Unfortunately I get for
    g++ hello_world_ccpunit.cpp -L/usr/local/include/cppunit -l cppunit

    the error msg
    hello_world_ccpunit.cpp:47:2: warning: no newline at end of file
    /usr/local/lib/libcppunit.so: undefined reference to `dlclose'
    /usr/local/lib/libcppunit.so: undefined reference to `dlopen'
    /usr/local/lib/libcppunit.so: undefined reference to `dlsym'
    collect2: ld returned 1 exit status

    Could you please help me? Cheers.

     
    • John Dubchak

      John Dubchak - 2006-06-26

      You likely are forgetting to link to the dynamic loadable modules.

      Adding -ldl to the end of your compile command should fix it.

       
    • olli0601

      olli0601 - 2006-06-27

      Thank you, now g++ compiles.However when I run the program, I get

      ./hello: error while loading shared libraries: libcppunit-1.10.so.2: cannot open shared object file: No such file or directory

      my LD_LIBDRARY_PATH includes the directory of libcppunit-1.10.so.2. When I include -shared to my g++ command (see start of thread), I get a segmenation fault.

      Could you please help?

       
      • John Dubchak

        John Dubchak - 2006-06-27

        Can you post your compile/link command?  It's possibly the way you're linking that is causing it to fail.

         
    • olli0601

      olli0601 - 2006-07-03

      Hi, the command

      g++ -o hello_world hello_world_ccpunit.cpp -L/usr/local/include/cppunit -l cppunit -ldl

      produces

      ./hello_world: error while loading shared libraries: libcppunit-1.10.so.2: cannot open shared object file: No such file or di
      rectory

      and the command

      g++ -o hello_world hello_world_ccpunit.cpp -L/usr/local/include/cppunit
      l cppunit -shared -ldl

      then results in a segmentation fault.

      /usr/local/lib contains
      libcppunit-1.10.so.2
      libcppunit-1.10.so.2.0.0
      libcppunit.a
      libcppunit.la
      libcppunit.so

      while /usr/local/include$ ]ls
      boost-1_33_1  cppunit  sbml

      and echo $LD_LIBRARY_PATH returns
      /usr/local/lib/python2.3/site-packages:/usr/local/lib

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.