I cannot include config.h in gimp - c

I am new to gimp programming. I have installed the gimp and using it in Visual Studio 2010. The configuration is ok.
I was trying to compile the code from here:
http://git.gnome.org/browse/gimp/tree/plug-ins/common/blur.c
The problem is that when including config.h, I am getting this:
fatal error C1189: #error : "config.h must be included prior to stdplugins-intl.h"
where is this config.h file located?
Also, I have problem with this code:
GimpRunMode run_mode; run_mode = param[0].data.d_int32;
it says a value of type gint32 cannot be assigned to an entity of type GimpRunMode.

config.h is generated when you run ./configure in the root of the gimp directory. If you have run configure it should have ended up in the root of the gimp directory.
As to your other problem, try casting the value before assigning it:
GimpRunMode run_mode;
run_mode = (GimpRunMode)param[0].data.d_int32;

Related

Accessing libnetlink.h

I'm trying to access some member variables within libnetlink.h, but when I #include in my source and compile with "gcc source.c -o binary", I get a "fatal error: libnetlink.h: No such file or directory" error.
I'm on Ubuntu 16.04 and I've already installed libnl-3-dev via apt-get install.
You need to put the correct path that must be seen from your source file.
this can be done by either:
1: Full path of the file 'libnetlink.h' like this (for example in linux):
/home/username/Desktop/folder1/libnetlink.h
2: Relative path of the file, corresponding to where your source file exist:
suppose your source file exist on 'Desktop', and your libnetlink.h exist in sub folder of Desktop folders called 'folder1', then the path will:
folder1/libnetlink.h
I guess the following command may help.
apt-get iproute-dev
I am using Fedora Core 26, after installing iproute-dev, the same problem is solved.

Matlab S-function builder with Visual Studio 2013 - missing rtwtypes.h

I'm trying to compile pre-generated code from Simulink S-function builder and I get an error:
fatal error C1083: Cannot open include file: 'rtwtypes.h': No such file or directory
I've gone trough every include directory in matlab and simulink and there is no such header file. I'm using Matlab 2014b. What may be the problem?
BTW. I can compile MEX files without any problems.
I tried including "hacked" file found on network:
Header rtwtypes.h source
But it doesn't work as well as I expected, now my error is:
fatal error C1189: #error : Must define one of RT, NRT, MATLAB_MEX_FILE, SL_INTERNAL, or FIPXT_SHARED_MODULE
I have no idea why rtwtypes.h isn't in matlab or simulink include directory...
But solution for my problem was:
Include found on network rtwtypes.h file into project
Add line above #define S_FUNCTION_LEVEL 2 in your your-s-function-name.c:
#define MATLAB_MEX_FILE
It builds without problem. Does it work as good as standard sfunction compiled by Matlab? I have no idea, some test may be needed.

Understand the linux build process

I'm trying to build the linux kernel and would like to understand a few things:
I have added a new file (b.c) to a certain directory with the intention of having the file compiled in. The Makefile has been updated accordingly. While compiling the file, an error is thrown saying that a certain header (a.h) is not found. However, other files in the same directory use a.h without any issues.
I have observed that .o.cmd file get created for all files except b.c. Is this a prerequisite for the headers to be correctly included? Does this file have any significance to the issue I'm facing?
For eg: I added 'async_infra.o' to this line in the Makefile:
uml_gre-objs := uml_gre_kern.o uml_gre_user.o async_infra.o
uml_gre_user.c includes the header that I'd like to be included in async_infra.c
Any suggestions on what's missing and how to address the issue will be appreciated.

Using talloc in an embedded project

