LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-21-2008, 07:31 PM   #1
LinuxCrayon
Member
 
Registered: Nov 2007
Location: Georgia, USA
Distribution: FreeBSD
Posts: 274

Rep: Reputation: 31
[C++] Cross Compiling Problems


Hey guys. I have a C++ program I wrote that compiles fine when using g++. No errors, no warnings. Even verbose mode seems to indicate no warnings.

Here is the code for the Windows version:
Code:
#include <iostream>
#include <cstdlib>
#include "ClearScreen.h"

int main()
{
    bool quit;
    int guess;
    int randomNumber;    
    
    quit = false;
    
    srand(time(0));
    
    ClearScreen("windows");
    
    std::cout << "Welcome to Numbamatic, the Guess a Number Game!\n\n";
    std::cout << "Please press 'Enter' to start!";
    
    getchar();
    
    ClearScreen("windows");
    
    while (!quit)
    {
        std::string answer;
        
        randomNumber = rand() % 10 + 1;
        
        std::cout << "The number has been generated!\n\n";
        
        do
        {    
            std::cout << "Please guess a number!\n>  ";
            std::cin >> guess;
            ClearScreen("windows");
            
            if (guess > randomNumber)
            {
                std::cout << "Sorry, but the number you guessed was too high.\n\n";
            }
            else if (guess < randomNumber)
            {
                std::cout << "Sorry, but the number you guessed was too low.\n\n";
            }
            else
            {
                std::cout << "Congratulations!  You correctly guessed the "\
                    "number!\n\n";
            }
        } while (guess != randomNumber);
        
        std::cout << "Would you like to play again?\n>[y/n]  ";
        std::cin >> answer;
        
        if (answer != "y" && answer != "n")
        {
            std::cout << "I'm sorry, but you entered an invalid response."\
                "  The game will now terminate due to your incompetence."\
                "  Have a nice day!\n\n";
            quit = true;
        }
        else if (answer == "y")
        {
            ClearScreen("windows");
        }
        else
        {
            quit = true;
        }
    }
    
    std::cout << "Thanks for playing!\n\n";
    
    return 0;    
}
And the ClearScreen.h file:
Code:
int ClearScreen(std::string os)
{
    if (os == "unix")
    {
        system("clear");
    }
    else if (os == "windows")
    {
        system("cls");
    }
    else
    {
        std::cout << "Error!" << std::endl;
        std::cout << "The value you passed to ClearScreen() is not valid!\n";
        exit(1);
    }
    
    return 0;
}
The above code compiles perfectly in Linux using g++. However, trying to compile it for Windows using MinGW does not work. I've tried using Visual C++ 2008 on a Windows box to compile it, and it still does not work.

Continued in Post 2.
 
Old 10-21-2008, 07:32 PM   #2
LinuxCrayon
Member
 
Registered: Nov 2007
Location: Georgia, USA
Distribution: FreeBSD
Posts: 274

