LINUX and STUFF

All about linux inside, networking, programming,server,tutorials, Open Source resources software and hardware and the other stuff.

Saturday, March 25, 2006

Library types

Two types of libraries exist on most operating systems: shared and static. On Windows, they are .DLL, for dynamically linked library, and .LIB for static library.
On Linux and most Unix, they are .so and .a files. The shared libraries, the .so files, are loaded at runtime. The .a files, or static libraries, are loaded at compile time and are no longer required to run the binary program. When you make a program, you must decide if you will link it to a static library or a shared one. You will want a shared library in most cases because standard libraries are available on most systems, and would be too big to include in a binary file.
If you have a small library that is not one of the standard ones that you need, then you may decide to include it in your binary program. In that case, simply add it like any other object file in your compilation:
cc -o program file1.o file2.o library.a

keyword : shared static library
 
Web www.linuxscience.blogspot.com
Graphical toolkits

Most Unix programs are console based. This is mainly because several years ago, most computer users were on text-only stations linked to big mainframes. Now, Linux is becoming a full graphical desktop, and needs graphical programs, or at least frontends to text-only programs. This is where graphical tookits come in. Here is a list of some of the toolkits available to Linux programmers:
· GTK - This is currently a very popular toolkit, and is the base of the GNOME desktop. It is C
based and easy to work with.
· QT - QT is a C++ toolkit made by Troll Tech. It is the base of the popular KDE desktop. · WXwindows - This is a very complete C++ toolkit that is cross-platform. The same code should work on Windows, the MacOS, Unix (Motif and GTK) and others.
· GraphApp - This is also a cross-platform toolkit, but is one of the easiest libraries I ever saw. It supports a smaller set of widgets, but takes only hours to learn. It will work on Windows, the
MacOS, Unix (Motif and Athena) and others.

keyword : gtk,qt,graphapp
 
Web www.linuxscience.blogspot.com
Segmentation fault

One of the most common problems when making software is errors like "Segmentation fault", also called SegFault. Here is what a SegFault is. Virtual memory in a computer can be created in 2 ways: pages or segments. Paging means that the memory is divided in pages of equal size, containing words of memory in it. Segmentation means that every process has a segment of memory of needed size, with gaps of empty memory blocks between the segments.
The operating system knows the upper limit of every segment, and every segment begins at a virtual address 0. When a program accesses a memory block, it calls a virtual address that the Memory Management Unit (MMU) maps to a real address. If the operating system sees that the requested address doesn't match any valid address in the segment, it will send a signal to the process terminating it. SegFaults are the direct result of a memory error. The program has a bad pointer, a memory leak or any kind of error that makes it access the wrong memory address. To correct these errors you need to check pointers and arrays for errors.

keyword : virtual memory,mmu
 
Web www.linuxscience.blogspot.com
Using PASCAL on Linux

Linux comes with a lot of compilers and interpreters. These include programs for C, C++, Perl, TCL/TK and more. Unfortunately most Linux distributions don't come with a Pascal compiler. Is it possible to compile Pascal programs? It sure is.
Several projects were started to make a Pascal compiler for Linux. One is called GNU Pascal and is available from http://agnes.dida.physik.uni-essen.de/~gnu-pascal. That program will also run on any operating system that supports the GNU C compiler.

keyword : fpc, gnu pascal
 
Web www.linuxscience.blogspot.com
Makefile don't equal C

Makefiles are used in most Unix C or even C++ programs. But nowhere does it say that they can't be used for other languages. Make is a program installed with most Linux distributions, and on most Unix systems too.
Makefiles make your program portable, and easy to compile. These files can be used in C, C++, Java, and any program that requires compilation. Make has so many useful applications. Feel free to explore them for your programs.

keyword : makefile howto
 
Web www.linuxscience.blogspot.com
Speed problems on a PPP connection

