g++

why g++ shows “gets()” not declared ,even after including <cstdio>

让人想犯罪 __ 提交于 2020-02-16 08:39:32
问题 #include <cstdio> #include <cstring> #include <iostream> using namespace std; int main() { char str[30]; gets(str); } when i use gets () function compiler gives me the following error error: 'gets' was not declared in this scope i was using G++ with geany ide please make the solution simple cuz iam a beginner. 回答1: gets was deprecated in C++11 and removed from C++14. If you are using GCC6.0 or newer then by default it uses C++14 and won't be available. Instead of using main() { char str[30];

I get this error: “glibc detected”

会有一股神秘感。 提交于 2020-02-11 06:43:29
问题 I just wrote a piece of CPP code and I compiled it using G++ in ubuntu. When I run my code everything is fine, the code runs well and gives output but doesn't exit and it gives this error: *** glibc detected *** ./a.out: free(): invalid next size (fast): 0x09f931f0 *** ======= Backtrace: ========= /lib/libc.so.6(+0x6c501)[0x3de501] /lib/libc.so.6(+0x6dd70)[0x3dfd70] /lib/libc.so.6(cfree+0x6d)[0x3e2e5d] /usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0x6e2441] ./a.out[0x8049ce6] /lib/libc.so.6(+0x2f69e)

I get this error: “glibc detected”

廉价感情. 提交于 2020-02-11 06:42:15
问题 I just wrote a piece of CPP code and I compiled it using G++ in ubuntu. When I run my code everything is fine, the code runs well and gives output but doesn't exit and it gives this error: *** glibc detected *** ./a.out: free(): invalid next size (fast): 0x09f931f0 *** ======= Backtrace: ========= /lib/libc.so.6(+0x6c501)[0x3de501] /lib/libc.so.6(+0x6dd70)[0x3dfd70] /lib/libc.so.6(cfree+0x6d)[0x3e2e5d] /usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0x6e2441] ./a.out[0x8049ce6] /lib/libc.so.6(+0x2f69e)

How can I compile c++ on (64bit) windows to make a 64bit exe?

≯℡__Kan透↙ 提交于 2020-02-05 07:27:51
问题 Using the g++ compiler that came with code::blocks I can compile 32bit programmes but when I try to compile to a 64bit programme it tells me that 64 bit isn't implemented, even though I have 64bit os. How can I compile c++ to make a 64bit exe? 回答1: Download Microsoft Visual C++, and set the target to 64-bit. Why make programming harder than it needs to be? 回答2: If you are not limited to gcc, you can use Microsoft's compiler from Visual Studio Express 2010 with Windows SDK (both are free) and

Linker errors with codelite, unittest++ and g++ on linux

北城余情 提交于 2020-02-04 05:20:29
问题 I'm new to unit testing in c++, and writing c++ on Linux (Mint). I'm using CodeLite as my IDE. I have found several answers on stackoverflow about linker errors, but after hours of trying various solutions I have not succeeded in implementing a solution correctly. I installed unittest++ through apt-get. The unittest++ header files were installed in /usr/include, so I added this to the Compiler linker options in Codelite (Right click project name->Settings, Compiler): Codelite screenshot I

is extern “C” required in C files ? (to solve odd Eclipse behaviour)

佐手、 提交于 2020-02-03 11:38:47
问题 I am relatively new to Mixed C/C++ applications using the gcc and g++ tools. To get the hand of it I have downloaded the iperf source code and built it with success using Eclipse. There is one oddity: If I look into the file "Thread.c" using Eclipse it thinks there is a syntax error and underlines almost the whole file as if the code is flawed, which it is absolutely not. This is the piece of code that triggers it: #ifdef __cplusplus extern "C" { #endif I know what extern "C" is used for in C

CCfits library demo code not working

谁说胖子不能爱 提交于 2020-02-02 13:39:05
问题 I'm new to C++. Ultimately, I'm trying to translate some code from python in order to perform analysis on some simulations of supernovae. However, in order to do this, I have to be able to import .fits files into my C++ code as an array. I downloaded the cfitsio and ccfits libraries, and they appear to be installed correctly given that a simple code consisting of an #include <CCfits> and an int main with a print statement in it compiles and runs. However, taking the demo code from NASA (http:

How to suppress warnings in Qt Creator

大憨熊 提交于 2020-02-01 03:09:46
问题 I'm wondering if it is possible to suppress compiler specific warnings in Qt-Creator. My g++-4.5 prints: warning: enumeral and non-enumeral type in conditional expression I would like to get rid of it, because it's very annoying. Ubuntu 11.04 x64 g++-4.5 QtCreator 2.01 Qt 4.7 Thank you! 回答1: You need to use this: QMAKE_CXXFLAGS += -Wno-enum-compare if you get a warning that ends in -Wenum-compare , for example. Also, note that some warnings cannot be suppressed as per the GCC documentation

what is the json-spirit linker flag for g++?

有些话、适合烂在心里 提交于 2020-01-29 23:38:30
问题 I can't find this anywhere. I've installed json-spirit on my ubuntu server with apt-get install json-spirit-dev . What linker flag has to be used with g++ to use json-spirit? 回答1: The only library listed in that package is called libjson_spirit.a . You can link with it by adding -ljson_spirit to your linker step. 来源: https://stackoverflow.com/questions/17437893/what-is-the-json-spirit-linker-flag-for-g

GCC Cross compile to a i586 architecture (Vortex86DX)

北城余情 提交于 2020-01-28 10:22:47
问题 I have Ubuntu 12.01 with gcc 4.8.2 and would like to cross compile for the Vortex86DX CPU running an old 2.6.23 kernel. I´m trying the following testing code: #include <iostream> int main() { std::cout << "Hello world" << std::endl; } That is compiled using the following command line: g++ -static-libgcc -static-libstdc++ -march=i586 test.cpp -otest586 When I run the test586 on the target architecture I´m getting this error: $ ./test586 ./teste586: symbol lookup error: ./test586: undefined