Linking a C++ library to a C program.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • add_aaron_2_x@hotmail.com

    Linking a C++ library to a C program.

    Hi,

    I am writing a C program which interfaces with a C++ library. The C++
    library works fine with C. I was wondering if I need to use a C++
    compiler (g++ in my case) to compile the C program or can I use a C
    compiler (gcc)?

    Thanks.

    p.s. I understand all the extern "C" business. This is purely a do I
    need to use a C++ compiler to compile a C program that uses a C++
    library question.

  • Rolf Magnus

    #2
    Re: Linking a C++ library to a C program.

    add_aaron_2_x@h otmail.com wrote:
    [color=blue]
    > Hi,
    >
    > I am writing a C program which interfaces with a C++ library. The C++
    > library works fine with C. I was wondering if I need to use a C++
    > compiler (g++ in my case) to compile the C program or can I use a C
    > compiler (gcc)?[/color]

    You can use gcc for compilation, but you must link with g++.

    Btw: Your question is off-topic here. A better newsgroup would be
    gnu.g++.help.

    Comment

    Working...