Menu

Linking against the library under C++

Help
Anonymous
2000-02-25
2012-09-22
  • Anonymous

    Anonymous - 2000-02-25

    Hi,

    I'm having some problems trying to get an independent C++ program to link against the
    libsphinx2 library.  Even in the simplest case (ie. a single call to a fbs_init inside a constructor)
    is doesn't seem to want to find the functions in the library.  I'm using RedHat 6.1 with
    egcs-2.91.66.

    Does anyone have a simple example in C++ that links that I could try/look at?

    Brent

     
    • Anonymous

      Anonymous - 2000-06-22

      You want to link a C++ object code with a C code. To do so, just dectare the C function as extern "C" funcName.
      For example to call the fbs_init(..) from your C++ code add the following to the top of your code
      extern "C" fbs_init(...). However, the best way to do such link to work, is to create a dummy function in C and let the function call the library. Do not forget to declare it as extern "C" dummyFuntion( ) as well.
      I hope it helps,

      Hossein

       

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.