CMake C ++。 OStream:不是'std'的成员

时间:2015-06-21 22:00:57

标签: c++ cmake

所以,这是我第一次使用CMake,但至少在我看来这是非常奇怪的错误。我在C ++标准库中使用的任何内容都会引发错误,因此我目前有100多个错误。在线我读它与我的代码被编译为'C'的事实有关,虽然我不知道如何强制使用C ++。

这是我目前的CMakeLists:

project(Dynamik CXX)

if(MSVC)
    add_definitions(/D_WIN32_WINNT=0x0501 /D_CRT_SECURE_NO_WARNINGS /DSFML_STATIC)
    set(CMAKE_CXX_FLAGS         "${CMAKE_CXX_FLAGS} /MP /EHsc /wd4244 /wd4996 ")
    set(CMAKE_CXX_FLAGS_DEBUG   "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /DNDEBUG /MT /MP /GS- /Ox /Ob2 /Oi /Oy /arch:SSE /fp:fast /Zi")
    set(CMAKE_LIB_LINKER_FLAGS  "${CMAKE_LIB_LINKER_FLAGS} /OPT:REF /SUBSYSTEM:WINDOWS")

else() # Most likely gcc or clang
    if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
    elseif ("${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "4.7")
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
    else()
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
    endif()

    if (BUILD_COVERAGE AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
    endif()

    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wno-strict-aliasing")
    set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
    set(CMAKE_CXX_FLAGS_DEBUG   "-g")
endif()

# Lets LOAD app our headers!
file(GLOB_RECURSE HDRS ${Dynamik_SOURCE_DIR}/*.h)

# Lets LOAD app our sources!
file(GLOB_RECURSE SRCS
    ${Dynamik_SOURCE_DIR}/*.cpp
    ${Dynamik_SOURCE_DIR}/*.c
)

#define the library
add_library(Dynamik STATIC ${HDRS} ${SRCS})

#Look for the packages we need

# OpenGL
find_package(OpenGL REQUIRED)

# GLEW
INCLUDE(${Dynamik_CMAKE_DIR}../CMake/FindGLEW.cmake)

# SDL2
INCLUDE(${Dynamik_CMAKE_DIR}../CMake/FindSDL2.cmake)

# Define the include DIR's 
include_directories(
    ${Dynamik_SOURCE_DIR}
    ${OPENGL_INCLUDE_DIRS}
    ${GLEW_INCLUDE_DIRS}
    ${SDL2_INCLUDE_DIRS}
)

以下是一些错误:

2>  DynamikError.cpp
2>  FileUtils.cpp
2>  FpsLimiter.cpp
2>  InputManager.cpp
2>f:\dynamik-cmake\dynamik\Vec2.h(33): error C2039: 'ostream' : is not a member of 'std' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec2.h(33): error C2143: syntax error : missing ';' before '&' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec2.h(33): error C2433: 'Dynamik::ostream' : 'friend' not permitted on data declarations (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec2.h(33): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec2.h(33): error C2039: 'ostream' : is not a member of 'std' (F:\Dynamik-CMake\Dynamik\DynamikError.cpp)
2>f:\dynamik-cmake\dynamik\Vec2.h(33): error C2061: syntax error : identifier 'ostream' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec2.h(33): error C2805: binary 'operator <<' has too few parameters (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec3.h(35): error C2039: 'ostream' : is not a member of 'std' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec3.h(35): error C2143: syntax error : missing ';' before '&' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec3.h(35): error C2433: 'Dynamik::ostream' : 'friend' not permitted on data declarations (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec3.h(35): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec3.h(35): error C2061: syntax error : identifier 'ostream' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec3.h(35): error C2805: binary 'operator <<' has too few parameters (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec4.h(36): error C2039: 'ostream' : is not a member of 'std' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec4.h(36): error C2143: syntax error : missing ';' before '&' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec4.h(36): error C2433: 'Dynamik::ostream' : 'friend' not permitted on data declarations (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec4.h(36): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec4.h(36): error C2061: syntax error : identifier 'ostream' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec4.h(36): error C2805: binary 'operator <<' has too few parameters (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\MathFunc.h(10): error C2065: 'M_PI' : undeclared identifier (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtgmath.h(126): error C2039: 'fmaf' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtgmath.h(126): error C3861: 'fmaf': identifier not found (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtgmath.h(131): error C2039: 'fma' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtgmath.h(131): error C3861: 'fma': identifier not found (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtgmath.h(136): error C2039: 'fmal' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtgmath.h(136): error C3861: 'fmal': identifier not found (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtgmath.h(154): error C2039: 'remquof' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtgmath.h(154): error C3861: 'remquof': identifier not found (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtgmath.h(159): error C2039: 'remquo' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtgmath.h(159): error C3861: 'remquo': identifier not found (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtgmath.h(164): error C2039: 'remquol' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtgmath.h(164): error C3861: 'remquol': identifier not found (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(23): error C2039: 'abs' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(23): error C2873: 'abs' : symbol cannot be used in a using-declaration (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(26): error C2039: 'fabs' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(26): error C2873: 'fabs' : symbol cannot be used in a using-declaration (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(28): error C2039: 'modf' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(28): error C2873: 'modf' : symbol cannot be used in a using-declaration (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(32): error C2039: 'acosf' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec2.h(33): error C2143: syntax error : missing ';' before '&' (F:\Dynamik-CMake\Dynamik\DynamikError.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(32): error C2873: 'acosf' : symbol cannot be used in a using-declaration (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec2.h(33): error C2433: 'Dynamik::ostream' : 'friend' not permitted on data declarations (F:\Dynamik-CMake\Dynamik\DynamikError.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(32): error C2039: 'asinf' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec2.h(33): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (F:\Dynamik-CMake\Dynamik\DynamikError.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(32): error C2873: 'asinf' : symbol cannot be used in a using-declaration (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(33): error C2039: 'atanf' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec2.h(33): error C2061: syntax error : identifier 'ostream' (F:\Dynamik-CMake\Dynamik\DynamikError.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(33): error C2873: 'atanf' : symbol cannot be used in a using-declaration (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(33): error C2039: 'atan2f' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec2.h(33): error C2805: binary 'operator <<' has too few parameters (F:\Dynamik-CMake\Dynamik\DynamikError.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(33): error C2873: 'atan2f' : symbol cannot be used in a using-declaration (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(33): error C2039: 'ceilf' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(33): error C2873: 'ceilf' : symbol cannot be used in a using-declaration (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec3.h(35): error C2039: 'ostream' : is not a member of 'std' (F:\Dynamik-CMake\Dynamik\DynamikError.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(34): error C2039: 'cosf' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec3.h(35): error C2143: syntax error : missing ';' before '&' (F:\Dynamik-CMake\Dynamik\DynamikError.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(34): error C2873: 'cosf' : symbol cannot be used in a using-declaration (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec3.h(35): error C2433: 'Dynamik::ostream' : 'friend' not permitted on data declarations (F:\Dynamik-CMake\Dynamik\DynamikError.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(34): error C2039: 'coshf' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec3.h(35): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (F:\Dynamik-CMake\Dynamik\DynamikError.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(34): error C2873: 'coshf' : symbol cannot be used in a using-declaration (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(34): error C2039: 'expf' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec3.h(35): error C2061: syntax error : identifier 'ostream' (F:\Dynamik-CMake\Dynamik\DynamikError.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(34): error C2873: 'expf' : symbol cannot be used in a using-declaration (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(35): error C2039: 'fabsf' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec3.h(35): error C2805: binary 'operator <<' has too few parameters (F:\Dynamik-CMake\Dynamik\DynamikError.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(35): error C2873: 'fabsf' : symbol cannot be used in a using-declaration (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(35): error C2039: 'floorf' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(35): error C2873: 'floorf' : symbol cannot be used in a using-declaration (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec4.h(36): error C2039: 'ostream' : is not a member of 'std' (F:\Dynamik-CMake\Dynamik\DynamikError.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(35): error C2039: 'fmodf' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec4.h(36): error C2143: syntax error : missing ';' before '&' (F:\Dynamik-CMake\Dynamik\DynamikError.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(35): error C2873: 'fmodf' : symbol cannot be used in a using-declaration (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec4.h(36): error C2433: 'Dynamik::ostream' : 'friend' not permitted on data declarations (F:\Dynamik-CMake\Dynamik\DynamikError.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(36): error C2039: 'frexpf' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec4.h(36): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int (F:\Dynamik-CMake\Dynamik\DynamikError.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(36): error C2873: 'frexpf' : symbol cannot be used in a using-declaration (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(36): error C2039: 'ldexpf' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec4.h(36): error C2061: syntax error : identifier 'ostream' (F:\Dynamik-CMake\Dynamik\DynamikError.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(36): error C2873: 'ldexpf' : symbol cannot be used in a using-declaration (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(36): error C2039: 'logf' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\Vec4.h(36): error C2805: binary 'operator <<' has too few parameters (F:\Dynamik-CMake\Dynamik\DynamikError.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(36): error C2873: 'logf' : symbol cannot be used in a using-declaration (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(37): error C2039: 'log10f' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(37): error C2873: 'log10f' : symbol cannot be used in a using-declaration (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(37): error C2039: 'modff' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(37): error C2873: 'modff' : symbol cannot be used in a using-declaration (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>f:\dynamik-cmake\dynamik\MathFunc.h(10): error C2065: 'M_PI' : undeclared identifier (F:\Dynamik-CMake\Dynamik\DynamikError.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(37): error C2039: 'powf' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(37): error C2873: 'powf' : symbol cannot be used in a using-declaration (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)
2>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\cmath(38): error C2039: 'sinf' : is not a member of '`global namespace'' (F:\Dynamik-CMake\Dynamik\FileUtils.cpp)

任何帮助解决此问题将不胜感激。谢谢!

0 个答案:

没有答案