Link C and C++ Object File

This is a discussion on Link C and C++ Object File within the C++ Programming forums, part of the General Programming Boards category; Hi all. I was write some library in C++. And now I want to link that library to my C ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    1

    Link C and C++ Object File

    Hi all.
    I was write some library in C++. And now I want to link that library to my C program with gcc. It was error (undefined references). My C program cannnot see function in my library..
    Could you help me ? How do I link my C++ object file to C source program ?. Thank

    Sorry in my English :P
    Memepuppy
    memepuppy@yahoo.com

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    72
    Hi

    declare these functions with extern "C" in your cpp code
    or use extern "C++" in the C code, if the compiler support that.

    damyan

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    63
    is this where ios::sync_with_stdio(); will help?
    from what i understand u #inlude stido.h and #include iostream.h add stdlib.h too for the hell of it, and that function is built into C++ so that it works with C code..

    as far as i know (which isn't much!) that will work

    ah, the databases are friends
    SS3X

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    108
    Assuming you are using the command line, are you handing the LIB file to the linker in the correct order ? The order in which library files are passed is important. The simplest mistake may sometimes be the eureka solution.
    rwalt

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21