g++

How to stop a program compiled with MinGW (g++) from opening a console window in windows

拥有回忆 提交于 2019-12-27 14:44:09
问题 I compiled a program using MinGW g++. When I run it, it opens a console window in addition to the main application window. What's the compiler flag to stop this? 回答1: I believe the compiler switch for that is -Wl,-subsystem,windows . The -Wl,<options> switch passes <options> to the linker. The -subsystem switch tells the linker which system to target when generating the executable. 回答2: I just add -mwindows to linker flags. 来源: https://stackoverflow.com/questions/4441551/how-to-stop-a-program

g++ linking order dependency when linking c code to c++ code

南笙酒味 提交于 2019-12-27 11:24:07
问题 Prior to today I had always believed that the order that objects and libraries were passed to g++ during the linking stage was unimportant. Then, today, I tried to link from c++ code to c code. I wrapped all the C headers in an extern "C" block but the linker still had difficulties finding symbols which I knew were in the C object archives. Perplexed, I created a relatively simple example to isolate the linking error but much to my surprise, the simpler example linked without any problems.

How to change/control the output precision in gcc or g++?

你离开我真会死。 提交于 2019-12-25 18:32:35
问题 I have the following piece of code written in c++ and compiled by g++ 4.8. double x = 0.123456789; cout << x << endl; I don't understand why I only get the output 0.1234567 even I define x as long double x . It probably a quite naive question, but can any one give me some hits? 回答1: Use the precision function or the setprecision manipulator to set the number of significant figures (or decimal places, if you also use fixed ). cout.precision(10); // 10 significant figures or cout <<

Code execution breaking during recursion

末鹿安然 提交于 2019-12-25 17:08:15
问题 In a pattern of single alphabet in an image I've written a small function which will start from any pixel and traverse all the contiguous pixels. In short in a matrix it will turn on all the contiguous pixels to true and rest will be zero. This function has done it correctly. However with little change in input pattern it is behaving abnormally. I'm finding that this line onwards: //process left-up diagonally is not getting called. What could be the reason? Also valgrind shows no memory

Problem with class template specialisations

人走茶凉 提交于 2019-12-25 16:24:13
问题 I'm trying to port some code from VC9 to G++, however Ive run into a problem with template specialisations apparently not being allowed for class members. The following code is an example of these errors for the getValue specialisations of the class methods. In all cases the error is "error: explicit specialization in non-namespace scope class ... " template<typename T> T getValue(const_iterator key)const { try{return boost::lexical_cast<T>(key->second);} catch(boost::bad_lexical_cast &e) {

C++ Code Stability between different g++ versions

空扰寡人 提交于 2019-12-25 11:34:07
问题 We've been trying to track down some strange behavior in our large legacy app for the past few months. It suffers from random and occasional memory corruption, vtable corruption (??), and other strange and random behavior like infinite loops in std::rbl_tree, std::map, and even std::string s = "abcd". The target machine is 32-bit Centos 6 so we started with the built-in g++ 4.4 but address sanitizer wasn't available, so moved to 4.8 in devtoolset-2 and now have compiled gcc 4.9 from source.

Connecting c++ program with Oracle

落花浮王杯 提交于 2019-12-25 08:59:08
问题 I'm trying to connect my C++ program to Oracle database(12.2). My C++ program is (I am using g++ compiler in ubuntu), #include <occi.h> #include <iostream> using namespace std; int main() { oracle::occi::Environment *env = oracle::occi::Environment::createEnvironment(); oracle::occi::Connection *conn = env->createConnection("bsk", "oraclepass"); env->terminateConnection(conn); oracle::occi::Environment::terminateEnvironment(env); } I'm getting the error undefined reference to `oracle::occi:

Code blocks Ver.16.01 crashing during run cycle of programme

不羁的心 提交于 2019-12-25 08:20:05
问题 I have a program which has been proved to run on an older version of codeblocks (ver 13.12) but does not seem to work when I try it on the newer version (ver 16.01). The purpose of the programme is to enter two integers which will then be added, mult etc. It uses asm code which I am new at. My question is why does it say windows has stopped responding after I type 2 integers and press enter? Here is the code: //Program 16 #include <stdio.h> #include <iostream> using namespace std; int main()

c++ linux ifstream read csv file

别来无恙 提交于 2019-12-25 05:33:13
问题 void Lexicon::buildMapFromFile(string filename ) //map { ifstream file; file.open(filename.c_str() ); string wow, mem, key; unsigned int x = 0; while(true) { getline(file, wow); if (file.fail()) break; //check for error while (x < wow.length() ) { if (wow[x] == ',') { key = mem; mem.clear(); x++; //step over ',' } else mem += wow[x++]; } list_map0.put(key, mem); //char to string list_map1.put(mem, key); //string to char mem.clear(); //reset memory x = 0;//reset index } file.close(); } This

c++ linux ifstream read csv file

蹲街弑〆低调 提交于 2019-12-25 05:33:06
问题 void Lexicon::buildMapFromFile(string filename ) //map { ifstream file; file.open(filename.c_str() ); string wow, mem, key; unsigned int x = 0; while(true) { getline(file, wow); if (file.fail()) break; //check for error while (x < wow.length() ) { if (wow[x] == ',') { key = mem; mem.clear(); x++; //step over ',' } else mem += wow[x++]; } list_map0.put(key, mem); //char to string list_map1.put(mem, key); //string to char mem.clear(); //reset memory x = 0;//reset index } file.close(); } This