PPPd is the PPP connection daemon. It will try to connect to a server using a specified speed. The default speed is 38400. If you use a serial connection, or a 56.7Kbps modem, it may not be enough. If you want to use all the available bandwidth, you need to increase that number. For example, for a serial connection, you want the speed set at 115200.
Another reason for speed drops is unwanted packets. You may want to filter unwanted packets out of your network, like some ICMP messages and chat connections. A last possibility for speed drops is Denial of Service attacks. DoS attacks are unfortunately very real and they occur a lot. Malicious people that can't handle their problems elsewhere turn to the Internet and launch attacks against networks. An attack against one user will always affect several thousands of people. By using bandwidth of an Internet provider to cause trouble to any one user, the whole provider will be affected. To prevent such attacks, firewalls exist, and tracking tools were invented to deal with abusers. MCI has a tool called DoSTrack that can be of help if you are victim of such an attack. For more information about various DoS attacks, you should search the Web.

keyword : ppp
 
Web www.linuxscience.blogspot.com
Linux without a hard drive

Modern Linux distributions require around 100 megs to 200 megs of hard disk space to install. But is it possible to run Linux on a system without a hard drive? Yes it is.
The Linux Router Project is a full-featured Linux distribution that fits on one diskette. It was made for routers, and use modules to add the software packages you need, including DNS servers, Web servers, email and routing. You can find more information on the Linux Router Project at http://www.linuxrouter.org.

keyword : linux router project
 
Web www.linuxscience.blogspot.com
Added processors

Dual processors are becoming more and more popular in computers. Of course, you won't be able to see much performance increase in Linux unless you tell Linux about the second CPU. Here is how to do it.
Go in the kernel, and enable SMP. SMP means Symetric Multi-Processing and tells the kernel that more than one processor can be used. After a reboot, Linux should tell you that it has detected 2 processors and what their status are.

keyword : smp
 
Web www.linuxscience.blogspot.com
Use Windows special keys in Linux

Why are all the new keyboards sold with Win95 keys on them? How about making them do real keyboard functions while in X Window? Here is how.
First you need to find out which key mapping you are using. Usually it will be US, it might also be en_US, ca or else. Locate the file, usually in /usr/X11/lib/X11/xkb and edit it with your favorite editor. For me the file is called /usr/X11/lib/X11/xkb/symbols/ca.
The file lists all the key codes and what they do. The key codes for the Win95 special keys are LWIN, RWIN and MENU. All you need to do is add them to the list, with the functions for them. I decided to map the leftWIN key to "@" and the right WIN key and MENU keys to "{" and "}". Here are the lines I added:
key { [ braceleft ] };
key { [ at ] };
key
{ [ braceright ] };
By browsing the file you can find all the other symbols and what they do. You can also add multiple functions to a key, by using ALT and SHIFT.The changes will take effect when you restart X Window. With the XKB extension (you do need to have it enabled in /etc/XF86Config btw) it's easy to change the mapping of any key.

keyword : special key in linux

 
Web www.linuxscience.blogspot.com
Everything on sound cards

A sound card can be easy or hard to detect. It depends on who made it. Many Sound Blaster Compatible cards in fact are not compatible with the Linux Sound Blaster driver. Other cards will be compatible with a driver you would never have thought of.
There are multiple drivers for Linux. Currently the kernel comes with its own set of sound drivers, plus the OSS/Free drivers. These will support most generic cards. In the installation program, or when compiling your kernel, you can pick the sound card that matches yours, or the one that matches the chipset on your sound card (for example, the Sound Blaster PCI64 card uses the AudioPCI chipset).
If your sound card is not supported by the kernel, you will need to get another driver. 2 popular ones are ALSA available from http://alsa.jcu.cz and OSS/Linux available from http://www.opensound.com OSS/Linux is a commercial product that supports a lot of cards not available in other drivers because of card specification restrictions. You will need to see the list of supported cards in each driver and pick the driver you need.

keyword : alsa
 
Web www.linuxscience.blogspot.com