g++-4.7

C++ program compilation fails in Ubuntu, but works in MacOSX

拟墨画扇 提交于 2020-01-05 21:21:29
问题 Hi I've a program written in C++. When I compile it in Mac terminal with g++ compiler, it compiles and runs. But when I compile the same C++ program in Ubuntu terminal with g++ compiler, it Fails. I don't know why it happens. g++ compiler version in Ubuntu is 4.7.3. Here is my code sample #include <iostream> using namespace std; #define IXSIZE 400 #define IYSIZE 400 #define IZSIZE 3 void putbyte(FILE *outf, unsigned char val) { unsigned char buf[1]; buf[0] = val; fwrite(buf,1,1,outf); } void

ofstream not working on linux

a 夏天 提交于 2020-01-04 03:27:14
问题 i have a simple test code: #include <string> #include <iostream> #include <fstream> int main() { std::ofstream strm = std::ofstream("test.txt"); strm << "TEST123"; strm.close(); return 0; } if i compile this on windows it works perfectly. however when i compile it on debian with the following command: g++-4.7 -std=c++0x -lpthread TestStream.cpp -ldl -o TestStream than it gives the following output: i have googled this error to no avail. does anybody know how to fix this? i use a lot of

ofstream not working on linux

丶灬走出姿态 提交于 2020-01-04 03:27:08
问题 i have a simple test code: #include <string> #include <iostream> #include <fstream> int main() { std::ofstream strm = std::ofstream("test.txt"); strm << "TEST123"; strm.close(); return 0; } if i compile this on windows it works perfectly. however when i compile it on debian with the following command: g++-4.7 -std=c++0x -lpthread TestStream.cpp -ldl -o TestStream than it gives the following output: i have googled this error to no avail. does anybody know how to fix this? i use a lot of

Is OpenMP (parallel for) in g++ 4.7 not very efficient? 2.5x at 5x CPU

我怕爱的太早我们不能终老 提交于 2019-12-24 16:43:14
问题 I've tried using OpenMP with a single #pragma omp parallel for , and it resulted in my programme going from a runtime of 35s (99.6% CPU) to 14s (500% CPU) , running on Intel(R) Xeon(R) CPU E3-1240 v3 @ 3.40GHz. That's the difference between compiling with g++ -O3 and g++ -O3 -fopenmp , both with gcc (Debian 4.7.2-5) 4.7.2 on Debian 7 (wheezy). Why is it only using 500% CPU at most, when the theoretical maximum would be 800%, since the CPU is 4 core / 8 threads? Shouldn't it be reaching at

unique_ptr member, private copy constructor versus move constructor

感情迁移 提交于 2019-12-22 09:12:26
问题 Given a base class for multiple derived class, the goal was to create a wrapper class that allowed an STL container to see objects with the base interface, event though different derived classes may actually be added to the container. (See Retrieve data from heterogeneous std::list). After some tinkering, I came up with a new derived class that was a wrapper around a unique_ptr to the base class. However, the move constructor has me confused. class Base { friend class BaseWrapper; virtual

call of overloaded ‘Point_(cv::Point2f&)’ is ambiguous

半世苍凉 提交于 2019-12-10 21:19:11
问题 I am working on some example code for OpenCV2 & C++ and I got stuck. Compiler (MinGW, g++ 4.7.2 on Win7) says that call of overloaded ‘Point_(cv::Point2f&)’ is ambiguous but I can't find exatcly what is wrong. Here is error: 18:09:33 **** Incremental Build of configuration Debug for project Blobs **** Info: Internal Builder is used for build g++ "-IC:\\OpenCV246PC\\build\\include" -O0 -g3 -Wall -c -fmessage-length=0 -o blobs.o "..\\blobs.cpp" ..\blobs.cpp: In function ‘int main()’: ..\blobs

OpenMP: don't use hyperthreading cores (half `num_threads()` w/ hyperthreading)

[亡魂溺海] 提交于 2019-12-07 06:15:40
问题 In Is OpenMP (parallel for) in g++ 4.7 not very efficient? 2.5x at 5x CPU, I determined that the performance of my programme varies between 11s and 13s (mostly always above 12s, and sometimes as slow as 13.4s) at around 500% CPU when using the default #pragma omp parallel for , and the OpenMP speed up is only 2.5x at 5x CPU w/ g++-4.7 -O3 -fopenmp , on a 4-core 8-thread Xeon. I tried using schedule(static) num_threads(4) , and noticed that my programme always completes in 11.5s to 11.7s

unique_ptr member, private copy constructor versus move constructor

纵然是瞬间 提交于 2019-12-05 18:15:30
Given a base class for multiple derived class, the goal was to create a wrapper class that allowed an STL container to see objects with the base interface, event though different derived classes may actually be added to the container. (See Retrieve data from heterogeneous std::list ). After some tinkering, I came up with a new derived class that was a wrapper around a unique_ptr to the base class. However, the move constructor has me confused. class Base { friend class BaseWrapper; virtual Base * clone () const = 0; public: virtual ~Base () {} //... public interface }; class Derived : public

OpenMP: don't use hyperthreading cores (half `num_threads()` w/ hyperthreading)

丶灬走出姿态 提交于 2019-12-05 08:58:14
In Is OpenMP (parallel for) in g++ 4.7 not very efficient? 2.5x at 5x CPU , I determined that the performance of my programme varies between 11s and 13s (mostly always above 12s, and sometimes as slow as 13.4s) at around 500% CPU when using the default #pragma omp parallel for , and the OpenMP speed up is only 2.5x at 5x CPU w/ g++-4.7 -O3 -fopenmp , on a 4-core 8-thread Xeon. I tried using schedule(static) num_threads(4) , and noticed that my programme always completes in 11.5s to 11.7s (always below 12s) at about 320% CPU, e.g., runs more consistently, and uses less resources (even if the

Nested class member access on C++11

给你一囗甜甜゛ 提交于 2019-11-29 08:55:37
In C++11, I am trying to access a member variable of an enclosing class from a nested class in the following way: struct Enclosing { int a; struct Nested { int f() { return a; } }; }; Even this doesn't compile using g++4.7.2 with -std=c++11, producing error messages of this form: error: invalid use of non-static data member 'Enclosing::a' As far as I understand, C++11 treats a nested class as a member of the class, so that supposedly a nested class can access every other member of the enclosing class. Did I do something wrong? Thanks in advance. Update: While my question seems to have an