Linking a C++ library to a C program.

A

add_aaron_2_x

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.
 
R

Rolf Magnus

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)?

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top