C++ noob - compiler question.

Discussion in 'C++' started by Denis Remezov, Aug 24, 2004.

  1. Noone wrote:
    >
    > I'm not new to programming, but I am fairly new to C++. I've got a bit of a
    > problem with a project that I am working on. My environment is as follows:
    >
    > OS: Mandrake 10
    > IDE: Anjuta
    > Compiler: gnu
    >
    > The project I am working on is a C/C++ combo. I've created a class (in C++)
    > to encapsulate a particular bit of functionality; this class makes calls to
    > some C functions in a separate file (nothing complicated). All of the
    > necessary includes are in place.
    >
    > The problem is this: when I "Compile" my file, it works fine and produces no
    > errors, but when I go to "Build" my file I get errors in the file that I
    > just compiled with no errors. The errors read "undefined reference to
    > function_name_here(param1*, param2)". The errors are produced on each line
    > that makes a call to a function in the C file.
    >


    See the FAQ (particularly item 32):
    http://www.parashift.com/c -faq-lite

    Denis
    Denis Remezov, Aug 24, 2004
    #1
    1. Advertising

  2. Denis Remezov

    Noone Guest

    I'm not new to programming, but I am fairly new to C++. I've got a bit of a
    problem with a project that I am working on. My environment is as follows:

    OS: Mandrake 10
    IDE: Anjuta
    Compiler: gnu

    The project I am working on is a C/C++ combo. I've created a class (in C++)
    to encapsulate a particular bit of functionality; this class makes calls to
    some C functions in a separate file (nothing complicated). All of the
    necessary includes are in place.

    The problem is this: when I "Compile" my file, it works fine and produces no
    errors, but when I go to "Build" my file I get errors in the file that I
    just compiled with no errors. The errors read "undefined reference to
    function_name_here(param1*, param2)". The errors are produced on each line
    that makes a call to a function in the C file.

    I'm a little confused as to what I need to do here. Why does it compile but
    not build?

    Thanks.

    -Sheppe
    Noone, Aug 24, 2004
    #2
    1. Advertising

  3. Noone wrote:
    > [...]
    > I'm a little confused as to what I need to do here. Why does it compile but
    > not build?


    Get a decent book on gnu tools. You probably forget that for linking
    you need to supply all object modules in the same command line.

    BTW, compiler command lines are off-topic here. Please refer to
    newsgroups comp.os.linux.development.* and gnu.g++.help for further
    information.

    V
    Victor Bazarov, Aug 24, 2004
    #3
  4. Denis Remezov

    Mike Wahler Guest

    "Noone" <> wrote in message
    news:SuLWc.208928$gE.115676@pd7tw3no...
    > I'm not new to programming, but I am fairly new to C++. I've got a bit of

    a
    > problem with a project that I am working on. My environment is as follows:
    >
    > OS: Mandrake 10
    > IDE: Anjuta
    > Compiler: gnu
    >
    > The project I am working on is a C/C++ combo. I've created a class (in

    C++)
    > to encapsulate a particular bit of functionality; this class makes calls

    to
    > some C functions in a separate file (nothing complicated). All of the
    > necessary includes are in place.
    >
    > The problem is this: when I "Compile" my file, it works fine and produces

    no
    > errors, but when I go to "Build" my file I get errors in the file that I
    > just compiled with no errors. The errors read "undefined reference to
    > function_name_here(param1*, param2)". The errors are produced on each line
    > that makes a call to a function in the C file.
    >
    > I'm a little confused as to what I need to do here. Why does it compile

    but
    > not build?


    Look up "extern C". If that doesn't help, try creating
    a small example that produces the problem and post it here
    (standard code only, please).

    -Mike
    Mike Wahler, Aug 24, 2004
    #4
  5. Denis Remezov

    Sheppe Guest

    Thanks for the link. :)

    -Sheppe

    "Denis Remezov" <> wrote in message
    news:...
    > Noone wrote:
    > >
    > > I'm not new to programming, but I am fairly new to C++. I've got a bit

    of a
    > > problem with a project that I am working on. My environment is as

    follows:
    > >
    > > OS: Mandrake 10
    > > IDE: Anjuta
    > > Compiler: gnu
    > >
    > > The project I am working on is a C/C++ combo. I've created a class (in

    C++)
    > > to encapsulate a particular bit of functionality; this class makes calls

    to
    > > some C functions in a separate file (nothing complicated). All of the
    > > necessary includes are in place.
    > >
    > > The problem is this: when I "Compile" my file, it works fine and

    produces no
    > > errors, but when I go to "Build" my file I get errors in the file that I
    > > just compiled with no errors. The errors read "undefined reference to
    > > function_name_here(param1*, param2)". The errors are produced on each

    line
    > > that makes a call to a function in the C file.
    > >

    >
    > See the FAQ (particularly item 32):
    > http://www.parashift.com/c -faq-lite
    >
    > Denis
    Sheppe, Aug 24, 2004
    #5
  6. Denis Remezov

    David Harmon Guest

    On Tue, 24 Aug 2004 18:08:50 GMT in comp.lang.c++, "Noone"
    <> wrote,
    >just compiled with no errors. The errors read "undefined reference to
    >function_name_here(param1*, param2)". The errors are produced on each line
    >that makes a call to a function in the C file.


    Are you sure that you declared the function with
    extern "C"
    in the C++ part?

    This issue is covered in Marshall Cline's C++ FAQ. See section
    "[32] How to mix C and C++" It is always good to check the FAQ before
    posting. You can get the FAQ at:
    http://www.parashift.com/c -faq-lite/
    David Harmon, Aug 24, 2004
    #6
  7. Denis Remezov

    Sheppe Guest

    Awesome! That fixed me up. Thanks for the tip. :)

    -Sheppe

    "Mike Wahler" <> wrote in message
    news:bILWc.32348$...
    >
    > "Noone" <> wrote in message
    > news:SuLWc.208928$gE.115676@pd7tw3no...
    > > I'm not new to programming, but I am fairly new to C++. I've got a bit

    of
    > a
    > > problem with a project that I am working on. My environment is as

    follows:
    > >
    > > OS: Mandrake 10
    > > IDE: Anjuta
    > > Compiler: gnu
    > >
    > > The project I am working on is a C/C++ combo. I've created a class (in

    > C++)
    > > to encapsulate a particular bit of functionality; this class makes calls

    > to
    > > some C functions in a separate file (nothing complicated). All of the
    > > necessary includes are in place.
    > >
    > > The problem is this: when I "Compile" my file, it works fine and

    produces
    > no
    > > errors, but when I go to "Build" my file I get errors in the file that I
    > > just compiled with no errors. The errors read "undefined reference to
    > > function_name_here(param1*, param2)". The errors are produced on each

    line
    > > that makes a call to a function in the C file.
    > >
    > > I'm a little confused as to what I need to do here. Why does it compile

    > but
    > > not build?

    >
    > Look up "extern C". If that doesn't help, try creating
    > a small example that produces the problem and post it here
    > (standard code only, please).
    >
    > -Mike
    >
    >
    Sheppe, Aug 24, 2004
    #7
  8. Denis Remezov

    Sheppe Guest

    As I replied to Mr. Wahler, doing this fixed things right up for me. Thanks!
    :)

    -Sheppe

    "David Harmon" <> wrote in message
    news:...
    > On Tue, 24 Aug 2004 18:08:50 GMT in comp.lang.c++, "Noone"
    > <> wrote,
    > >just compiled with no errors. The errors read "undefined reference to
    > >function_name_here(param1*, param2)". The errors are produced on each

    line
    > >that makes a call to a function in the C file.

    >
    > Are you sure that you declared the function with
    > extern "C"
    > in the C++ part?
    >
    > This issue is covered in Marshall Cline's C++ FAQ. See section
    > "[32] How to mix C and C++" It is always good to check the FAQ before
    > posting. You can get the FAQ at:
    > http://www.parashift.com/c -faq-lite/
    >
    Sheppe, Aug 24, 2004
    #8
  9. Denis Remezov

    Default User Guest

    Default User, Aug 24, 2004
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yan
    Replies:
    0
    Views:
    1,132
  2. Jack Wright
    Replies:
    5
    Views:
    623
    Shiv Kumar
    Jan 19, 2004
  3. Ram
    Replies:
    0
    Views:
    2,832
  4. Andrey Batyuck

    Compiler compiler with C++ as output

    Andrey Batyuck, May 11, 2004, in forum: C++
    Replies:
    3
    Views:
    438
    Frederik Hertzum
    May 17, 2004
  5. RickMuller
    Replies:
    4
    Views:
    705
    Alexey Shamrin
    Mar 26, 2005
Loading...

Share This Page