Original Poster
Rep: Reputation: 31
Here is the MinGW errors:
Code:
 i586-mingw32msvc-cc numbamatic-windows.cpp -o numbamatic
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0xe): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x52): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x8b): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0xd0): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x120): undefined reference to `std::ios_base::Init::Init()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x163): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x1cd): undefined reference to `std::cout'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x1d2): 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*)'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x1dd): 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> >&)'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x1e3): 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/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x1f3): undefined reference to `std::cout'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x1f8): 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*)'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x22a): undefined reference to `___gxx_personality_sj0'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x281): undefined reference to `std::allocator<char>::allocator()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x2a0): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x2cc): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x2f0): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x30d): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x31d): undefined reference to `std::cout'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x329): 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*)'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x339): undefined reference to `std::cout'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x33e): 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*)'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x352): undefined reference to `std::allocator<char>::allocator()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x371): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x38e): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x3db): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x3ff): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x41c): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x43c): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x473): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x49e): undefined reference to `std::cout'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x4aa): 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*)'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x4ba): undefined reference to `std::cout'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x4c6): 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*)'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x4d5): undefined reference to `std::cin'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x4da): undefined reference to `std::basic_istream<char, std::char_traits<char> >::operator>>(int&)'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x4e9): undefined reference to `std::allocator<char>::allocator()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x508): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x534): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x558): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x575): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x59a): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x5bb): undefined reference to `std::cout'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x5c7): 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*)'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x5e1): undefined reference to `std::cout'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x5ed): 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*)'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x5ff): undefined reference to `std::cout'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x60b): 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*)'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x627): undefined reference to `std::cout'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x633): 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*)'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x642): undefined reference to `std::cin'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x647): undefined reference to `std::basic_istream<char, std::char_traits<char> >& std::operator>><char, std::char_traits<char>, std::allocator<char> >(std::basic_istream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x6a7): undefined reference to `std::cout'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x6b3): 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*)'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x6ee): undefined reference to `std::allocator<char>::allocator()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x70d): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x739): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x7da): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x7f4): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x80e): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x833): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x854): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x890): undefined reference to `std::cout'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text+0x89c): 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*)'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text$_ZStneIcSt11char_traitsIcESaIcEEbRKSbIT_T0_T1_EPKS3_[bool std::operator!=<char, std::char_traits<char>, std::allocator<char> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*)]+0x10): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(char const*) const'
/tmp/ccsNJyWn.o:numbamatic-windows.cpp:(.text$_ZSteqIcSt11char_traitsIcESaIcEEbRKSbIT_T0_T1_EPKS3_[bool std::operator==<char, std::char_traits<char>, std::allocator<char> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*)]+0x10): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(char const*) const'
collect2: ld returned 1 exit status
dev@dev:~/tutorials/cpp/personal.projects$ less numbamatic-windows.cpp
dev@dev:~/tutorials/cpp/personal.projects$ less numbamatic-unix.cpp
dev@dev:~/tutorials/cpp/personal.projects$ g++ numbamatic-windows.cpp
dev@dev:~/tutorials/cpp/personal.projects$ g++ -v numbamatic-windows.cpp
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)
 /usr/lib/gcc/x86_64-linux-gnu/4.2.3/cc1plus -quiet -v -D_GNU_SOURCE numbamatic-windows.cpp -quiet -dumpbase numbamatic-windows.cpp -mtune=generic -auxbase numbamatic-windows -version -fstack-protector -fstack-protector -o /tmp/ccYgt8Io.s
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.2.3/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/usr/include/x86_64-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.2
 /usr/include/c++/4.2/x86_64-linux-gnu
 /usr/include/c++/4.2/backward
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.2.3/include
 /usr/include
End of search list.
GNU C++ version 4.2.3 (Ubuntu 4.2.3-2ubuntu7) (x86_64-linux-gnu)
    compiled by GNU C version 4.2.3 (Ubuntu 4.2.3-2ubuntu7).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: d12ba6ac5ad10f3cd3c194fd1127d2d9
 as --traditional-format -V -Qy -o /tmp/cc4aTJB1.o /tmp/ccYgt8Io.s
GNU assembler version 2.18.0 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.18.0.20080103
 /usr/lib/gcc/x86_64-linux-gnu/4.2.3/collect2 --eh-frame-hdr -m elf_x86_64 --hash-style=both -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/gcc/x86_64-linux-gnu/4.2.3/../../../../lib/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.2.3/../../../../lib/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.2.3/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.2.3 -L/usr/lib/gcc/x86_64-linux-gnu/4.2.3 -L/usr/lib/gcc/x86_64-linux-gnu/4.2.3/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.2.3/../../.. /tmp/cc4aTJB1.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.2.3/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.2.3/../../../../lib/crtn.o
