Skip to content
Advertisement

Tag: c++

Create shared library with extension so

I have c++ shared library project in my eclipse. Project builds fine, but I always need to rename binary by adding .so extension. Is it possible somehow set Eclipse to create binary with needed extension? Answer Now that I see the command line, it is easy to answer the question. -o “libMYLIB” -o sets the name of the output file

XML to postscript using xsltproc

I’m trying to produce a postscript file for an XML document. I can produce a plain text or an html output using xsltproc. Is there a way to produce a postscript file from command line or programmatically using C? Answer One possibility to achieve this is converting the XML-file to XSL-FO and then use Apache-FOP to transform it to a

Limit Qlistview to 1 selected item at most

I try to compel the program to select the 1st item(and only it) in the QListview if user’s selection is more 1 and includes the 1st item. The selectionMode flag is multiselection, which means user can select several items in the listview. Below is my code: in the constructor: But this code does not work. It only deselects the last

How do we compile kernel code in C?

I am new to C and Linux. I am trying to compile the below code but it gives some fatal error while compiling. Any help on fixing this appreciated. Here is the code measurecpu.c: I am trying to compile it this way: I get this error: Answer I am trying to compile it this way gcc -c -O2 -W -Wall

Linux scheduling. (pthreads)

I’m trying to play around with threads and so far, with the code below, I’m doing fine. I want also want to print the current index of the executing thread but I’ve encountered some problems. I’m trying to print the current executing thread along with “Hello world!”. But, the output is this… So far, I’ve already tried issuing What can

How do I configure QT5 without Xlib

I am trying to configure (and build) QT5 static. I want it to draw to the framebuffer and use webkit. I searched the docs but I didn’t find anything on how I can do this without X. Does anyone know a way of doing this ? Answer Building Qt statically is totally orthogonal to the platform selection. Depending on your

Get/Set the pthread scheduling policy in Linux

The code below is a sample provided by the book in my Operating Systems course. When compiling it I get the error shown below it. I compiled it using this command… However, I get this error. I tried adding -pthread: but the error remains. Thanks for your help! Answer You have the correct compiling command: but you need to put:

Simple way to call ‘cat’ from c++?

I am writing some C++ code and I need to pre-allocate an array based on the contents of a file. I can definitely read the the file and parse the strings a certain way, but it’s must easier to find the proper number from the following Linux one-liner: What is the best way to use this single one liner on

waitpid() gives incorrect exit code

I’ve got a function for starting a process, and then returning the stdout and exit code. However I’ve noticed that it claims that every process returns the exit code of 1. I control the executable being invoked and I had it print to stdout the exit code, so I’ve confirmed that when it “failed”, it in fact returned 0 from

Design of multi-threaded server in c

When trying to implement a simple echo server with concurrent support on linux. Following approaches are used: Use pthread functions to create a pool of thread, and maintained in a linked list. It’s created on process start, and destroy on process termination. Main thread will accept request, and use a POSIX message queue to store accepted socket file descriptor. Threads

Advertisement