<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><DIV>I was wondering if anyone was having similar problem with trying to use the stringToBigInteger() function.</DIV>
<DIV> </DIV>
<DIV>I have attached a sample code below, and as an attachment. </DIV>
<DIV> </DIV>
<DIV>I have included "BigIntegerLibrary.hh"; however, the compiler is inable to reconcile the stringToBigInteger() function.</DIV>
<DIV> </DIV>
<DIV>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()).</DIV>
<DIV> </DIV>
<DIV>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).</DIV>
<DIV> </DIV>
<DIV>I believe my code matches closely to the "sample.cpp" you provide with the zipped download.</DIV>
<DIV> </DIV>
<DIV>Please let me know what I am doing wrong here.</DIV>
<DIV> </DIV>
<DIV>-Dave W.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>////////CODE TO FOLLOW/////////</DIV>
<DIV> </DIV>
<DIV>#include<iostream><BR>#include<string><BR>#include<vector><BR>#include "BigIntegerLibrary.hh"</DIV>
<DIV>int main()<BR>{<BR> bool is_prime = true;</DIV>
<DIV> std::vector<BigInteger> prime_list;<BR> std::vector<BigInteger> prime_factors;<BR> std::vector<BigInteger>::iterator iter;</DIV>
<DIV> std::string number = "600851475143";</DIV>
<DIV> BigInteger bigNumber = stringToBigInteger(number);</DIV>
<DIV> //Generate a list of primes<BR> for(BigInteger i=2; i<bigNumber/2; i++)<BR> {<BR> is_prime = true;</DIV>
<DIV> for(BigInteger j=2; j<i; j++)<BR> {<BR> if((i%j)==0)<BR> {<BR> is_prime = false;<BR> break;<BR> }<BR> }</DIV>
<DIV> if(is_prime)<BR> {<BR> prime_list.push_back(i);<BR> }<BR> }</DIV>
<DIV> //Get primes that work, from the bottom up<BR> for(iter = prime_list.begin(); iter != prime_list.end(); iter++)<BR> {<BR> if((bigNumber % *iter)==0)<BR> {<BR> bigNumber /= *iter;<BR> prime_factors.push_back(*iter);<BR> iter--;<BR> }<BR> }</DIV>
<DIV> std::cout << "\nThe prime factors of 600,851,475,143 are: ";</DIV>
<DIV> for(iter = prime_list.begin(); iter != prime_list.end(); iter++)<BR> {<BR> std::cout << *iter << std::endl;<BR> }</DIV>
<DIV> std::cout << "\nThe largest prime factor of 600,851,475,143 is: " << prime_factors[prime_factors.size()-1];</DIV>
<DIV> return 0;<BR>}</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>/////ERROR MESSAGES//////// (using codeblocks IDE)</DIV>
<DIV> </DIV>
<DIV>C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0x2cc)||undefined reference to `stringToBigInteger(std::string const&)'|<BR>C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0x2ef)||undefined reference to `BigInteger::BigInteger(int)'|<BR>C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0x31b)||undefined reference to `BigInteger::BigInteger(int)'|<BR>C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0x431)||undefined reference to `BigInteger::BigInteger(int)'|<BR>C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0x471)||undefined reference to `BigInteger::BigInteger(int)'|<BR>C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0x59b)||undefined reference to `BigInteger::operator++(int)'|<BR>C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0x625)||undefined
reference to `BigInteger::operator++(int)'|<BR>C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0x6df)||undefined reference to `BigInteger::BigInteger(int)'|<BR>C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0x84a)||undefined reference to `BigInteger::operator=(BigInteger const&)'|<BR>C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0xa50)||undefined reference to `operator<<(std::ostream&, BigInteger const&)'|<BR>C:\Users\Dave\Desktop\bigint-2009.05.03\primefactor.o:primefactor.cpp:(.text+0xac5)||undefined reference to `operator<<(std::ostream&, BigInteger const&)'|<BR>) const]+0xae)||undefined reference to `BigInteger::operator=(BigInteger const&)'|<BR>) const]+0xc7)||undefined reference to `BigInteger::divideWithRemainder(BigInteger const&, BigInteger&)'|<BR>) const]+0x14)||undefined reference to
`BigInteger::compareTo(BigInteger const&) const'|<BR>) const]+0xae)||undefined reference to `BigInteger::operator=(BigInteger const&)'|<BR>) const]+0xc7)||undefined reference to `BigInteger::divideWithRemainder(BigInteger const&, BigInteger&)'|<BR>)]+0x102)||undefined reference to `BigInteger::operator=(BigInteger const&)'|<BR> std::random_access_iterator_tag)]+0x34)||undefined reference to `BigInteger::operator=(BigInteger const&)'|<BR>||=== Build finished: 18 errors, 0 warnings ===|</DIV>
<DIV> </DIV></td></tr></table><br>