Compiling a C++ program with GCC

gcc can actually compile C++ code just fine. The errors you received are linker errors, not compiler errors. Odds are that if you change the compilation line to be this: gcc info.C -lstdc++ which makes it link to the standard C++ library, then it will work just fine. However, you should just make your life … Read more

How to specify preference of library path?

Add the path to where your new library is to LD_LIBRARY_PATH (it has slightly different name on Mac …) Your solution should work with using the -L/my/dir -lfoo options, at runtime use LD_LIBRARY_PATH to point to the location of your library. Careful with using LD_LIBRARY_PATH – in short (from link): ..implications..: Security: Remember that the … Read more

gcc/g++: “No such file or directory”

Your compiler just tried to compile the file named foo.cc. Upon hitting line number line, the compiler finds: #include “bar” or #include <bar> The compiler then tries to find that file. For this, it uses a set of directories to look into, but within this set, there is no file bar. For an explanation of … Read more

Different floating point result with optimization enabled – compiler bug?

Intel x86 processors use 80-bit extended precision internally, whereas double is normally 64-bit wide. Different optimization levels affect how often floating point values from CPU get saved into memory and thus rounded from 80-bit precision to 64-bit precision. Use the -ffloat-store gcc option to get the same floating point results with different optimization levels. Alternatively, … Read more

How do I enable C++11 in gcc?

H2CO3 is right, you can use a makefile with the CXXFLAGS set with -std=c++11 A makefile is a simple text file with instructions about how to compile your program. Create a new file named Makefile (with a capital M). To automatically compile your code just type the make command in a terminal. You may have … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)