For a project I am working on I wanted to try out the following program: http://sourceforge.net/projects/tirg/
对于我正在研究的项目,我想尝试以下程序:http://sourceforge.net/projects/tirg/
It consists of two C++ files, but I cannot get it to compile on my laptop running Linux, while it compiles without any problem on the laptop of a friend of mine running Mac OS. I have no experience whatsoever in compiling C++ code, so it might be a beginners mistake.
它由两个C ++文件组成,但我无法在运行Linux的笔记本电脑上进行编译,而在我的朋友运行Mac OS的笔记本电脑上编译没有任何问题。我没有任何编译C ++代码的经验,所以它可能是初学者的错误。
The laptop running Mac OS that managed to compile the code without problems used the following g++ version:
运行Mac OS的笔记本电脑设法编译代码没有问题使用以下g ++版本:
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
I tried compiling the C++ files using gcc, g++, clang and clang++ on my laptop running Arch LInux (64 bit) with the following versions:
我尝试在运行Arch LInux(64位)的笔记本电脑上使用gcc,g ++,clang和clang ++编译C ++文件,其中包含以下版本:
gcc and g++ (GCC) 4.8.1 20130725 (prerelease)
clang version 3.3 (tags/RELEASE_33/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
The error I get when compiling it is:
编译时得到的错误是:
/usr/include/c++/4.8.1/bits/stl_vector.h:1240:36: error: no matching function for call to ‘std::vector<std::vector<unsigned char> >::_M_fill_assign(int&, int&)’
{ _M_fill_assign(__n, __val); }
^
Which was caused by this line of code:
这是由这行代码引起的:
std::vector<std::vector<trg::Rgb> > a(300, 255);
I have put the complete output of the compilation on pastebin: http://pastebin.com/m285PSrH
我已将汇编的完整输出放在pastebin上:http://pastebin.com/m285PSrH
I also had problems when compiling OpenCV, so there is probably something wrong with my configuration. I think it is a versioning problem, a wrong version of the standard library for example.
我在编译OpenCV时也遇到了问题,因此我的配置可能有问题。我认为这是版本问题,例如标准库的错误版本。
Hopefully someone with more experience in C++ can point out what might have gone wrong. Thanks!
希望有更多C ++经验的人可以指出可能出错的地方。谢谢!
2 个解决方案
#1
2
The i686-apple-darwin11-llvm-g++-4.2 does it wrong. You would get an 2D vector of vectors if an implicit conversion is possible. However [23.3.6.2]:
i686-apple-darwin11-llvm-g ++ - 4.2做错了。如果可以进行隐式转换,您将获得向量的2D向量。但[23.3.6.2]:
explicit vector(size_type n);
显式向量(size_type n);
You may do:
你可能会这样做:
struct Rgb {};
int main() {
std::vector<Rgb> rgb_vector(255);
std::vector<std::vector<Rgb> > a(300, rgb_vector);
return 0;
}
#2
5
std::vector<std::vector<trg::Rgb> > a(300, 255);
has no sense. you wanted to write something like this:
毫无意义。你想写这样的东西:
//std::vector<std::vector<trg::Rgb> > a(picHeight, picWidth);
std::vector<std::vector<trg::Rgb> > a;
a.resize(picWidth);
{
std::vector<std::vector<trg::Rgb> >::iterator end = a.end();
std::vector<std::vector<trg::Rgb> >::iterator it = a.begin();
for(; it != end; ++it)
it->resize(picHeight);
}
you should correct each assign() in your code and each call to constructor of
你应该纠正你的代码中的每个assign()和每次调用构造函数
vector<vector<XX> >
#1
2
The i686-apple-darwin11-llvm-g++-4.2 does it wrong. You would get an 2D vector of vectors if an implicit conversion is possible. However [23.3.6.2]:
i686-apple-darwin11-llvm-g ++ - 4.2做错了。如果可以进行隐式转换,您将获得向量的2D向量。但[23.3.6.2]:
explicit vector(size_type n);
显式向量(size_type n);
You may do:
你可能会这样做:
struct Rgb {};
int main() {
std::vector<Rgb> rgb_vector(255);
std::vector<std::vector<Rgb> > a(300, rgb_vector);
return 0;
}
#2
5
std::vector<std::vector<trg::Rgb> > a(300, 255);
has no sense. you wanted to write something like this:
毫无意义。你想写这样的东西:
//std::vector<std::vector<trg::Rgb> > a(picHeight, picWidth);
std::vector<std::vector<trg::Rgb> > a;
a.resize(picWidth);
{
std::vector<std::vector<trg::Rgb> >::iterator end = a.end();
std::vector<std::vector<trg::Rgb> >::iterator it = a.begin();
for(; it != end; ++it)
it->resize(picHeight);
}
you should correct each assign() in your code and each call to constructor of
你应该纠正你的代码中的每个assign()和每次调用构造函数
vector<vector<XX> >