D
ddh
Hi,
I download mingw in my system(XP SP2), and extract them in
c:\mingw\gcc, so the directories looks like: c:\mingw\gcc\bin,
c:\mingw\gcc\include ..., and I added c:\mingw\gcc\bin in my PATH env.
It is OK for compiling .c code, but when compiling c++ code, some
error will occur.
my cpp file:
--- tmp.cpp ---
#include <iostream>
int main()
{
std::cout << "Hello, world!" << std::endl;
return 0;
}
And the command line is :
gcc -O2 -o tmp tmp.cpp
It output:
C:\DOCUME~1\user\LOCALS~1\Temp/ccYJbaaa.o(.text+0x1b):tmp.cpp:
undefined refe
rence to `std::cout'
C:\DOCUME~1\user\LOCALS~1\Temp/ccYJbaaa.o(.text+0x29):tmp.cpp:
undefined refe
rence to `std::basic_ostream<char, std::char_traits<char> >&
std:perator<< <st
C:\DOCUME~1\user\LOCALS~1\Temp/ccYJbaaa.o(.text+0x31):tmp.cpp:
undefined refe
rence to `std::basic_ostream<char, std::char_traits<char> >&
std::endl<char, std
undefined refe
rence to `std::ios_base::Init::Init()'
C:\DOCUME~1\user\LOCALS~1\Temp/ccYJbaaa.o(.text+0x98):tmp.cpp:
undefined refe
rence to `std::ios_base::Init::~Init()'
collect2: ld returned 1 exit status
But if the command line is:
gcc -O2 -o tmp tmp.cpp c:\mingw\gcc\lib\libstdc++.a
Then it will be OK.
So I want to know how to set the envionment so that I can use the
former command line to compile c++ code.
Thank you
I download mingw in my system(XP SP2), and extract them in
c:\mingw\gcc, so the directories looks like: c:\mingw\gcc\bin,
c:\mingw\gcc\include ..., and I added c:\mingw\gcc\bin in my PATH env.
It is OK for compiling .c code, but when compiling c++ code, some
error will occur.
my cpp file:
--- tmp.cpp ---
#include <iostream>
int main()
{
std::cout << "Hello, world!" << std::endl;
return 0;
}
And the command line is :
gcc -O2 -o tmp tmp.cpp
It output:
C:\DOCUME~1\user\LOCALS~1\Temp/ccYJbaaa.o(.text+0x1b):tmp.cpp:
undefined refe
rence to `std::cout'
C:\DOCUME~1\user\LOCALS~1\Temp/ccYJbaaa.o(.text+0x29):tmp.cpp:
undefined refe
rence to `std::basic_ostream<char, std::char_traits<char> >&
std:perator<< <st
const*)'d::char_traits said:&, char
C:\DOCUME~1\user\LOCALS~1\Temp/ccYJbaaa.o(.text+0x31):tmp.cpp:
undefined refe
rence to `std::basic_ostream<char, std::char_traits<char> >&
std::endl<char, std
C:\DOCUME~1\user\LOCALS~1\Temp/ccYJbaaa.o(.text+0x7c):tmp.cpp:::char_traits said:
undefined refe
rence to `std::ios_base::Init::Init()'
C:\DOCUME~1\user\LOCALS~1\Temp/ccYJbaaa.o(.text+0x98):tmp.cpp:
undefined refe
rence to `std::ios_base::Init::~Init()'
collect2: ld returned 1 exit status
But if the command line is:
gcc -O2 -o tmp tmp.cpp c:\mingw\gcc\lib\libstdc++.a
Then it will be OK.
So I want to know how to set the envionment so that I can use the
former command line to compile c++ code.
Thank you