Results 1 to 7 of 7

Thread: Need help in c++

  1. #1

    Default Need help in c++

    Recently i change my c++ programming environment from Windows to openSuSe 11.0, and i met lot of problem when i compile the source code.I had install everything of the add-on in Yast->software management->c/c++.
    I start with the simplest program "hello world",which only cout the world "hello world".Here is the problem:

    ass.cpp:(.text+0xa): undefined reference to `std::cout'
    ass.cpp:(.text+0xf): undefined reference to `std::basic_ostream<char, std::har_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_osream<char, std::char_traits<char> >&, char const*)'
    ass.cpp:(.text+0x17): undefined reference to `std::basic_ostream<char, std:char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_osream<char, std::char_traits<char> >&)'
    ass.cpp:(.text+0x1c): undefined reference to `std::basic_ostream<char, std:char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<car> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
    /tmp/ccOgf11w.o: In function `__static_initialization_and_destruction_0(int int)':
    ass.cpp:(.text+0x4a): undefined reference to `std::ios_base::Init::Init()'
    ass.cpp:(.text+0x4f): undefined reference to `std::ios_base::Init::~Init()'
    /tmp/ccOgf11w.o:(.eh_frame+0x12): undefined reference to `__gxx_personalityv0'
    collect2: ld returned 1 exit status

    what does it mean?
    it seems like the compiler does not recognize the <iostream> header.Is there any big difference between gcc compiler and Windows(i use Bloodshed Dev c++).
    I need help because i want to change from Windows to Linux.Perhaps i can get some link for more information about gcc compiler.thanks..

  2. #2
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: Need help in c++

    No problem here. Did you use g++ to compile?

    Code:
    $ cat hello.cc
    #include <iostream>
    
    main()
    {
            std::cout << "Hello world" << std::endl;
    }
    $ g++ -o hello hello.cc
    $ ./hello
    Hello world

  3. #3

    Default Re: Need help in c++

    After the installation of openSuSe i had try to compile the source code and i get nth(neither gcc nor g++),after few "add-on",i can use gcc already.I am not familiar with gcc...
    Now i am using g++ -o <> <> ,because it is more close to c++ in windows.For example, i never see std::cout(i always use cout in windows).Forgive me as i just change from windows to linux.Is there any related forum for a newbie like me?I would like to know more about gcc.Anyways thanks for help.

  4. #4
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: Need help in c++

    For compiling C++ programs use g++. For compiling C programs use gcc.

    To be able to omit std::, read up about namespaces. This is a standard C++ feature now.

  5. #5

    Default Re: Need help in c++

    Wise Penguin, sorry for my ignorance, is there anyway I can "export" a LInux script to Windows? I mean , without programming php or C++ , just taking the whole LInux script.
    Thank you in advance!

  6. #6
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: Need help in c++

    What sort of scripts are these that you are trying to run on Windows? Shell scripts?

  7. #7

    Default Re: Need help in c++

    Hi,

    I am not an expert, but as I am tackling a similar problem in these days, I may suggest you to have a look at the following link (for gcc etc.):

    An Introduction to GCC - Linking with external libraries

    Maybe you are not including the -l option suitable for your case. Please, let me know if it works...

    mig-37

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •