Tag Info

Hot answers tagged

14

You're right that you'll end up with the same executable at the end (albeit with a different name); in the first case gcc will actually create a bunch of temporary object files that it removes after linking, versus the second case where you're making the object files yourself. The main reason to do things the second way is to allow for incremental building. ...


13

There have been many discussions about this. Mainly, the reason is a philosophical one. C was invented as a simple language for system development (not so much application development). There are many arguments for using C++, but there are about as many for not using C++ and sticking to C. In the end, it's a historical issue. Most application stuff is ...


11

You may want to read from cin to get a poor man’s pause – it will wait for you to type an Enter, rather than resuming while you’re getting coffee (as sleep() will).


9

At a guess, you copied it over with a utility that doesn't preserve file modes. Try chmod +x.


8

Here is a breakdown of the command. First the original command, for reference g++ -Wall -I/usr/local/include/thrift *.cpp -lthrift -o something Now, for the breakdown. g++ This is the actual command command, g++. It is the program that is being executed. Here is what it is, from the man page: gcc - GNU project C and C++ compiler This is a ...


8

Every standard conforming compiler should come with STL, as it is part of the standard library. The first standard was finalized in 1998, so unless you are using a really old system, it should be available. All you need to do is use the proper #includes. #include <vector> std::vector<int> v;


7

For developing C/C++ you need the gcc compiler, which is included in most Linux distributions or can be easily installed. There is not a default IDE: most people use their favorite editor (vim, emacs, Geany etc...) and there are IDEs like Eclipse or KDevelop available. C# can be done with Mono, but it is not fully compatible with .NET: check the ...


6

Use -mtune. -march is used to determine the allowed instruction set, whereas -mtune is to be used to tune performance of the code (as always, see man gcc). Depending on the precise CPU type, you might also consider values other than core2. And if you use a recent GCC version (at least 4.4, I think), you might best use native instead.


6

For external representations, UTF-8 is definitely the standard. Some 8-bit encodings are still strong (mostly in Europe) and some 16-bit encodings are still strong (mostly in East Asia), but they are clearly legacy encodings, on their slow way out. UTF-8 is standard not only on unix, but also on the web. For internal representations, there's no such ...


6

Same thing for cout/cerr, and you can just use sleep() - see man 3 sleep or man 3 usleep for more info.


5

This has more to do with C and C++ than Unix, and as such belongs to SO. To answer your question, the <> indicates headers in the standard library and "" the libraries written specifically for the project. From the K&R: Any source line of the form #include "filename" or #include <filename> is replaced by the contents ...


5

Depends - if you actually develope kernel space drivers that use mutexes and semaphores you should give the patches a quick review. As developer that is your responsibility, no answer on a website will solve that issue. If you are mainly developing userspace software, these changes do not affect you, as you only wrangle with the kernel interfaces, which are ...


5

From this answer to "Install gcc 4.7 on CentOS [6.x]", the easiest way to get g++ 4.7, and the required tools and libraries, for CentOS 5.x is via the devtools package: cd /etc/yum.repos.d wget http://people.centos.org/tru/devtools/devtools.repo yum --enablerepo=testing-devtools-6 install devtoolset-1.0 Since you're running g++ manually (as opposed to ...


5

The Cross compiler article on wikipedia is quite good. Generally a cross compiler is a compiler producing code for a different kind of system than yours. Usually this means a different target hardware architecture, but it can also mean a different target operating system (or both). Theoretically you could combine these and use a cross-compiler on ...


5

The main entry point is God. Be it a C or C++ source file, it is the center of the application. Only in the same way that nitrogen is the center of a pine tree. It is where everything starts, but there's nothing about C or C++ that makes you put the "center" of your application in main(). A great many C and C++ programs are built on an event loop or an ...


5

On Debian derived systems you can get the source (even as a non root user) using apt-get source provided sources.list has some deb-src entries. Otherwise it's stuck with downloading from the project source repository with standard tools. Once you've got that source then: ./configure --prefix=/home/me/mysoftware make make install Will work for most source ...


5

I have also .1 as I can see from the content it is used for manual Yes, these are written in groff markup. They aren't compiled, they're interpreted at runtime via man or some other viewer (using groff as a backend). The .1 actually denotes the manual section (see man man). When an executable is installed into an element of the system's executable ...


4

I guess all you need is a package providing the g++ command (plus all the dependencies, of course).


4

This is just a partial answer, since your question is fairly broad. C++ defines an "execution character set" (in fact, two of them, a narrow and a wide one). When your source file contains something like: char s[] = "Hello"; Then the numeric byte value of the letters in the string literal are simply looked up according to the execution encoding. (The ...


4

It's probably killed by kernel's oom killer. dmesg should contain information about it. Sorry, but you may need to redesign your algorithm.


4

libstdc++ 3 is not the default libstdc++ anymore. You can still install it, though it is best to do so with your distro package util. I'm assuming your BOINC client is for your arch, x86_64, and not compiled for x86. The difference is significant in resolving dependency issues. Considering you are on a regular user account, you should theoretically be ...


4

On a Ubuntu system, you can install the c++ compiler along with common development libraries with the build-essential package. This is a meta package that depends on the following: libc6-dev | libc-dev, gcc, g++, make, dpkg-dev This is the base of what is needed for compiling C and C++. Other development libraries can be installed as-needed.


4

Run it on a decicated computer just for these tasks or in virtual.


4

preamble you probably don't want to invest time into preventing people from disassembling your code: instead focus on making your project better, so that once your competitors have figured out how you did feature X, your software already has feature Y... the reasoning is simple: if you have a dull project, then nobody will care to disassemble it and you ...


4

I typically will use xev to determine the key's scancode and then map it to whatever action I want using either xdotool or XBindKeys. xev $ xev | grep -A2 --line-buffered '^KeyRelease' \ | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p' After running the above xev command you'll get a little white window that'll pop up. You'll ...


4

I sometimes resort to this #define BRK do { printf("%s %d\n", __FILE__, __LINE__); getchar(); } while (0) ... BRK(); // Stop and wait for enter Also, function instrumentation might help: GCC allows to hook into every function enter/exit, see http://stackoverflow.com/questions/2281739/automatically-adding-enter-exit-function-logs-to-a-project


3

Stay with gcc compiler and Vim as an IDE. There are a lot of plugins for Vim that improves the experience in almost coding languages, but you should learn Vim first if you want to take advantage of that though. On the other side, I think just a few "firms" are naming "C#" and "Linux" in the same context.


3

Run gcc -M to generate the list of header files used by a given source file, or gcc -MM to omit system headers. The output is in a makefile format, since the option is intended to generate the build dependencies of that source file. There are ways to tweak the output format, see the available preprocessor options in the GCC manual. The default output looks ...


3

Well, if no-one else is writing answer for this question (instead of valid comments), I'll do it. bootchart.org is tool for doing exactly this. Bootchart is a tool for performance analysis and visualization of the GNU/Linux boot process. There is rather good page explaining how it works: Bootchart - How it works?. In short, it's wrapper for normal ...


3

If you just want to change the program's configuration, the typical method of doing that is to update its conf file, then send it a SIGHUP signal, which it is programmed to respond to by reloading its conf file ( see signal(7) ). As Coren said, you typically have the program store its pid in a file in /var/run when it starts so you can later send it the ...



Only top voted, non community-wiki answers of a minimum length are eligible