Examples of GTK and plplot? - c

I am trying to embed a plplot graphics inside a gtk window at OSX. I used plplotcanvas but so far i have no success at all. At the wiki there is one example (http://archive.tcltk.co.kr/doc/plplot-html-5.9.4/gui.html) but i can find nothing else. The version i am using is 5.10.0.
Anyone knows how to do it or any advise?. At the examples on the wiki the compiler can not find plplotcanvas.h after change the libraries the compiler says the same for every function:
plem.c:62:2: warning: implicit declaration of function 'plplot_canvas_plwid' is invalid in C99 [-Wimplicit-function-declaration]
plplot_canvas_plwid(canvas,2);
It is the same with every function of plplotcanvas. Thanks in advance guys.

Either you got a version mismatch of libs and API you use, a typo, or you simply forgot to include appropriate headers.
For a more detailed diagnosis you need to post some (relevant) code chunks.
There are plenty of examples for plplot usage, each screenshot links to a full code example

Related

Read libsmbios Library Documentation

I have never been good at reading and understanding C & C++ Library documentation, for some reason. It's drives me insane. If I see a working sample then I'm good for most other things.
I have installed libsmbios-dev and libsmbios-doc on my ubuntu based machine.
The Library docs are located at /usr/share/doc/libsmbios-doc/doxygen/libsmbios_c
Can anyone provide a working example of pulling the service tag number on a dell machine using libsmbios?
I've search and I can't seem to find what i'm looking for.
Thank you
Could this function be the one you're looking for?
char *sysinfo_get_service_tag();
Defined in service_tag.c, declared in system_info.h. I am unable to test this, but you would presumably include this file in your code.
#include <smbios_c/system_info.h>
at the top of your code:
#include <smbios_c/system_info.h>
when you want to obtain the service tag, in your program.
just call the function, from the library, that performs the desired operation. I.E.
sysinfo_get_dell_system_id();
which returns an int that is the system ID
There is no need to have the source code, as the executable function is in the library. libsmbios-def, which you will need to include in your link step.

error: implicit declaration of function 'rdtscl' [-Werror=implicit-function-declaration] (but no error when running on older kernel version)

I'm new to all of this and am trying to compile a program on a virtual machine with kernel version 3.10.0-957.el7.x86_64. But I get this error:
/home/../../../isr_demux.c: In function 'demux0_isr':
/home/../../../ isr_demux.c: 782:3: error: implicit declaration of function 'rdtscl' [-Werror=implicit-function-declaration]`
I pulled up isr_demux.c and saw that the snippet of code it said was causing the error is this:
The third to last line is line 782. What's interesting is that this same file compiles fine on a virtual machine with an older kernel version 3.10.0-327.el7.x86_64.
I searched online a lot but am truly stuck. I saw another post and checked my header files, and included linux/proc_fs.h along with many other ones. Someone said I could be missing a function prototype or definition, but adding a prototype did not fix this, and defining the function led to a redefinition error.
Any ideas about whether I'm still missing a header file somewhere? Or if the problem is with the newer kernel itself and I might need to find some sort of patch? Thanks!
The website elixir.bootlin.com is pretty useful for these things. The following link is a search across the entire kernel sources tree for version 3.10.108 for the symbol rdtscl.
https://elixir.bootlin.com/linux/v3.10.108/ident/rdtscl
rdtscl is only defined as a macro, so looks like the macro is not defined where you are getting your error about implicit declaration of rdtscl.
The two places where rdtscl is defined as a macro are:
https://elixir.bootlin.com/linux/v3.10.108/source/arch/x86/include/asm/msr.h#L182
https://elixir.bootlin.com/linux/v3.10.108/source/arch/x86/include/asm/paravirt.h#L182
So the fix is to include the correct headers files if you are building for x86 (the headers defining those macros are in arch/x86), or replace the call to rdtscl with something else.

Trying to get get_long_long to work in credit.c cs50

I been doing some research through stack overflow and also through the cs50 reference library.
The reference library states the obvious. Basically that get_long_long can be used, but that its being deprecated for get_long. Idk when, but that's what it says.
Stack Overflow has similar questions, but no one is answering what I am trying to find the answer for.
I have posted two pictures to show you what my code looks like and the error message I am receiving.
For some reason it is giving me this error saying that the implicit declaration is invalid, but I have the cs50.h library included at the top, so i'm a little confused.
Thanks in advance for your help!
You are using a function for which the compiler has not seen a declartion of yet. IE, you havent included it properly with the proper header files. I would check your includes and ensure that you have properly included the header file that contains the function. Alternatively, you can declare it before use above main if this is a local function. But it seems as though its part of the cs50 package, I would make sure you have that package in your include section or add a relative path to it if you can locate it on your system.

PyFile_Type replaced by ..?

I'm tyring to compile Yenc for Python 3.2. I noticed that gcc complained about a non-declared function PyString_Type, so I replaced it with its replacement PyBytes_Type as according to the documentation.
However, gcc also complained about an undeclared function called PyFile_Type. I googled a bit and found:
Python 3.x replaces the PyFile_Type extension type
with an abstract interface and specific implementation types.
Unfortunately it doesn't make any of this directly available
with a C level api.
source
I am by no means a C-programmer, which leaves me unable to solve this issue. What should I do to solve this?
Edit: output of compilation, _yenc.c
Thanks!
Simply put, PyFile_Type has been replaced by something not even remotely similar in Python 3, and you'll have to either modify the code yourself or wait for the maintainer to do that. If you're not a C programmer, it'll likely have to be the latter. The documentation states that rather than wrapping FILE*'s, Python 3 now wraps low-level I/O, in this case file descriptors and read()/write().
You can try using PyFileIO_Type, however you have to declare it before. (Original is located in _iomodule.h inside the Python sources):
extern PyTypeObject PyFileIO_Type;

Using ext2 file system variant on Linux

I'm a newbie to kernel programming, and I'm stuck on something, so I'd appreciate some help. I appologize in advance if something similar was asked before, I did not find any relevant post, and could find explanations on the web which were simple enough for someone unexperienced as myself in this field to understand.
I want to experiment with my own version of ext2.
I've got the source files from kernel.org, and made the proper changes. Nothing fancy, just to check something I had in mind.
Now I want to insert it to my linux kernel (ubuntu 2.6.31-14-generic-pae if it matters).
How can I do this?
My (obviously naive) initial thought was to simply use the makefile that comes along with it (after manually setting various flags there so it has obj-m/obj-y where needed) and compile it as a kernel module.
However I keep getting errors during compile time about redifining macros, implicit declarations of functions etc. For example
ext2.h:181:1: warning: "ext2_find_first_zero_bit" redefined
balloc.c:574: error: implicit declaration of function dquot_free_block_nodirty
Obviously this is not the way to go. I guess worst case scenario is compiling the entire kernel again (with my modified ext2 code instead of the original) so it creates the relevant library with my own ext2, and rebooting from the new image. I find it hard to believe this is the best approach.
Is it even possible for a new file system to be inserted as a kernel module?
Myabe I should put my modified ext2 code in /usr/src and somehow compile only the relevant library which contains the current ext2 code?
Anyway, I'd appreciate any help on what should I be doing.
Thank you
Do a search and replace of ext2 with my_awesome_filesystem or some such.

Resources