there is a pdf file with this post,
Software Development
software development notes, main category for Cs, Java, and other programming experiences.
qt how to add new library
Projects > right click , 1>> ADD library ,
pro .file adding libs,
INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/lib/x86_64-linux-gnu -I/usr/lib/x86_64-linux-gnu -I/usr/lib/x86_64-linux-gnu -I/usr/share/qt4/mkspecs/linux-g++ -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I. -I../Kutuphane_icin_method_test_projesi -I.
#INCPATH = -I/usr/share/qt4/mkspecs/linux-g++ -I/usr/include/qt4/QtCore -I/usr/include/qt4 -I. -I../Kutuphane_icin_method_test_projesi -I.
#LINK = g++
#LFLAGS = -Wl,-O1
#LIBS = $(SUBLIBS) -L/usr/lib/x86_64-linux-gnu -lQtCore -lpthread -lcurl
LINK = g++
LFLAGS = -Wl,-O1
LIBS = $(SUBLIBS) -L/home/sus/Documents/VS2010/C_Projects/Kutuphane_icin_method_test_projesi/../../../../../../usr/lib/x86_64-linux-gnu/ -lQtCore -lQtGui -lQtDesignerComponents -L/usr/lib/x86_64-linux-gnu -lQtCore -lpthread -lcurl
Code::Blocks Settings for Qt Development , Linker, Search Directories
Qt is a cross-platform object oriented C++ framework for application development. KDE is written using Qt. And not surprisingly, KDE comes with native support for building Qt based applications. In KDE, KDevelop is the default IDE under Linux for creating Qt based applications. For smaller projects however, it seems that the feature richness of KDevelop is almost an overkill.
I personally like simplicity of Code::Blocks when writing small programs. Even though Code::Blocks does come with Qt support, you will have to tell it where Qt is installed before you can compile your code correctly. Like any other C++ environment, the two things you must provide are the include path and the linker path.
Install Qt4, please follow the instructions here. Here are the build options you need to add with the default Qt4 install:
As a bare minimum, you will need to set the libQtGui and libQtCore libraries paths. Note thatUbuntu 8.04 comes with Qt3 installed, when you specify the libraries you need to make sure you specify the ones with the correct version. In my example, the required Qt4 libraries are /usr/lib/libQtGui.so.4 and /usr/lib/libQtCore.so.4. You also need to specify where the include files can be found. For typical applications, /ur/incude/qt4 and /usr/include/qt4/QtGui are the paths you will need. If you want contextual help to be available, you will have to provide the search paths for the include files under “C/C++ parser options” tab in Project/targets options settings.
error “extra qualification ‘student::’ on member ‘student’ [-fpermissive] ”
I am getting an error extra qualification ‘student::’ on member ‘student’ [-fpermissive]
.
And also why name::name
such syntax is used in constructor?
#include
#include
using namespace std;
class student
{
private:
int id;
char name[30];
public:
/* void read()
{
cout<<"enter id"<>id;
cout<<"enter name"<>name;
}*/
void show()
{
cout<
SOLUTION ..
In-class definitions of member function(s)/constructor(s)/destructor don't require qualification such asstudent::
.
So this code,
student::student()
{
id=0;
strcpy(name,"undefine");
}
should be this:
student()
{
id=0;
strcpy(name,"undefine");
}
The qualification student::
is required only if you define the member functions outside the class, usually in .cpp file.
How to simple make file configuration
For Click : >> Download file Here : Make_file_ch01
The mechanics of programming usually follow a fairly simple routine of editing
source files, compiling the source into an executable form, and debugging the result.
Although transforming the source into an executable is considered routine, if done
incorrectly a programmer can waste immense amounts of time tracking down the
problem. Most developers have experienced the frustration of modifying a function
and running the new code only to find that their change did not fix the bug. Later
they discover that they were never executing their modified function because of some
procedural error such as failing to recompile the source, relink the executable, or
rebuild a jar. Moreover, as the program’s complexity grows these mundane tasks can
become increasingly error-prone as different versions of the program are developed,
perhaps for other platforms or other versions of support libraries, etc.
The make program is intended to automate the mundane aspects of transforming
source code into an executable. The advantages of make over scripts is that you can
specify the relationships between the elements of your program to make, and it knows
through these relationships and timestamps exactly what steps need to be redone to
produce the desired program each time. Using this information, make can also opti-
mize the build process avoiding unnecessary steps.
GNU make (and other variants of make) do precisely this. make defines a language for
describing the relationships between source code, intermediate files, and executa-
bles. It also provides features to manage alternate configurations, implement reus-
able libraries of specifications, and parameterize processes with user-defined macros.
In short, make can be considered the center of the development process by providing
a roadmap of an application’s components and how they fit together.
The specification that make uses is generally saved in a file named makefile. Here is a
makefile to build the traditional “Hello, World” program:
hello: hello.c
gcc hello.c -o hello
To build the program execute make by typing:
$ make
3
at the command prompt of your favorite shell. This will cause the make program to
read the makefile and build the first target it finds there:
$ make
gcc hello.c -o hello
If a target is included as a command-line argument, that target is updated. If no com-
mand-line targets are given, then the first target in the file is used, called the default
goal.
Typically the default goal in most makefiles is to build a program. This usually
involves many steps. Often the source code for the program is incomplete and the
source must be generated using utilities such as flex or bison. Next the source is
compiled into binary object files (.o files for C/C++, .class files for Java, etc.). Then,
for C/C++, the object files are bound together by a linker (usually invoked through
the compiler, gcc) to form an executable program.
Modifying any of the source files and reinvoking make will cause some, but usually
not all, of these commands to be repeated so the source code changes are properly
incorporated into the executable. The specification file, or makefile, describes the
relationship between the source, intermediate, and executable program files so that
make can perform the minimum amount of work necessary to update the executable.
So the principle value of make comes from its ability to perform the complex series of
commands necessary to build an application and to optimize these operations when
possible to reduce the time taken by the edit-compile-debug cycle. Furthermore, make
is flexible enough to be used anywhere one kind of file depends on another from tra-
ditional programming in C/C++ to Java, TEX, database management, and more.
Tracking of Humans Using Masked Histograms and Mean Shift
semafors
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide] Производитель и Потребитель буфера ПРОИЗВОДИТЕЛЬ БУФЕРА, prod_onebuf.c : /* producer program: producer program sets up a buffer to be read by a consumer semaphores are used to ensure that producer doesn't overwrite an unread buffer and consumer doesn't the same data more than once. */ #include <sys/types.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <sys/ipc.h> #include <sys/sem.h> #include <sys/shm.h> #define MSG_SIZE 30 #define MAX 5 main() { key_t key; /* two semaphores in a set index 0 -incremented when producer has reset buffer -tested and decremented by consumer to check if buffer has been reset index 1 -incremented when consumer has read buffer -tested and decremented by producer to check if consumer is done */ static struct sembuf wait_consumed = { 1, -1, 0}; static struct sembuf signal_produced = { 0, 1, 0}; int semid, shmid, i; char *message; if((key = ftok( getenv("HOME"), 'u')) == -1){ fprintf(stderr,"ftok key formation error\n"); exit(1); } if((semid=semget(key, 2, IPC_CREAT | 0660)) == -1){ perror("producer semget():"); exit(2); } if((shmid=shmget(key, MSG_SIZE, IPC_CREAT | 0660)) == -1) { perror("producer shmget():"); exit(3); } message=shmat(shmid, 0, 0); for(i=1; i < MAX; i++) { /* producer has to go first */ if(i > 1) semop(semid,&wait_consumed,1); sprintf(message, "message %d", i); semop(semid, &signal_produced, 1); } shmdt(message); sleep(5); /* allow consumer to digest last message */ /* alternatively a DELIMITER string could be placed in shared memory when seen by the consumer, it would exit. the producer would do shmctl(...,IPC_STAT,...) and when shm_attach==1 it would remove the two IPC facilities */ shmctl(shmid, IPC_RMID, NULL); semctl(semid, 0, IPC_RMID ,0); } NОТРЕБИТЕЛЬ БУФЕРА, cons_onebuf.c : /* consumer program: producer program sets up a buffer to be read by a consumer. semaphores are used to ensure that producer doesn't overwrite an unread buffer and consumer doesn't read the same data more than once. */ #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <sys/ipc.h> #include <sys/sem.h> #include <sys/shm.h> #define MSG_SIZE 30 main(int argc, char *argv[]) { key_t key; /* two semaphores in a set index 0 - incremented when producer has reset buffer - tested and decremented by consumer to check if buffer has been reset index 1 - incremented when consumer has read buffer - tested and decremented by producer to check if consumer is done */ static struct sembuf wait_produced = { 0, -1, 0}; static struct sembuf signal_consumed = { 1, 1, 0}; int semid, shmid, rtn; char *message; if((key = ftok( getenv("HOME"), 'u')) == -1){ fprintf(stderr,"ftok key formation error\n"); exit(1); } /* either producer or consumer might be the creator but producer will be the remover of the IPC resources. producer and consumer's effective uid must be the same. */ if ((semid=semget(key, 2, IPC_CREAT | 0660)) == -1) { perror("consumer semget():"); exit(2); } if ((shmid=shmget(key, MSG_SIZE, IPC_CREAT | 0660)) == -1) { perror("producer shmget():"); exit(3); } message=shmat(shmid, (char *)0, SHM_RDONLY); while(1){ rtn=semop(semid,&wait_produced,1); /* when producer is done semid will be IPC_RMID forcing break */ if(rtn == -1){ perror("consumer - semop on wait_consumed"); break; } printf("%s received: %s\n", argv[0], message); semop(semid, &signal_consumed, 1); } shmdt(message); exit(0); } ВЫЗОВ: $ prod_onebuf& 14649 $ cons_onebuf cons_onebuf received: message 1 cons_onebuf received: message 2 cons_onebuf received: message 3 cons_onebuf received: message 4 consumer-semop on wait_consumed:Identifier removed |