I would like to be able to use talloc in an embedded project I am working on, but have been unable to determine how I go about incorporating it into my development environment. The environment in question is a vendor-supplied Windows IDE that uses ARM GCC 4.4.1, and I am using it to target an ARM7 device.
I have gotten to the stage where the compiler is complaining about conflicting types:
In file included from .\talloc-2.0.8\talloc.c:33:
.\talloc-2.0.8\lib\replace/replace.h:626: error: conflicting types for 'ptrdiff_t'
c:\program files (x86)\cypress\psoc creator\2.2\psoc creator\import\gnu_cs\arm\4.4.1\bin\../lib/gcc/arm-none-eabi/4.4.1/include/stddef.h:149: note: previous declaration of 'ptrdiff_t' was here
.\talloc-2.0.8\lib\replace/replace.h:848: error: conflicting types for 'useconds_t'
c:\program files (x86)\cypress\psoc creator\2.2\psoc creator\import\gnu_cs\arm\4.4.1\bin\../lib/gcc/arm-none-eabi/4.4.1/../../../../arm-none-eabi/include/sys/types.h:253: note: previous declaration of 'useconds_t' was here
.\talloc-2.0.8\talloc.c:123: error: expected specifier-qualifier-list before 'uint8_t'
I noticed that replace.h tries to include a file called config.h that does not exist in the talloc source tree - a problem I got around by creating a blank file by that name. Is the idea to use config.h to inform talloc what functions are already defined by the system? Is this just a matter of using the #define directive to prevent replace.h from trying to replace existing types?
Given that this is the first time I have attempted to use code that I did not write myself in a project, I am somewhat confused as to how to go about reconciling these conflicts.
config.h should be generated automatically. For tmalloc, it's done by waf (python-based build system).
$ python ./buildtools/bin/waf configure
Checking for program gcc or cc : /usr/lib/ccache/gcc
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for gcc : ok
Checking for program git : /usr/bin/git
Check for -MD : yes
....
$ python ./buildtools/bin/waf build
.....

Installing a new library in Linux, and accessing it from my C code

I am working on a project which requires me to download and use this. Inside the downloaded folder, when extracted I am presented with three things:
A folder called "include"
A folder called "src"
A file called "Makefile"
After some research, I found out that I have to navigate to the directory which contains these files, and just type in the command make.
It seemed to install the library in my system. So I tried a sample bit of code which should use the library:
csp_conn_t * conn;
csp_packet_t * packet;
csp_socket_t * socket = csp_socket(0);
csp_bind(socket, PORT_4);
csp_listen(socket, MAX_CONNS_IN_Q);
while(1) {
conn = csp_accept(socket, TIMEOUT_MAX);
packet = csp_read(conn, TIMEOUT_NONE);
printf(ā€œ%S\r\nā€, packet->data);
csp_buffer_free(packet);
csp_close(conn);
}
That's all that was given for the sample server end of the code. So I decided to add these to the top:
#include <csp.h>
#include <csp_buffer.h>
#include <csp_config.h>
#include <csp_endian.h>
#include <csp_interface.h>
#include <csp_platorm.h>
Thinking I was on the right track, I tried to compile the code with gcc, but I was given this error:
csptest_server.c:1: fatal error: csp.h: No such file or directory
compilation terminated.
I thought I may not have installed the library correctly after all, but to make sure, I found out I could check by running this command, and getting this result:
find /usr -iname csp.h
/usr/src/linux-headers-2.6.35-28-generic/include/config/snd/sb16/csp.h
/usr/src/linux-headers-2.6.35-22-generic/include/config/snd/sb16/csp.h
So it seems like the csp.h is installed, maybe I am referencing it incorrectly in the header include line? Any insight? Thanks a lot.
The make command is probably only building the library, but not installing it. You could try sudo make install. This is the "common" method, but I recommend you to check the library's documentation, if any.
The sudo command is only necessary if you have no permissions to write the system's include and library directories, which may be your case.
Another possibility (instead of installing the library) is telling GCC the location of the library's source code and generated binaries (by means of the -I and -L options of the gcc command.
That Makefile will not install anything, just translate the source into a binary format.
The csp.h in the Linux kernel has nothing to do with your project, it's just a naming collision, likely to happen with three letter names.
In your case, I would presume you need to add the include directory to the compilation flags for your server, like gcc -I/path/to/csp/include/csp csptest_server.c.
(Next, you'll run into linker errors because you'll also want to specify -L/path/to/csp -lcsp so that the linker can find the binary code to link to.)

Resources