[bigint] undefined reference to stringToBigInteger() using bigint-2009.05.03.tar.bz2

dave weirich <mindgasm1976 at yahoo.com>
Tue Jan 5 04:28:34 PST 2010


I was wondering if anyone was having similar problem with trying to use the stringToBigInteger() function.
 
I have attached a sample code below, and as an attachment. 
 
I have included "BigIntegerLibrary.hh"; however, the compiler is inable to reconcile the stringToBigInteger() function.
 
In efforts to troubleshoot this, I have viewed BigIntegerLibrary.hh and found no reference to this function.  I did however, find the function located in BigIntegerUtils.hh.  I have specifically tried to include this header, but still yield similar results (undefined reference to stringToBigInteger()).
 
I have also tried to instantiate objects of type BigIntegerLibrary as well as BigIntegerUtils and have attempted to derive the stringToBigInteger() function as a class member, but still attain the "undefined reference..." error.  I have also attempted to use :: scope resolution direclty from both libraries (same result).
 
I believe my code matches closely to the "sample.cpp" you provide with the zipped download.
 
Please let me know what I am doing wrong here.
 
-Dave W.
 
 
////////CODE TO FOLLOW/////////
 
#include<iostream>
#include<string>
#include<vector>
#include "BigIntegerLibrary.hh"
int main()
{
    bool is_prime = true;
    std::vector<BigInteger> prime_list;
    std::vector<BigInteger> prime_factors;
    std::vector<BigInteger>::iterator iter;
    std::string number = "600851475143";
    BigInteger bigNumber = stringToBigInteger(number);
    //Generate a list of primes
    for(BigInteger i=2; i<bigNumber/2; i++)
    {
        is_prime = true;
        for(BigInteger j=2; j<i; j++)
        {
            if((i%j)==0)
            {
                is_prime = false;
                break;
            }
        }
        if(is_prime)
        {
            prime_list.push_back(i);
        }
    }
    //Get primes that work, from the bottom up
    for(iter = prime_list.begin(); iter != prime_list.end(); iter++)
    {
        if((bigNumber % *iter)==0)
        {
            bigNumber /= *iter;
            prime_factors.push_back(*iter);
            iter--;
        }
    }
    std::cout << "\nThe prime factors of 600,851,475,143 are: ";
    for(iter = prime_list.begin(); iter != prime_list.end(); iter++)
    {
        std::cout << *iter << std::endl;
    }
    std::cout << "\nThe largest prime factor of 600,851,475,143 is: " << prime_factors[prime_factors.size()-1];
    return 0;
}
 
 
 
 
/////ERROR MESSAGES////////  (using codeblocks IDE)
 
C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0x2cc)||undefined reference to `stringToBigInteger(std::string const&)'|
C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0x2ef)||undefined reference to `BigInteger::BigInteger(int)'|
C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0x31b)||undefined reference to `BigInteger::BigInteger(int)'|
C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0x431)||undefined reference to `BigInteger::BigInteger(int)'|
C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0x471)||undefined reference to `BigInteger::BigInteger(int)'|
C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0x59b)||undefined reference to `BigInteger::operator++(int)'|
C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0x625)||undefined reference to `BigInteger::operator++(int)'|
C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0x6df)||undefined reference to `BigInteger::BigInteger(int)'|
C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0x84a)||undefined reference to `BigInteger::operator=(BigInteger const&)'|
C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0xa50)||undefined reference to `operator<<(std::ostream&, BigInteger const&)'|
C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0xac5)||undefined reference to `operator<<(std::ostream&, BigInteger const&)'|
) const]+0xae)||undefined reference to `BigInteger::operator=(BigInteger const&)'|
) const]+0xc7)||undefined reference to `BigInteger::divideWithRemainder(BigInteger const&, BigInteger&)'|
) const]+0x14)||undefined reference to `BigInteger::compareTo(BigInteger const&) const'|
) const]+0xae)||undefined reference to `BigInteger::operator=(BigInteger const&)'|
) const]+0xc7)||undefined reference to `BigInteger::divideWithRemainder(BigInteger const&, BigInteger&)'|
)]+0x102)||undefined reference to `BigInteger::operator=(BigInteger const&)'|
 std::random_access_iterator_tag)]+0x34)||undefined reference to `BigInteger::operator=(BigInteger const&)'|
||=== Build finished: 18 errors, 0 warnings ===|
 


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mattmccutchen.net/mailman/archives/bigint/attachments/20100105/40e502e9/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: primefactor.cpp
Type: application/octet-stream
Size: 1389 bytes
Desc: not available
URL: <http://mattmccutchen.net/mailman/archives/bigint/attachments/20100105/40e502e9/attachment.obj>


More information about the bigint mailing list