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. ...


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

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 ...


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.


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

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 ...


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

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

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 ...


3

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.


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

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 ...


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

I'm sure there will be a difference in speed over a network, but I'm not sure it will be enough to make your decision. It may only be a minor annoyance from time to time. However, I would emphasize point number 1, especially for coding. Here are some things I use VERY often in vim when I'm coding: comment/uncomment blocks of code all at once (using block ...


2

Generally you should look for the documentation of a command in its man page: man g++. In the case of GNU software such as GCC, you'll usually find more complete documentation in info format, or in HTML on the software home page. C (and C++) compilers have a somewhat peculiar syntax that doesn't heed the usual conventions for options (options come before ...


2

You might find the OpenSUSE Build Service useful; there are packages in the devel:gcc project. I believe if you add the URL http://download.opensuse.org/repositories/devel:/gcc/openSUSE_11.2/ to your YaST configuration, you ought to be able to install those packages. (Though the status on the website looks broken, I wonder how long that'll be..) All that ...


2

Taglib is quite feature rich. It comes as C++ lib without dependencies to Qt or KDE libs. A C API is bundled (and there are a lot of other languages bindings available). A lot of projects (like amarok, juk, vlc ...) use this library. The homepage contains some claims some advantages of taglib over id3lib (mainly performance).


2

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 ...


2

gcc is both a C and C++ compiler. It will look at the file's extension and process accordingly. g++ is only a wrapper that calls gcc g++ is installed with the gcc package in Arch gcc file.C # uppercase .C (or .cpp) will process as C++ gcc file.c # lowercase .c will process as C


2

You can develop with the Qt SDK on all the distros where it is available (and compile the open source edition often enough when it's not directly packaged, provided you can use that license). What the primary desktop environment is based on is largely irrelevant (you could develop non-GUI Qt apps on a headless server if you felt like it). What you can ...


2

All programs receive an array of strings as its arguments. In C++, the arguments are the argv parameter of the main function. The first element of that array is the name of the program, the others are the arguments that you pass. $ cat foo.cpp #include <iostream> int main (int argc, char *argv[]) { for (int i = 1; i < argc; i++) ...


2

The message already installed and latest version is referring to the latest version of the RPM (binary package) for the version of Fedora. It appears that you are using Fedora 12, which is quite outdated. Your best course of action is likely to upgrade to the latest version of Fedora first, then you will have a more recent version of GCC available (4.7.2). ...


1

Besides what was said above, your teacher's advice is trying to create your habits for the future. You can always get a CLI interface on Linux/Unix, and it will be consistent, unlike GUIs which won't be always available (e.g. on a server) or might differ from what you're used to. So I'd go with vim, which, as said before, will be there almost anywhere, and, ...


1

Here the simplest analogue of lsusb: #include <stdio.h> #include <usb.h> main(){ struct usb_bus *bus; struct usb_device *dev; usb_init(); usb_find_busses(); usb_find_devices(); for (bus = usb_busses; bus; bus = bus->next) for (dev = bus->devices; dev; dev = dev->next){ printf("Trying device ...


1

Here's a (quick-and-dirty) shell script that might help you. Adjust the output format to something that's easy to parse for you. Finding the right icon could use some improvement to select the highest resolution image. Maybe there is a better way to get the optimal icon using gconftool or something, I don't know. #!/bin/sh ...


1

To be able to run application without specifying whole path to it, directory where executable is installed must be in $PATH variable. You can check what is in $PATH by using echo $PATH. To modify $PATH you can use export PATH=$PATH:/usr/lib64/qt4/bin/. After that you can use just moc to start it. To make changes permanent you may put that line to your ...


1

one claiming that the common convention for internal strings in international applications in Linux is UTF-32 This is probably a reference to the fact that GCC defines wchar_t as a UTF-32 character, unlike Windows C(++) compilers that define wchar_t = UTF-16 (for compatibility with Windows WCHAR). You could use wchar_t internally if that's convenient ...


1

The best way to compare text files is with the diff command: diff output1.txt output1.txt For a mass comparison, you can call diff in a loop: for x in input*.txt; do slow-program <"$x" >"$x.out-slow" fast-program <"$x" >"$x.out-fast" diff "$x.out-slow" "$x.out-fast" done If the snippet above produces any output, your fast program is ...


1

Assuming you compiled your programs as prog1 and prog2, and that they produce their output on stdout, you could do something like this: #! /bin/bash for input in input*.txt ; do ./prog1 $input > $input.out1 ./prog2 $input > $input.out2 if cmp $input.out1 $input.out2 > /dev/null ; then echo Programs disagreed on $input else echo ...



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