Hello,

i have got problems compiling a simple "Hello World"  like c++ Project with a 
fresh Msys2 installation and a MinGW64 Toolchain on Windows 7.
Im using cmake to create the project.

CMakeLists.txt

cmake_minimum_required( VERSION 3.0 )
project( helloName )
add_executable(helloName main.cpp)



main.cpp

#include<iostream>
using namespace std;

int main()
{
    string name;
    cout << "Hello! Whats your name?";
    cin >> name;
    cout << "Hi, my name is " << name;

    return 0;
}


The following "cmake" operation works fine:

cmake -G"Eclipse CDT4 - Unix Makefiles" -DCMAKE_BUILD_TYPE=Debug 
-DCMAKE_ECLIPSE_VERSION=4.6.1 -DCMAKE_CXX_COMPILER_ARG1=-std=c++11

But if I try "make -j4" I got the error:

[ 50%] Building CXX object CMakeFiles/helloName.dir/main.cpp.obj
[100%] Linking CXX executable helloName
CMakeFiles/helloName.dir/main.cpp.obj: In function `main':
C:/Work/DevEnv/mingw64_checking/main.cpp:6: undefined reference to 
`std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> 
>::basic_string()'
C:/Work/DevEnv/mingw64_checking/main.cpp:7: undefined reference to 
`std::basic_ostream<char, std::char_traits<char> >& std::operator<< 
<std::char_traits<char> >(std::basic_ostream<char, std::char_traits<c           
          har> >&, char const*)'
C:/Work/DevEnv/mingw64_checking/main.cpp:8: undefined reference to 
`std::basic_istream<char, std::char_traits<char> >& std::operator>><char, 
std::char_traits<char>, std::allocator<char> >(std::basic_istre                 
    am<char, std::char_traits<char> >&, std::__cxx11::basic_string<char, 
std::char_traits<char>, std::allocator<char> >&)'
C:/Work/DevEnv/mingw64_checking/main.cpp:9: undefined reference to 
`std::basic_ostream<char, std::char_traits<char> >& std::operator<< 
<std::char_traits<char> >(std::basic_ostream<char, std::char_traits<c           
          har> >&, char const*)'
C:/Work/DevEnv/mingw64_checking/main.cpp:9: undefined reference to 
`std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, 
std::char_traits<char>, std::allocator<char> >(std::basic_ostr                  
   eam<char, std::char_traits<char> >&, std::__cxx11::basic_string<char, 
std::char_traits<char>, std::allocator<char> > const&)'
C:/Work/DevEnv/mingw64_checking/main.cpp:6: undefined reference to 
`std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> 
>::~basic_string()'
C:/Work/DevEnv/mingw64_checking/main.cpp:6: undefined reference to 
`std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> 
>::~basic_string()'
CMakeFiles/helloName.dir/main.cpp.obj: In function `__tcf_0':
C:/msys64/mingw64/include/c++/6.2.0/iostream:74: undefined reference to 
`std::ios_base::Init::~Init()'
CMakeFiles/helloName.dir/main.cpp.obj: In function 
`__static_initialization_and_destruction_0':
C:/msys64/mingw64/include/c++/6.2.0/iostream:74: undefined reference to 
`std::ios_base::Init::Init()'
CMakeFiles/helloName.dir/main.cpp.obj:main.cpp:(.data+0x0): undefined reference 
to `__gxx_personality_seh0'
CMakeFiles/helloName.dir/main.cpp.obj:main.cpp:(.xdata+0xc): undefined 
reference to `__gxx_personality_seh0'
CMakeFiles/helloName.dir/main.cpp.obj:main.cpp:(.rdata$.refptr._ZSt3cin[.refptr._ZSt3cin]+0x0):
 undefined reference to `std::cin'
CMakeFiles/helloName.dir/main.cpp.obj:main.cpp:(.rdata$.refptr._ZSt4cout[.refptr._ZSt4cout]+0x0):
 undefined reference to `std::cout'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/helloName.dir/build.make:95: helloName] Fehler 1
make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/helloName.dir/all] Fehler 2
make: *** [Makefile:84: all] Fehler 2


Thank you,

Michael


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Msys2-users mailing list
Msys2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/msys2-users

Reply via email to