| | |
Compiling error help please
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Sep 2008
Posts: 31
Reputation:
Solved Threads: 0
Ok here is the code I am trying to compile remotly on a linux machine
I am getting quite a few compile errors when I try to compile this
Here is just a sample of the errors I am getting.
Now on my home machine I have no problem compiling this I am using Dev C++ at home on a windows machine.
What Am I doing wrong
I am getting quite a few compile errors when I try to compile this
Here is just a sample of the errors I am getting.
C++ Syntax (Toggle Plain Text)
-bash-3.2$ gcc -o lemastsGCD lemastsGCD.cpp /tmp/cca8g62Q.o: In function `__static_initialization_and_destruction_0(int, int)': lemastsGCD.cpp:(.text+0x51): undefined reference to `std::ios_base::Init::Init()' /tmp/cca8g62Q.o: In function `__tcf_0': lemastsGCD.cpp:(.text+0x9a): undefined reference to `std::ios_base::Init::~Init()' /tmp/cca8g62Q.o: In function `gcdr(int, int)': lemastsGCD.cpp:(.text+0xb1): undefined reference to `std::cout' lemastsGCD.cpp:(.text+0xb6): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' lemastsGCD.cpp:(.text+0xc7): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(int)' lemastsGCD.cpp:(.text+0xd7): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' lemastsGCD.cpp:(.text+0xe8): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(int)' lemastsGCD.cpp:(.text+0xf8): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' lemastsGCD.cpp:(.text+0x100): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)' lemastsGCD.cpp:(.text+0x108): undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))' /tmp/cca8g62Q.o: In function `main': lemastsGCD.cpp:(.text+0x166): undefined reference to `std::cout'
Now on my home machine I have no problem compiling this I am using Dev C++ at home on a windows machine.
What Am I doing wrong
c++ Syntax (Toggle Plain Text)
#include <iostream> int gcdr(int a, int b); // recursive function declaration int gcdi(int a, int b); // iterative function declaration using namespace std; int main(int argc, char *argv[]) // Command line arguments { if (argc != 4) // If the command line does not receive four // arguments if statement is entered { cout << "\nProgram usage: program name.exe type of algorithm -r or -i integer integer\n"; // Statement to user that an error has occur ed return -1; // Terminate program } int x,y,swap; // Variables to hold input integers from user string GCDtype; // String variable to hold the type of function // to be used. GCDtype = argv[1]; // Variable to save the type of function to be run swap = 0; // Integer variable used for swap x = atoi(argv[2]); // Varable to hold first integer input y = atoi(argv[3]); // Viable to hold second integer input if (x <= y) // If statement to swap integers in the case // that the first integer is larger than second { swap = x; // set swap variable equal to x x = y; // set x equal to y y = swap; // set y equal to swap variable } if (GCDtype == "-r") // If statement for recursive function { cout << "\nStarting recursion" << endl; // Inform user starting recursion // start of recursion cout << "gcd by recursive algorithm is " << gcdr(x, y)/* function call*/ << endl; } else if (GCDtype == "-i") // Else if for iterative function { // Run GCDi function cout << "\ngcd by iterative algorithm is " << gcdi(x,y)/* function call*/ << endl; } else // Inform user that -r or -i was not entered { cout << "\nIncorrect use of program. Correct use is as follows\n"; cout << "Program Name.exe -r or -i integer integer" << endl; } return -1; // End program } int gcdr(int a, int b) // Function recursive { cout << "Finding gcd(" << a << "," << b << ")" << endl; return ( b == 0 ? a : gcdr(b, a % b) ); // Run recursion until GCD is found } int gcdi(int a, int b) // Function iterative { int c; // Variable to hold b while (b != 0) // Run while b does not equal zero { c = b; b = a % b; // b now equals a mod b a = c; // a now equals what b was } return a; }
![]() |
Similar Threads
- compiling error (C++)
- Another "cannot find symbol" compiling error (Java)
- compiling error, tried debugging but no luck (C)
- compiling error - help (C++)
- error 88:'(' expected when trying to display an array any help (Pascal and Delphi)
- compiling error wtf!?!? (C)
- Please help me out, need help (C)
Other Threads in the C++ Forum
- Previous Thread: Database connection in c++
- Next Thread: automated ticket system! HELP!!!
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamic email encryption error file forms fstream function functions game generator getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





