For a project I am working on I wanted to try out the following program: 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.
The laptop running Mac OS that managed to compile the code without problems used the following g++ version:
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:
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
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.
Hopefully someone with more experience in C++ can point out what might have gone wrong. Thanks!
GCC compiler is used to compile and run a C program on the Linux operating system. Visual Studio Code editor comes with a pre-integrated terminal, so it is easy to run and compile C programs in Linux on the Visual Studio Code editor.
The Unix command for compiling C code is gcc. This is a compiler from Gnu for Linux. If you are using a Unix machine like Solaris you may need to use the command cc.) When you compile your program the compiler produces a file containing binary code which is directly readable by the machine you are on.
In our mac systems, we already have a compiler, i.e., clang installed. We will install a code editor, i.e., visual studio code, in our mac environment. Let's see how to install C on mac and work with it.
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
vector<vector<XX> >
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With