dev@dev:~/tutorials/cpp/personal.projects$ i586-mingw32msvc-cc numbamatic-windows.cpp -o numbamatic
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0xe): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x52): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x8b): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0xd0): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x120): undefined reference to `std::ios_base::Init::Init()'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x163): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x1cd): undefined reference to `std::cout'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x1d2): 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*)'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x1dd): 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> >&)'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x1e3): 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/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x1f3): undefined reference to `std::cout'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x1f8): 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*)'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x22a): undefined reference to `___gxx_personality_sj0'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x281): undefined reference to `std::allocator<char>::allocator()'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x2a0): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x2cc): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x2f0): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x30d): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x31d): undefined reference to `std::cout'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x329): 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*)'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x339): undefined reference to `std::cout'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x33e): 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*)'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x352): undefined reference to `std::allocator<char>::allocator()'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x371): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x38e): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x3db): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x3ff): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x41c): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x43c): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x473): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x49e): undefined reference to `std::cout'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x4aa): 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*)'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x4ba): undefined reference to `std::cout'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x4c6): 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*)'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x4d5): undefined reference to `std::cin'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x4da): undefined reference to `std::basic_istream<char, std::char_traits<char> >::operator>>(int&)'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x4e9): undefined reference to `std::allocator<char>::allocator()'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x508): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x534): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x558): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x575): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x59a): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x5bb): undefined reference to `std::cout'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x5c7): 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*)'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x5e1): undefined reference to `std::cout'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x5ed): 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*)'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x5ff): undefined reference to `std::cout'
/tmp/ccIgUslU.o:numbamatic-windows.cpp:(.text+0x60b): 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*)'
.........................
collect2: ld returned 1 exit status
dev@dev:~/tutorials/cpp/personal.projects$ int ClearScreen(std::string os)
bash: syntax error near unexpected token `('
dev@dev:~/tutorials/cpp/personal.projects$ {
>     if (os == "unix")
>     {
>         system("clear");
bash: syntax error near unexpected token `"clear"'
dev@dev:~/tutorials/cpp/personal.projects$     }
bash: syntax error near unexpected token `}'
dev@dev:~/tutorials/cpp/personal.projects$     else if (os == "windows")
bash: syntax error near unexpected token `else'
dev@dev:~/tutorials/cpp/personal.projects$     {
>         system("cls");
bash: syntax error near unexpected token `"cls"'
dev@dev:~/tutorials/cpp/personal.projects$     }
bash: syntax error near unexpected token `}'
dev@dev:~/tutorials/cpp/personal.projects$     else
bash: syntax error near unexpected token `else'
dev@dev:~/tutorials/cpp/personal.projects$     {
>         std::cout << "Error!" << std::endl;
bash: !": event not found
>         std::cout << "The value you passed to ClearScreen() is not valid!\n";
bash: !\n": event not found
>         exit(1);
bash: syntax error near unexpected token `1'
dev@dev:~/tutorials/cpp/personal.projects$     }
bash: syntax error near unexpected token `}'
dev@dev:~/tutorials/cpp/personal.projects$    
dev@dev:~/tutorials/cpp/personal.projects$     return 0;
bash: return: can only `return' from a function or sourced script
dev@dev:~/tutorials/cpp/personal.projects$ }
As you can see, it's more or less a lot of the same repeated over and over, until the very end.

I'm not an experienced C++ developer, and I'm just trying to get it to work in both Windows and Linux. As I said before, the Linux version compiles fine, and the Windows version compiles fine if I use g++...but this does not produce a Windows binary file, obviously, and is therefore of little use.

What's the deal here?

[NOTE]
I removed a portion of the error report because it causes me to go over the character limit.
[/NOTE]
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Binutils, Cross Compiling problems sci3ntist Programming 1 08-09-2007 06:11 PM
Cross Compiling dosnlinux Programming 5 03-01-2006 11:12 AM
cross compiling cerin Linux - Software 1 02-11-2006 10:47 PM
cross-compiling? jon_k Programming 3 12-09-2004 09:36 AM
cross compiling with g++ hornofsalvation Linux - Newbie 2 10-09-2004 10:29 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration