c++ - Compiling a program under Windows gives a bunch of "error: template with C linkage" reports -
i have made opengl project compilable gcc (version 4.7.3 , newer) , runable on linux. when trying compile same code under windows using msys2 gcc 4.9.2 installed, tons of error reports:
g++ -g --std=c++11 src/*.cpp -iinclude -isrc -lil -lilu -lilut -lgl -lglu -lglut -lm -dwin32 -i/mingw64/include windows/src/*.cpp -o "achtung, die kurve 3d!" in file included /usr/lib/gcc/x86_64-pc-msys/4.9.2/include/c++/bits/stringfwd.h:40:0, /usr/lib/gcc/x86_64-pc-msys/4.9.2/include/c++/string:39, include/windows.h:1, /usr/include/w32api/gl/gl.h:13, /mingw64/include/gl/freeglut_std.h:143, /mingw64/include/gl/freeglut.h:17, src/controls.cpp:1: /usr/lib/gcc/x86_64-pc-msys/4.9.2/include/c++/bits/memoryfwd.h:63:3: error: template c linkage template<typename> ^ /usr/lib/gcc/x86_64-pc-msys/4.9.2/include/c++/bits/memoryfwd.h:66:3: error: template specialization c linkage template<> ^ /usr/lib/gcc/x86_64-pc-msys/4.9.2/include/c++/bits/memoryfwd.h:70:3: error: template c linkage template<typename, typename> ^ ... in file included /mingw64/include/gl/freeglut_std.h:143:0, /mingw64/include/gl/freeglut.h:17, src/controls.cpp:1: /usr/include/w32api/gl/gl.h:684:1: error: ‘wingdiapi’ not name type wingdiapi void apientry glaccum(glenum op,glfloat value); ... /usr/include/w32api/gl/gl.h:1037:24: error: expected ‘)’ before ‘*’ token typedef void (apientry *pfnglgetcolortableparameterfvextproc)(glenum target,glenum pname,glfloat *params); ^ in file included /mingw64/include/gl/freeglut_std.h:144:0, /mingw64/include/gl/freeglut.h:17, src/controls.cpp:1: /usr/include/w32api/gl/glu.h:24:25: error: expected initializer before ‘gluerrorstring’ const glubyte *apientry gluerrorstring(glenum errcode); ^ /usr/include/w32api/gl/glu.h:25:25: error: expected initializer before ‘gluerrorunicodestringext’ const wchar_t *apientry gluerrorunicodestringext(glenum errcode); ^ ...
this taken partial log consisting of 4500 lines of errors. these frequent ones repeated many times.
i thought problem lied in old msys/mingw (not msys2 port) tried first same results. however, msys2 did not solve problems makes me clueless since code written in c++ , requires standard c , c++ header files along gl ones. not use extern "c" mangling.
you using msys2 gcc here, not mingw-w64 gcc.
please read msys2 wiki [1] of explained, briefly:
run mingw64_shell.bat
, not msys2_shell.bat
, install mingw-w64 gcc toolchain package(s). command installs both 32-bit , 64-bit ones using bash curly brace expansion feature:
pacman -s mingw-w64-{x86_64,i686}-toolchain
.. see gcc -dumpmachine
reports x86_64-w64-mingw32
, not x86_64-pc-msys
Comments
Post a Comment