Thread: “undefined reference to ” error when compiling C project with GCC Compiler

  1. #1
    Registered User
    Join Date
    Jan 2016
    Posts
    1

    “undefined reference to ” error when compiling C project with GCC Compiler

    I'm hoping someone can assist. I'm new to C, and I've been experimenting with some code from the R project. The project I've created consists of a main.c file and several header files. I've attached my project. The main.c file looks as follows:

    Code:
    #include "Rinternals.h"
    int main(int argc, char** argv) {     
    }
    SEXP Cdqrls(SEXP x, SEXP y, SEXP tol, SEXP chk)
    {   
    SEXP ans;
    SEXP qr, coefficients, residuals, effects, pivot, qraux;
    int n, ny = 0, p, rank, nprotect = 4, pivoted = 0;
    double rtol = asReal(tol), *work;   
    }
    The Rinternals.h file is this file from the R Project source: https://svn.r-project.org/R/trunk/sr...e/Rinternals.h


    I've included this header file in the same folder as the main.c file, and I've also included in this folder all the header files that are in the Rinternals.h #includes statements. When I attempt to compile this, I get the following error:

    Code:
    main.c:34: undefined reference to `Rf_asReal'
    The error relates to this line specifically:

    Code:
    double rtol = asReal(tol), *work;
    I've tried a number of things, and can't seem to find a way to get this code to compile. I'm currently working in Netbeans and compiling with GNU GCC Compiler (get the same error when using Code::blocks). Any help with this would be greatly appreciated.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Did you forget to link with the appropriate library, or the appropriate object file(s)?
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. undefined reference error when compiling
    By csharp100 in forum C++ Programming
    Replies: 6
    Last Post: 05-07-2012, 04:20 PM
  2. undefined reference error, please help me
    By leo2008 in forum C Programming
    Replies: 8
    Last Post: 03-27-2012, 03:50 AM
  3. compiler keeps giving undefined reference errors
    By ecsx00 in forum C Programming
    Replies: 1
    Last Post: 11-24-2011, 03:12 AM
  4. undefined reference error
    By gcctest in forum C Programming
    Replies: 3
    Last Post: 12-19-2008, 08:17 AM
  5. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM