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.
Related
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.
When I run the following code on ubuntu(gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4)):
#include<iostream>
#include<vector>
#include<list>
using namespace std;
int main(){
vector <int> v;
v.push_back(1);
v.push_back(2);
v.push_back(3);
v.push_back(4);
v.push_back(5);
list<int> temp;
for(auto i:v){
cout<<i<<" ";
temp.push_back(i);
}
for(auto i:temp){
cout<<i<<" ";
}
}
I get the following errors:
try.cpp: In function ‘int main()’:
try.cpp:13:10: error: ‘i’ does not name a type
for(auto i:v){
^
try.cpp:17:1: error: expected ‘;’ before ‘for’
for(auto i:temp){
^
try.cpp:17:1: error: expected primary-expression before ‘for’
try.cpp:17:1: error: expected ‘;’ before ‘for’
try.cpp:17:1: error: expected primary-expression before ‘for’
try.cpp:17:1: error: expected ‘)’ before ‘for’
try.cpp:17:10: error: ‘i’ does not name a type
for(auto i:temp){
^
try.cpp:20:1: error: expected ‘;’ before ‘}’ token
}
^
try.cpp:20:1: error: expected primary-expression before ‘}’ token
try.cpp:20:1: error: expected ‘;’ before ‘}’ token
try.cpp:20:1: error: expected primary-expression before ‘}’ token
try.cpp:20:1: error: expected ‘)’ before ‘}’ token
try.cpp:20:1: error: expected primary-expression before ‘}’ token
But when I run the code on online ide I works fine.
What is the problem with the code?
The link for code on online ide:No errors
Your code uses some of the C++11 features such as range based loops and auto specifier but you don't compile for the C++11 standard. You need to enable the C++11 support by including the -std=c++11 flag when compiling:
g++ -std=c++11 -o try try.cpp
The online compiler has this enabled by using the -std=gnu++1z flag.
I am trying to use the quickfix library to connect to a broker using the FIX protocol. I just built the library using the documentation they provide and use their sample code right now
#include "quickfix/FileStore.h"
#include "quickfix/FileLog.h"
#include "quickfix/SocketAcceptor.h"
#include "quickfix/Session.h"
#include "quickfix/SessionSettings.h"
#include "quickfix/Application.h"
int main( int argc, char** argv )
{
try
{
if(argc < 2) return 1;
std::string fileName = argv[1];
FIX::SessionSettings settings(fileName);
MyApplication application;
FIX::FileStoreFactory storeFactory(settings);
FIX::FileLogFactory logFactory(settings);
FIX::SocketAcceptor acceptor
(application, storeFactory, settings, logFactory /*optional*/);
acceptor.start();
// while( condition == true ) { do something; }
acceptor.stop();
return 0;
}
catch(FIX::ConfigError& e)
{
std::cout << e.what();
return 1;
}
}
However, when I try to compile it with:
g++ fix.cpp -fexceptions -finline-functions -lquickfix -lpthread -lxml2
I get a bunch of errors:
In file included from /usr/local/include/quickfix/Session.h:34:0,
from fix.cpp:6:
/usr/local/include/quickfix/DataDictionaryProvider.h:54:72: error: ‘ptr::shared_ptr’ has not been declared
void addTransportDataDictionary(const BeginString& beginString, ptr::shared_ptr<DataDictionary>);
^
/usr/local/include/quickfix/DataDictionaryProvider.h:54:82: error: expected ‘,’ or ‘...’ before ‘<’ token
void addTransportDataDictionary(const BeginString& beginString, ptr::shared_ptr<DataDictionary>);
^
/usr/local/include/quickfix/DataDictionaryProvider.h:55:70: error: ‘ptr::shared_ptr’ has not been declared
void addApplicationDataDictionary(const ApplVerID& applVerID, ptr::shared_ptr<DataDictionary>);
^
/usr/local/include/quickfix/DataDictionaryProvider.h:55:80: error: expected ‘,’ or ‘...’ before ‘<’ token
void addApplicationDataDictionary(const ApplVerID& applVerID, ptr::shared_ptr<DataDictionary>);
^
/usr/local/include/quickfix/DataDictionaryProvider.h:63:25: error: ‘shared_ptr’ is not a member of ‘ptr’
std::map<std::string, ptr::shared_ptr<DataDictionary> > m_transportDictionaries;
^
/usr/local/include/quickfix/DataDictionaryProvider.h:63:25: error: ‘shared_ptr’ is not a member of ‘ptr’
/usr/local/include/quickfix/DataDictionaryProvider.h:63:55: error: template argument 2 is invalid
std::map<std::string, ptr::shared_ptr<DataDictionary> > m_transportDictionaries;
^
/usr/local/include/quickfix/DataDictionaryProvider.h:63:55: error: template argument 4 is invalid
/usr/local/include/quickfix/DataDictionaryProvider.h:63:57: error: expected unqualified-id before ‘>’ token
std::map<std::string, ptr::shared_ptr<DataDictionary> > m_transportDictionaries;
^
/usr/local/include/quickfix/DataDictionaryProvider.h:64:25: error: ‘shared_ptr’ is not a member of ‘ptr’
std::map<std::string, ptr::shared_ptr<DataDictionary> > m_applicationDictionaries;
^
/usr/local/include/quickfix/DataDictionaryProvider.h:64:25: error: ‘shared_ptr’ is not a member of ‘ptr’
/usr/local/include/quickfix/DataDictionaryProvider.h:64:55: error: template argument 2 is invalid
std::map<std::string, ptr::shared_ptr<DataDictionary> > m_applicationDictionaries;
^
/usr/local/include/quickfix/DataDictionaryProvider.h:64:55: error: template argument 4 is invalid
/usr/local/include/quickfix/DataDictionaryProvider.h:64:57: error: expected unqualified-id before ‘>’ token
std::map<std::string, ptr::shared_ptr<DataDictionary> > m_applicationDictionaries;
^
/usr/local/include/quickfix/DataDictionaryProvider.h: In member function ‘void FIX::DataDictionaryProvider::addTransportDataDictionary(const FIX::BeginString&, const string&)’:
/usr/local/include/quickfix/DataDictionaryProvider.h:58:45: error: ‘shared_ptr’ is not a member of ‘ptr’
{ addTransportDataDictionary(beginString, ptr::shared_ptr<DataDictionary>( new DataDictionary(path) )); }
^
/usr/local/include/quickfix/DataDictionaryProvider.h:58:75: error: expected primary-expression before ‘>’ token
{ addTransportDataDictionary(beginString, ptr::shared_ptr<DataDictionary>( new DataDictionary(path) )); }
^
/usr/local/include/quickfix/DataDictionaryProvider.h: In member function ‘void FIX::DataDictionaryProvider::addApplicationDataDictionary(const FIX::ApplVerID&, const string&)’:
/usr/local/include/quickfix/DataDictionaryProvider.h:60:45: error: ‘shared_ptr’ is not a member of ‘ptr’
{ addApplicationDataDictionary(applVerID, ptr::shared_ptr<DataDictionary>( new DataDictionary(path) )); }
^
/usr/local/include/quickfix/DataDictionaryProvider.h:60:75: error: expected primary-expression before ‘>’ token
{ addApplicationDataDictionary(applVerID, ptr::shared_ptr<DataDictionary>( new DataDictionary(path) )); }
^
fix.cpp: In function ‘int main(int, char**)’:
fix.cpp:19:5: error: ‘MyApplication’ was not declared in this scope
MyApplication application;
^
fix.cpp:19:19: error: expected ‘;’ before ‘application’
MyApplication application;
^
fix.cpp:23:8: error: ‘application’ was not declared in this scope
(application, storeFactory, settings, logFactory /*optional*/);
^
root#luis:/home/luis/tradingbot/bot4# In file included from /usr/local/include/quickfix/Session.h:34:0,
In: command not found
root#luis:/home/luis/tradingbot/bot4# from fix.cpp:6:
from: can't read /var/mail/fix.cpp:6:
root#luis:/home/luis/tradingbot/bot4# /usr/local/include/quickfix/DataDictionaryProvider.h:54:72: error: ‘ptr::shared_ptr’ has not been declared
bash: /usr/local/include/quickfix/DataDictionaryProvider.h:54:72:: No such file or directory
root#luis:/home/luis/tradingbot/bot4# void addTransportDataDictionary(const BeginString& beginString, ptr::shared_ptr<DataDictionary>);
bash: syntax error near unexpected token `('
root#luis:/home/luis/tradingbot/bot4# ^
^: command not found
root#luis:/home/luis/tradingbot/bot4# /usr/local/include/quickfix/DataDictionaryProvider.h:54:82: error: expected ‘,’ or ‘...’ before ‘<’ token
bash: ’: No such file or directory
root#luis:/home/luis/tradingbot/bot4# void addTransportDataDictionary(const BeginString& beginString, ptr::shared_ptr<DataDictionary>);
bash: syntax error near unexpected token `('
root#luis:/home/luis/tradingbot/bot4# ^
^: command not found
root#luis:/home/luis/tradingbot/bot4# /usr/local/include/quickfix/DataDictionaryProvider.h:55:70: error: ‘ptr::shared_ptr’ has not been declared
bash: /usr/local/include/quickfix/DataDictionaryProvider.h:55:70:: No such file or directory
What am I doing wrong?
You need to provide an implementation of the MyApplication class and compile with the appropriate C++11 flags.
Your MyApplication object typically needs to derive from the FIX::Application class which is a pure virtual class and will require you to implement a series of methods such as onLogon(...) and toApp(...)
If you want to just get your code to compile as a first step you can try using the FIX::NullApplication class (defined in quickfix/Application.h) as your starting application object.
The quickfix library must be compiled with this pre-processor directive HAVE_STD_UNIQUE_PTR
Your application must provide an implementation for the MyApplication class and that implementation must inherit from FIX::Application
So all I am trying to do is compile my program with opencv-2.3 . This is all under the assumtion that I installed everything correctly.
My Main is super simple:
#include <iostream>
#include <opencv/cv.h>
int main(int argv, char** argc){
std::cout << "Hello World" << std::endl;
return 0;
}
My MakeFile is super simple.
g++ main.cpp `pkg-config opencv --cflags --libs`
And the error is really confusing:
make
g++ main.cpp \
`pkg-config opencv --cflags --libs`
In file included from /usr/include/c++/4.6/bits/stl_algo.h:62:0,
from /usr/include/c++/4.6/algorithm:63,
from /usr/local/include/opencv2/core/core.hpp:56,
from /usr/local/include/opencv/cv.h:64,
from main.cpp:8:
/usr/include/c++/4.6/bits/algorithmfwd.h:358:41: error: macro "max" passed 3 arguments, but takes just 2
/usr/include/c++/4.6/bits/algorithmfwd.h:369:41: error: macro "min" passed 3 arguments, but takes just 2
In file included from /usr/include/c++/4.6/bits/stl_algo.h:62:0,
from /usr/include/c++/4.6/algorithm:63,
from /usr/local/include/opencv2/core/core.hpp:56,
from /usr/local/include/opencv/cv.h:64,
from main.cpp:8:
/usr/include/c++/4.6/bits/algorithmfwd.h:354:5: error: expected unqualified-id before ‘const’
/usr/include/c++/4.6/bits/algorithmfwd.h:354:5: error: expected ‘)’ before ‘const’
/usr/include/c++/4.6/bits/algorithmfwd.h:354:5: error: expected ‘)’ before ‘const’
/usr/include/c++/4.6/bits/algorithmfwd.h:354:5: error: expected initializer before ‘const’
/usr/include/c++/4.6/bits/algorithmfwd.h:358:5: error: template declaration of ‘const _Tp& std::max’
/usr/include/c++/4.6/bits/algorithmfwd.h:365:5: error: expected unqualified-id before ‘const’
/usr/include/c++/4.6/bits/algorithmfwd.h:365:5: error: expected ‘)’ before ‘const’
/usr/include/c++/4.6/bits/algorithmfwd.h:365:5: error: expected ‘)’ before ‘const’
/usr/include/c++/4.6/bits/algorithmfwd.h:365:5: error: expected initializer before ‘const’
/usr/include/c++/4.6/bits/algorithmfwd.h:369:5: error: template declaration of ‘const _Tp& std::min’
In file included from /usr/include/c++/4.6/algorithm:63:0,
from /usr/local/include/opencv2/core/core.hpp:56,
from /usr/local/include/opencv/cv.h:64,
from main.cpp:8:
/usr/include/c++/4.6/bits/stl_algo.h: In function ‘void std::__merge_sort_loop(_RandomAccessIterator1, _RandomAccessIterator1, _RandomAccessIterator2, _Distance)’:
/usr/include/c++/4.6/bits/stl_algo.h:3285:26: error: expected unqualified-id before ‘(’ token
/usr/include/c++/4.6/bits/stl_algo.h: In function ‘void std::__merge_sort_loop(_RandomAccessIterator1, _RandomAccessIterator1, _RandomAccessIterator2, _Distance, _Compare)’:
/usr/include/c++/4.6/bits/stl_algo.h:3308:26: error: expected unqualified-id before ‘(’ token
In file included from /usr/local/include/opencv2/core/core.hpp:59:0,
from /usr/local/include/opencv/cv.h:64,
from main.cpp:8:
/usr/include/c++/4.6/complex: In function ‘_Tp std::__complex_abs(const std::complex<_Tp>&)’:`
/usr/include/c++/4.6/complex:571:28: error: expected unqualified-id before ‘(’ token
In file included from /usr/include/c++/4.6/vector:65:0,
from /usr/local/include/opencv2/core/core.hpp:63,
from /usr/local/include/opencv/cv.h:64,
from main.cpp:8:
/usr/include/c++/4.6/bits/stl_vector.h: In member function ‘std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::_M_check_len(std::vector<_Tp, _Alloc>::size_type, const char*) const’:
/usr/include/c++/4.6/bits/stl_vector.h:1244:40: error: expected unqualified-id before ‘(’ token
In file included from /usr/include/c++/4.6/vector:66:0,
from /usr/local/include/opencv2/core/core.hpp:63,
from /usr/local/include/opencv/cv.h:64,
from main.cpp:8:
/usr/include/c++/4.6/bits/stl_bvector.h: In member function ‘std::vector<bool, _Alloc>::size_type std::vector<bool, _Alloc>::_M_check_len(std::vector<bool, _Alloc>::size_type, const char*) const’:
/usr/include/c++/4.6/bits/stl_bvector.h:1026:45: error: expected unqualified-id before ‘(’ token
Now when I hit pkg-config --cflags --libs opencv in the terminal I get the correct place where all the libs and the .hpp and other files. So I have no idea what is going on here.
Thanks for the help!!
It might be caused by using the old, C headers. The new ones are located in <opencv2/opencv.hpp> if I remember correctly.
I am getting this error during compile time (g++ 4.4.6):
main.cpp: In function ‘int main()’:
main.cpp:27: error: expected initializer before ‘:’ token
main.cpp:33: error: expected primary-expression before ‘for’
main.cpp:33: error: expected ‘;’ before ‘for’
main.cpp:33: error: expected primary-expression before ‘for’
main.cpp:33: error: expected ‘)’ before ‘for’
main.cpp:33: error: expected initializer before ‘:’ token
main.cpp:36: error: could not convert ‘((list != 0u) ? (list->SortedList::~SortedList(), operator delete(((void*)list))) : 0)’ to ‘bool’
main.cpp:37: error: expected primary-expression before ‘return’
main.cpp:37: error: expected ‘)’ before ‘return’
My code is as follows:
#include <iostream>
#include "Student.h"
#include "SortedList.h"
using namespace std;
int main() {
SortedList *list = new SortedList();
Student create[100];
int num = 100000;
for (Student &x : create) { // <--Line 27
x = new Student(num);
num += 10;
}
for (Student &x : create)
list->insert(&x);
delete list;
return 0;
}
Anybody who possibly knows the source of the error would be of great help. Also, Student and SortedList are objects which are declared in their .h files.
According to this page on GCC's website, range-based for is only available in g++ 4.6 and up, so you'll have to convert your code to a normal for loop or use std::for_each or something, or upgrade your compiler.