mingw-w64 & CLion cannot compile projects with assimp successfully - c++
Using CLion & mingw-w64(7.2.0) to compile https://github.com/CasterKKK/OpenGLStarter, get the following errors:
In file included from C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/x86_64-w64-mingw32/include/windows.h:70:0,
from C:/PROGRA~1/POSTGR~1/10/include/pthread.h:198,
from C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/x86_64-w64-mingw32/bits/gthr-default.h:35,
from C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/x86_64-w64-mingw32/bits/gthr.h:148,
from C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/ext/atomicity.h:35,
from C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/bits/basic_string.h:39,
from C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/string:52,
from C:/PROGRA~1/MINGW-~1/X86_64~1.0-P/mingw64/lib/gcc/x86_64-w64-mingw32/7.2.0/include/c++/stdexcept:39,
from D:/Workspaces/CppWorkspace/OpenGLEngine/lib/assimp/include/assimp/Exceptional.h:44,
from D:/Workspaces/CppWorkspace/OpenGLEngine/lib/assimp/include/assimp/BaseImporter.h:47,
from D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBLoader.h:49,
from D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBLoader.cpp:48:
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:185:20: error: expected identifier before numeric constant
SPOT,LOCAL,INFINITE
^
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:185:20: error: expected '}' before numeric constant
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:185:20: error: expected unqualified-id before numeric constant
In file included from D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBLoader.cpp:49:0:
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:188:30: error: 'Assimp::COB::ChunkInfo' is not a namespace or unscoped enum
using ChunkInfo::operator=;
^
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:189:11: error: expected unqualified-id before ')' token
Light() : Node(TYPE_LIGHT),angle(),inner_angle(),ltype(SPOT) {}
^
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:194:5: error: 'LightType' does not name a type; did you mean 'Light'?
LightType ltype;
^~~~~~~~~
Light
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:200:1: error: expected class-name before '{' token
{
^
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:201:11: error: 'ChunkInfo' has not been declared
using ChunkInfo::operator=;
^~~~~~~~~
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h: In constructor 'Assimp::Camera::Camera()':
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:202:16: error: class 'Assimp::Camera' does not have any field named 'Node'
Camera() : Node(TYPE_CAMERA) {}
^~~~
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:202:21: error: 'TYPE_CAMERA' was not declared in this scope
Camera() : Node(TYPE_CAMERA) {}
^~~~~~~~~~~
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:202:21: note: suggested alternative: 'TP_TIMER'
Camera() : Node(TYPE_CAMERA) {}
^~~~~~~~~~~
TP_TIMER
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h: At global scope:
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:216:1: error: expected class-name before '{' token
{
^
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:217:11: error: 'ChunkInfo' has not been declared
using ChunkInfo::operator=;
^~~~~~~~~
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:249:1: error: expected class-name before '{' token
{
^
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:260:37: error: 'Node' was not declared in this scope
typedef std::deque< std::shared_ptr<Node> > NodeList;
^~~~
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:260:37: note: suggested alternative:
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:105:8: note: 'Assimp::COB::Node'
struct Node : public ChunkInfo
^~~~
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:260:41: error: template argument 1 is invalid
typedef std::deque< std::shared_ptr<Node> > NodeList;
^
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:260:43: error: template argument 1 is invalid
typedef std::deque< std::shared_ptr<Node> > NodeList;
^
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:260:43: error: template argument 2 is invalid
D:\Workspaces\CppWorkspace\OpenGLEngine\lib\assimp\code\COBScene.h:275:1: error: expected declaration before '}' token
} // end Assimp
^
mingw32-make.exe[3]: *** [lib\assimp\code\CMakeFiles\assimp.dir\build.make:1645: lib/assimp/code/CMakeFiles/assimp.dir/COBLoader.cpp.obj] Error 1
mingw32-make.exe[3]: *** Waiting for unfinished jobs....
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:332: lib/assimp/code/CMakeFiles/assimp.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:89: CMakeFiles/OpenGLEngine.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:163: OpenGLEngine] Error 2
But if I open and compile it with Visual Studio 2017, it works fine...
Here is the CLion's setting:
I used the command line cmake -G"Visual Studio 15 2017 Win64" .. to compile the code, and it works fine, but I cannot set Visual Studio in CLion, for it cannot find C:\Program Files (x86)\Microsoft Visual Studio\2017\Community even my VS 2017 is right there, which is really weird...
The problem is that the project on Github was never build with mingw, thus the issues you are seeing. Better stick to VS or clang compilers.
Related
How can I resolve ReLU is not a member of torch::nn error while building?
I am trying to build a simple network using torch. But when I try to build the project it returns some error messages like error: ‘ReLU’ is not a member of ‘torch::nn’ My network definitions is as follows: #pragma once #include <torch/torch.h> class ConvNetImpl : public torch::nn::Module { public: explicit ConvNetImpl(int64_t num_classes = 10); torch::Tensor forward(torch::Tensor x); private: torch::nn::Sequential layer1{ torch::nn::Conv2d(torch::nn::Conv2dOptions(1, 16, 5).stride(1).padding(2)), torch::nn::BatchNorm2d(16), torch::nn::ReLU(), torch::nn::MaxPool2d(torch::nn::MaxPool2dOptions(2).stride(2)) }; torch::nn::Sequential layer2{ torch::nn::Conv2d(torch::nn::Conv2dOptions(16, 32, 5).stride(1).padding(2)), torch::nn::BatchNorm2d(32), torch::nn::ReLU(), torch::nn::MaxPool2d(torch::nn::MaxPool2dOptions(2).stride(2)) }; torch::nn::Linear fc; }; TORCH_MODULE(ConvNet); When I try to build with: cmake --build . --config Release It returns me this message: [ 33%] Building CXX object CMakeFiles/freespace_torch.dir/src/convnet.cpp.o In file included from /home/fugurcal/freespace_torch/src/convnet.cpp:2:0: /home/fugurcal/freespace_torch/include/convnet.h:13:20: error: ‘BatchNorm2d’ is not a member of ‘torch::nn’ torch::nn::BatchNorm2d(16), ^~~~~~~~~~~ /home/fugurcal/freespace_torch/include/convnet.h:13:20: note: suggested alternative: ‘BatchNorm’ torch::nn::BatchNorm2d(16), ^~~~~~~~~~~ BatchNorm /home/fugurcal/freespace_torch/include/convnet.h:14:20: error: ‘ReLU’ is not a member of ‘torch::nn’ torch::nn::ReLU(), ^~~~ /home/fugurcal/freespace_torch/include/convnet.h:15:20: error: ‘MaxPool2d’ is not a member of ‘torch::nn’ torch::nn::MaxPool2d(torch::nn::MaxPool2dOptions(2).stride(2)) ^~~~~~~~~ /home/fugurcal/freespace_torch/include/convnet.h:15:41: error: ‘MaxPool2dOptions’ is not a member of ‘torch::nn’ torch::nn::MaxPool2d(torch::nn::MaxPool2dOptions(2).stride(2)) ^~~~~~~~~~~~~~~~ /home/fugurcal/freespace_torch/include/convnet.h:15:41: note: suggested alternative: ‘Conv2dOptions’ torch::nn::MaxPool2d(torch::nn::MaxPool2dOptions(2).stride(2)) ^~~~~~~~~~~~~~~~ Conv2dOptions /home/fugurcal/freespace_torch/include/convnet.h:16:5: error: could not convert ‘{torch::nn::Conv2d((* &(& torch::nn::ConvOptions<2>(1, 16, torch::ExpandingArray<2, long int>(5)).torch::nn::ConvOptions<2>::stride(torch::ExpandingArray<2, long int>(1)))->torch::nn::ConvOptions<2>::padding(torch::ExpandingArray<2, long int>(2)))), <expression error>, <expression error>, <expression error>}’ from ‘<brace-enclosed initializer list>’ to ‘torch::nn::Sequential’ }; ^ /home/fugurcal/freespace_torch/include/convnet.h:20:20: error: ‘BatchNorm2d’ is not a member of ‘torch::nn’ torch::nn::BatchNorm2d(32), ^~~~~~~~~~~ /home/fugurcal/freespace_torch/include/convnet.h:20:20: note: suggested alternative: ‘BatchNorm’ torch::nn::BatchNorm2d(32), ^~~~~~~~~~~ BatchNorm /home/fugurcal/freespace_torch/include/convnet.h:21:20: error: ‘ReLU’ is not a member of ‘torch::nn’ torch::nn::ReLU(), ^~~~ /home/fugurcal/freespace_torch/include/convnet.h:22:20: error: ‘MaxPool2d’ is not a member of ‘torch::nn’ torch::nn::MaxPool2d(torch::nn::MaxPool2dOptions(2).stride(2)) ^~~~~~~~~ /home/fugurcal/freespace_torch/include/convnet.h:22:41: error: ‘MaxPool2dOptions’ is not a member of ‘torch::nn’ torch::nn::MaxPool2d(torch::nn::MaxPool2dOptions(2).stride(2)) ^~~~~~~~~~~~~~~~ /home/fugurcal/freespace_torch/include/convnet.h:22:41: note: suggested alternative: ‘Conv2dOptions’ torch::nn::MaxPool2d(torch::nn::MaxPool2dOptions(2).stride(2)) ^~~~~~~~~~~~~~~~ Conv2dOptions /home/fugurcal/freespace_torch/include/convnet.h:23:5: error: could not convert ‘{torch::nn::Conv2d((* &(& torch::nn::ConvOptions<2>(16, 32, torch::ExpandingArray<2, long int>(5)).torch::nn::ConvOptions<2>::stride(torch::ExpandingArray<2, long int>(1)))->torch::nn::ConvOptions<2>::padding(torch::ExpandingArray<2, long int>(2)))), <expression error>, <expression error>, <expression error>}’ from ‘<brace-enclosed initializer list>’ to ‘torch::nn::Sequential’ }; ^ CMakeFiles/freespace_torch.dir/build.make:62: recipe for target 'CMakeFiles/freespace_torch.dir/src/convnet.cpp.o' failed make[2]: *** [CMakeFiles/freespace_torch.dir/src/convnet.cpp.o] Error 1 CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/freespace_torch.dir/all' failed make[1]: *** [CMakeFiles/freespace_torch.dir/all] Error 2 Makefile:83: recipe for target 'all' failed make: *** [all] Error 2 I know mentioned methods are member of torch::nn. How can I resolve this issue?
Issue solved. While making "cmake -DCMAKE_PREFIX_PATH=/absolute/path/to/libtorch .." my libtorch directory was "/home/user/folder/libtorch". After changing the libtorch directory to "/home/user/libtorch" issue solved.
rapidjson error: expected unqualified-id before 'bool' when building for Linux using Bazel
I'm compiling some C++ code that compiles fine for Android and iOS but fails under Linux. I've searched around and it looks like this kind of crash shows up when the implementer does something wrong; such as, using a reserved word. However I fail to see what I am doing wrong based on the error I'm getting. In file included from external/rapidjson_artifact/include/rapidjson/document.h:20:0, from src/main/cc/com/mycompany/serialization/JsonSerializer.h:4, from bazel-out/k8-dbg/genfiles/src/main/java/com/mycompany/model/common/cc/com /mycompany/model/common/Vector2d.h:13, from bazel-out/k8-dbg/genfiles/src/main/java/com/mycompany/model/common/cc/com/mycompany/model/common/FastVector2d.h:10, from src/main/cc/com/mycompany/api/gestures/primitives/CalculatedElementPosition.h:7, from src/main/cc/com/mycompany/api/gestures/primitives/PointerInteraction.h:7, from src/main/cc/com/mycompany/api/gestures/native/NativeUserInteractionHandler.h:10, from src/main/cc/com/mycompany/linux/api/gestures/UserInteractionHandler.h:4, from src/main/cc/com/mycompany/linux/api/opengl/OpenGlHandler.h:13, from src/main/cc/com/mycompany/linux/api/opengl/OpenGlHandler.cc:1: external/rapidjson_artifact/include/rapidjson/reader.h:189:15: error: expected unqualified-id before 'bool' bool Bool(bool) { return static_cast<Override&>(*this).Default(); } ^~~~ external/rapidjson_artifact/include/rapidjson/reader.h:189:15: error: expected ')' before 'bool' In file included from /usr/include/GL/glx.h:30:0, from src/main/cc/com/mycompany/linux/api/opengl/OpenGlHandler.h:7, from src/main/cc/com/mycompany/linux/api/opengl/OpenGlHandler.cc:1: external/rapidjson_artifact/include/rapidjson/reader.h: In member function 'void rapidjson::GenericReader<SourceEncoding, TargetEncoding, StackAllocator>::ParseTrue(InputStream&, Handler&)': external/rapidjson_artifact/include/rapidjson/reader.h:623:26: error: expected unqualified-id before 'int' if (!handler.Bool(true)) ^ external/rapidjson_artifact/include/rapidjson/reader.h:623:26: error: expected ')' before 'int' external/rapidjson_artifact/include/rapidjson/reader.h: In member function 'void rapidjson::GenericReader<SourceEncoding, TargetEncoding, StackAllocator>::ParseFalse(InputStream&, Handler&)': external/rapidjson_artifact/include/rapidjson/reader.h:636:26: error: expected unqualified-id before 'int' if (!handler.Bool(false)) ^ external/rapidjson_artifact/include/rapidjson/reader.h:636:26: error: expected ')' before 'int' external/rapidjson_artifact/include/rapidjson/document.h: In member function 'bool rapidjson::GenericValue<Encoding, Allocator>::Accept(Handler&) const': external/rapidjson_artifact/include/rapidjson/document.h:1539:44: error: expected unqualified-id before 'int' case kFalseType: return handler.Bool(false); ^ external/rapidjson_artifact/include/rapidjson/document.h:1539:44: error: expected ';' before 'int' external/rapidjson_artifact/include/rapidjson/document.h:1540:44: error: expected unqualified-id before 'int' case kTrueType: return handler.Bool(true); ^ external/rapidjson_artifact/include/rapidjson/document.h:1540:44: error: expected ';' before 'int' In file included from src/main/cc/com/mycompany/serialization/JsonSerializer.h:4:0, from bazel-out/k8-dbg/genfiles/src/main/java/com/mycompany/model/common/cc/com/mycompany/model/common/Vector2d.h:13, from bazel-out/k8-dbg/genfiles/src/main/java/com/mycompany/model/common/cc/com/mycompany/model/common/FastVector2d.h:10, from src/main/cc/com/mycompany/api/gestures/primitives/CalculatedElementPosition.h:7, from src/main/cc/com/mycompany/api/gestures/primitives/PointerInteraction.h:7, from src/main/cc/com/mycompany/api/gestures/native/NativeUserInteractionHandler.h:10, from src/main/cc/com/mycompany/linux/api/gestures/UserInteractionHandler.h:4, from src/main/cc/com/mycompany/linux/api/opengl/OpenGlHandler.h:13, from src/main/cc/com/mycompany/linux/api/opengl/OpenGlHandler.cc:1: external/rapidjson_artifact/include/rapidjson/document.h: At global scope: external/rapidjson_artifact/include/rapidjson/document.h:2028:15: error: expected unqualified-id before 'bool' bool Bool(bool b) { new (stack_.template Push<ValueType>()) ValueType(b); return true; } ^~~~ external/rapidjson_artifact/include/rapidjson/document.h:2028:15: error: expected ')' before 'bool' In file included from src/main/cc/com/mycompany/serialization/JsonSerializer.h:6:0, from bazel-out/k8-dbg/genfiles/src/main/java/com/mycompany/model/common/cc/com/mycompany/model/common/Vector2d.h:13, from bazel-out/k8-dbg/genfiles/src/main/java/com/mycompany/model/common/cc/com/mycompany/model/common/FastVector2d.h:10, from src/main/cc/com/mycompany/api/gestures/primitives/CalculatedElementPosition.h:7, from src/main/cc/com/mycompany/api/gestures/primitives/PointerInteraction.h:7, from src/main/cc/com/mycompany/api/gestures/native/NativeUserInteractionHandler.h:10, from src/main/cc/com/mycompany/linux/api/gestures/UserInteractionHandler.h:4, from src/main/cc/com/mycompany/linux/api/opengl/OpenGlHandler.h:13, from src/main/cc/com/mycompany/linux/api/opengl/OpenGlHandler.cc:1: external/rapidjson_artifact/include/rapidjson/writer.h:109:15: error: expected unqualified-id before 'bool' bool Bool(bool b) { Prefix(b ? kTrueType : kFalseType); return WriteBool(b); } ^~~~ external/rapidjson_artifact/include/rapidjson/writer.h:109:15: error: expected ')' before 'bool' All the errors point to rapidjson but I highly doubt that is the problem. It is probably something I'm doing wrong. Can someone suggest what I should look for to find the root cause?
/bin/sh: pkg-config: command not found
I'm trying to run hand gesture recognition openCV sample project from this link https://github.com/simena86/handDetectionCV. I run the make command in cygwin terminal, but i'm getting error. I run following command in cygwin terminal E:\handDetectionCVmaster\make Output: Arun#Arun-PC /cygdrive/e/handDetectionCVmaster $ make g++ -o opencv main.cpp myImage.cpp handGesture.cpp roi.cpp `pkg-config --cflags --libs opencv` /bin/sh: pkg-config: command not found main.cpp:1:39: error: opencv2/imgproc/imgproc.hpp: No such file or directory main.cpp:2:29: error: opencv2/opencv.hpp: No such file or directory main.cpp:3:39: error: opencv2/highgui/highgui.hpp: No such file or directory In file included from main.cpp:8: myImage.hpp:8: error: 'cv' is not a namespace-name myImage.hpp:8: error: expected namespace-name before ';' token myImage.hpp:15: error: 'Mat' does not name a type myImage.hpp:16: error: 'Mat' does not name a type myImage.hpp:17: error: 'Mat' does not name a type myImage.hpp:18: error: 'Mat' was not declared in this scope myImage.hpp:18: error: template argument 1 is invalid myImage.hpp:18: error: template argument 2 is invalid myImage.hpp:19: error: 'VideoCapture' does not name a type In file included from main.cpp:9: roi.hpp:9: error: 'cv' is not a namespace-name roi.hpp:9: error: expected namespace-name before ';' token roi.hpp:14: error: expected ')' before 'upper_corner' roi.hpp:15: error: 'Point' does not name a type roi.hpp:16: error: 'Mat' does not name a type roi.hpp:17: error: 'Scalar' does not name a type roi.hpp:19: error: 'Mat' has not been declared In file included from main.cpp:10: handGesture.hpp:11: error: 'cv' is not a namespace-name handGesture.hpp:11: error: expected namespace-name before ';' token handGesture.hpp:18: error: 'Point' was not declared in this scope handGesture.hpp:18: error: template argument 1 is invalid handGesture.hpp:18: error: template argument 2 is invalid handGesture.hpp:18: error: template argument 1 is invalid handGesture.hpp:18: error: template argument 2 is invalid handGesture.hpp:20: error: 'Point' was not declared in this scope handGesture.hpp:20: error: template argument 1 is invalid handGesture.hpp:20: error: template argument 2 is invalid handGesture.hpp:20: error: template argument 1 is invalid handGesture.hpp:20: error: template argument 2 is invalid handGesture.hpp:21: error: 'Vec4i' was not declared in this scope handGesture.hpp:21: error: template argument 1 is invalid handGesture.hpp:21: error: template argument 2 is invalid handGesture.hpp:21: error: template argument 1 is invalid handGesture.hpp:21: error: template argument 2 is invalid handGesture.hpp:22: error: 'Point' was not declared in this scope handGesture.hpp:22: error: template argument 1 is invalid handGesture.hpp:22: error: template argument 2 is invalid handGesture.hpp:23: error: 'Rect' does not name a type handGesture.hpp:24: error: 'Mat' has not been declared handGesture.hpp:29: error: 'Rect' does not name a type handGesture.hpp:44: error: 'Point' has not been declared handGesture.hpp:44: error: 'Point' has not been declared handGesture.hpp:44: error: 'Point' has not been declared handGesture.hpp:53: error: 'Scalar' does not name a type handGesture.hpp:55: error: 'Point' has not been declared handGesture.hpp:55: error: 'Point' has not been declared handGesture.hpp:56: error: 'Vec4i' was not declared in this scope handGesture.hpp:56: error: template argument 1 is invalid handGesture.hpp:56: error: template argument 2 is invalid main.cpp:15: error: 'cv' is not a namespace-name main.cpp:15: error: expected namespace-name before ';' token main.cpp:19: error: 'FONT_HERSHEY_PLAIN' was not declared in this scope
That means you miss the pkg-config installation. That is what is also causing the rest of the errors as the output of the pkg-config command could not be invoked, respectively. Go to the following url, grab it and install it: http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-config_0.26-1_win32.zip Please note that you might need to install further dependencies from that site, but then it oughta work, basically.
STL vector error: Unknown type name
I have this structure: struct casilla{ int x,y; }; And these lines of code; std::vector<std::vector<std::vector<casilla> > > iniciales; iniciales.resize(7); Wich give me this error in the g++ compiler: src/tetromino.cpp:5:1: error: unknown type name 'iniciales' iniciales.resize(7); ^ src/tetromino.cpp:5:10: error: expected unqualified-id iniciales.resize(7); Edit: I modified my code and now it's like this: std::vector<std::vector<std::vector<casilla> > > iniciales(7); for(int i=0; i<iniciales.size();i++){ iniciales[i].resize(3); for(int i=0; i<3;i++) iniciales[i][j].resize(4); } iniciales.at(TTR_CUADRADO){{{0,5},{0,6},{1,5},{1,6}}}; iniciales.at(TTR_LREVES)={{ {0,4},{0,5},{0,6},{1,6} }, {{-1,5},{0,5},{1,5},{1,4}}, {{0,4},{1,4},{1,5},{1,6}}, {{-1,5},{-1,6},{0,5},{1,5}} }; iniciales.at(TTR_L)={{{0,4}{0,5},{0,6},{1,4}},{{-1,5},{0,5},{1,5},{1,6}}, {{0,4},{0,5},{0,6},{-1,6}},{{-1,4},{-1,5},{0,5},{1,5}}}; iniciales.at(TTR_Z)={{{0,5},{0,6},{1,6},{1,7}},{{0,6},{1,6},{0,7},{-1,7},}}; iniciales.at(TTR_ZREVES)={{{0,6},{0,7},{1,5},{1,6}},{{0,6},{0,7},{-1,6},{1,7}}}; iniciales.at(TTR_I)={{{0,4},{0,5},{0,6},{0,7}},{{-2,6},{-1,6},{0,6},{1,6}}}; iniciales.at(TTR_T)={{{0,5},{0,6},{0,7},{1,6}}} for(int i=0; i<iniciales.size();i++){ for(int i=0; i<3;i++) iniciales[i][j].shrink_to_fit(); } } All the TTR* variables are enumerated values between 0 and 6. This is when the party starts: c++ -Wall -g -Iinclude -c src/tetromino.cpp -o obj/tetromino.o src/tetromino.cpp:5:1: error: expected unqualified-id for(int i=0; i<iniciales.size();i++){ ^ src/tetromino.cpp:10:2: error: unknown type name 'iniciales' iniciales.at(TTR_CUADRADO){{{0,5},{0,6},{1,5},{1,6}}}; ^ src/tetromino.cpp:10:11: error: expected unqualified-id iniciales.at(TTR_CUADRADO){{{0,5},{0,6},{1,5},{1,6}}}; ^ src/tetromino.cpp:11:1: error: unknown type name 'iniciales' iniciales.at(TTR_LREVES)={{ {0,4},{0,5},{0,6},{1,6} }, ^ src/tetromino.cpp:11:10: error: expected unqualified-id iniciales.at(TTR_LREVES)={{ {0,4},{0,5},{0,6},{1,6} }, ^ src/tetromino.cpp:16:1: error: unknown type name 'iniciales' iniciales.at(TTR_L)={{{0,4}{0,5},{0,6},{1,4}},{{-1,5},{0,5},{1,5},{1,6}}, ^ src/tetromino.cpp:16:10: error: expected unqualified-id iniciales.at(TTR_L)={{{0,4}{0,5},{0,6},{1,4}},{{-1,5},{0,5},{1,5},{1,6}}, ^ src/tetromino.cpp:18:1: error: unknown type name 'iniciales' iniciales.at(TTR_Z)={{{0,5},{0,6},{1,6},{1,7}},{{0,6},{1,6},{0,7},{-1,7},}}; ^ src/tetromino.cpp:18:10: error: expected unqualified-id iniciales.at(TTR_Z)={{{0,5},{0,6},{1,6},{1,7}},{{0,6},{1,6},{0,7},{-1,7},}}; ^ src/tetromino.cpp:19:1: error: unknown type name 'iniciales' iniciales.at(TTR_ZREVES)={{{0,6},{0,7},{1,5},{1,6}},{{0,6},{0,7},{-1,6},{1,7}}}; ^ src/tetromino.cpp:19:10: error: expected unqualified-id iniciales.at(TTR_ZREVES)={{{0,6},{0,7},{1,5},{1,6}},{{0,6},{0,7},{-1,6},{1,7}}}; ^ src/tetromino.cpp:20:1: error: unknown type name 'iniciales' iniciales.at(TTR_I)={{{0,4},{0,5},{0,6},{0,7}},{{-2,6},{-1,6},{0,6},{1,6}}}; ^ src/tetromino.cpp:20:10: error: expected unqualified-id iniciales.at(TTR_I)={{{0,4},{0,5},{0,6},{0,7}},{{-2,6},{-1,6},{0,6},{1,6}}}; ^ src/tetromino.cpp:21:1: error: unknown type name 'iniciales' iniciales.at(TTR_T)={{{0,5},{0,6},{0,7},{1,6}}} ^ src/tetromino.cpp:21:10: error: expected unqualified-id iniciales.at(TTR_T)={{{0,5},{0,6},{0,7},{1,6}}} ^ src/tetromino.cpp:22:1: error: expected unqualified-id for(int i=0; i<iniciales.size();i++){ ^ src/tetromino.cpp:26:1: error: extraneous closing brace ('}') } ^ src/tetromino.cpp:27:1: error: no template named 'vector'; did you mean 'std::vector'? vector<casilla> tetromino::Zonstd::aComun(vector<casillstd::a> v1,... ^~~~~~ std::vector /usr/include/c++/4.2.1/bits/stl_vector.h:162:11: note: 'std::vector' declared here class vector : protected _Vector_base<_Tp, _Alloc> ^ src/tetromino.cpp:27:28: error: no member named 'Zonstd' in 'tetromino' vector<casilla> tetromino::Zonstd::aComun(vector<casillstd::a> v1,... ~~~~~~~~~~~^ fatal error: too many errors emitted, stopping now [-ferror-limit=] What should I do? As #Jack is saying, i think it could be because I'm doind it outside any method. Should i make an specific method to set this global variable. Also I prefer to make a global variable rather than creating one each time I call a function. PS.:Sorry for the "weird" variable names, I'm programming in Spanish. :P
My guess is that you are trying to execute some code outside of a method, eg: #include <vector> std::vector<std::vector<std::vector<casilla> > > iniciales; iniciales.resize(7); while it should be #include <vector> std::vector<std::vector<std::vector<casilla> > > iniciales; void someMethod() { iniciales.resize(7); } or, even better: std::vector<std::vector<std::vector<casilla> > > iniciales(7);
Macports cgal not working! How do I fix it?
This is a basic example that I found on the CGAL main webpage. I am trying to compile the following: 1 #include <iostream> 2 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h> 3 #include <CGAL/convex_hull_2.h> 4 5 typedef CGAL::Exact_predicates_inexact_constructions_kernel K; 6 typedef K::Point_2 Point_2; 7 8 int main() 9 { 10 Point_2 points[5] = { Point_2(0,0), Point_2(10,0), Point_2(10,10), Point_2(6,5), Point_2(4,1) }; 11 Point_2 result[5]; 12 13 Point_2 *ptr = CGAL::convex_hull_2( points, points+5, result ); 14 std::cout << ptr - result << " points on the convex hull" << std::endl; 15 return 0; 16 } but I get this error: Demo $> make [100%] Building CXX object CMakeFiles/helloworld_cgal.dir/helloworld_cgal.cpp.o In file included from /opt/local/include/CGAL/Bbox_2.h:30, from /opt/local/include/CGAL/basic_classes.h:30, from /opt/local/include/CGAL/Cartesian/Cartesian_base.h:28, from /opt/local/include/CGAL/Simple_cartesian.h:27, from /opt/local/include/CGAL/Exact_predicates_inexact_constructions_kernel.h:27, from /Users/carlos/Documents/Code/Demo/helloworld_cgal.cpp:2: /opt/local/include/CGAL/array.h:81: error: expected nested-name-specifier before ‘...’ token /opt/local/include/CGAL/array.h:81: error: expected ‘>’ before ‘...’ token /opt/local/include/CGAL/array.h:83: error: template argument 2 is invalid /opt/local/include/CGAL/array.h:84: error: expected ‘,’ or ‘...’ before ‘&’ token /opt/local/include/CGAL/array.h:84: error: ISO C++ forbids declaration of ‘Args’ with no type /opt/local/include/CGAL/array.h: In function ‘int CGAL::make_array(const T&, int)’: /opt/local/include/CGAL/array.h:86: error: template argument 2 is invalid /opt/local/include/CGAL/array.h:86: error: invalid type in declaration before ‘=’ token /opt/local/include/CGAL/array.h:86: error: ‘args’ was not declared in this scope /opt/local/include/CGAL/array.h:86: error: expected `}' before ‘...’ token /opt/local/include/CGAL/array.h:86: error: expected `}' before ‘...’ token /opt/local/include/CGAL/array.h:86: error: expected ‘,’ or ‘;’ before ‘...’ token /opt/local/include/CGAL/array.h: At global scope: /opt/local/include/CGAL/array.h:87: error: expected unqualified-id before ‘return’ /opt/local/include/CGAL/array.h:88: error: expected declaration before ‘}’ token make[2]: *** [CMakeFiles/helloworld_cgal.dir/helloworld_cgal.cpp.o] Error 1 make[1]: *** [CMakeFiles/helloworld_cgal.dir/all] Error 2 make: *** [all] Error 2 I installed cgal using macports. Does anyone know what could be wrong with this?
Indeed it looks like a mismatch between compiler or compiler options used when building CGAL and compiling with CGAL. It may be that macports doesn't help, I have been luckier with homebrew than macports when installing CGAL.