Implicit declaration of function error - c

While compiling code for softiwarp using this guide
I encountered the following errors while compile codes in kernel directory.
error: implicit declaration of function ‘remap_vmalloc_range’
error: implicit declaration of function ‘vmalloc’
error: implicit declaration of function ‘vmalloc_user’
error: implicit declaration of function ‘vfree’
Anyone here could help guide me, how to install the libraries related to this function? I'm using ubuntu 16.04.

These functions are declared in <linux/vmalloc.h>. You need to #include that header.

Related

Error: "Implicit declaration" for device_create_with_groups

I am trying to build a custom kernel for NVIDIA Jetson Tk-1 by following the instructions here:
https://github.com/projectara/Android-wiki/wiki/Kernel-Only-Build-Instructions-for-Jetson-reference-platform
Everything goes well until the "Testing Your Custom Kernel" section:
STEP 2. make greybus modules
$ cd $JKB_ROOT/greybus
$ make clean
$ make ARCH=arm KERNELDIR=../kernel-out EXTRA_CFLAGS+=-fno-pic
Here is a snippet for the error I am getting:
/home/jonah/ara_kernel/greybus/loopback.c: In function
'gb_loopback_probe': /home/jonah/ara_kernel/greybus/loopback.c:1207:2:
error: implicit declaration of function 'device_create_with_groups'
[-Werror=implicit-function-declaration] dev =
device_create_with_groups(&loopback_class, ^
/home/jonah/ara_kernel/greybus/loopback.c:1207:6: warning: assignment
makes pointer from integer without a cast [enabled by default] dev =
device_create_with_groups(&loopback_class,
the problem occurs in the loopback.c file, which uses the function device_create_with_groups(...)
Here is the loopback.c file:
https://github.com/projectara/greybus/blob/master/loopback.c
As I understand, this function is found in include/linux/device.h header file, but even if I add #include <linux/device.h> to the beginning of loopback.c, I get the same implicit declaration error.
I am running Ubuntu 14.04 with Linux kernel headers 4.5.0-040500-generic.
Am I using the wrong kernel headers or is the function deprecated or something?
I can get rid of the warning with a declaration in the function above it:
struct device *device_create_with_groups(struct class *class, struct device *parent, dev_t devt, void *drvdata, const struct attribute_group **groups, const char *fmt, ...);
but will this have any severe repercussions when I use the kernel? Or will the function magically be found by the linker eventually?

Problems using graphviz as a library

I'm trying to use graphviz as a library for a C++ project, following the libguide provided here. However I'm having problems even compiling the examples in the appendix. When I try to compile demo.c using gcc I get the following output:
$ gcc -I/usr/local/Cellar/graphviz/2.28.0/include/ demo.c -L/usr/local/Cellar/graphviz/2.28.0/lib/ -lgvc -lgraph -lcdt
demo.c: In function ‘main’:
demo.c:14: error: ‘Agdirected’ undeclared (first use in this function)
demo.c:14: error: (Each undeclared identifier is reported only once
demo.c:14: error: for each function it appears in.)
demo.c:15: error: too many arguments to function ‘agnode’
demo.c:16: error: too many arguments to function ‘agnode’
demo.c:17: error: too many arguments to function ‘agedge’
Agdirected is found in cgraph.h, but if I change the includes in demo.c to
#include <graphviz/gvc.h>
#include <graphviz/cgraph.h>
Then all hell breaks loose (mostly conflicting declarations between the two headers). How can I include the necessary headers without the headache of all these conflicts?
Mac OS X 10.8.3, Graphviz 2.28.0, GCC 4.2.1
It seems after some experimentation that adding the flag
#define WITH_CGRAPH
has the effect of including cgraph.h, which gets rid of the "'Agdirected' undeclared" error.
The other errors can be fixed by changing the command line option in gcc from -lgraph to -lcgraph
The libguide you are using is the cgraph version, which assumes Graphviz 2.30 or later. With that version, the #define WITH_CGRAPH is already provided.

troubles with implicit declaration static (compiling customized mupdf library)

I am compiling mupdf with a custom version of some functions in mupdf library. There are two functions that seem to call each other so when I create the _custom version of them an error is issued at compile time.
pc#pc:~/sviluppo/mupdf-0.9$ make
CC build/debug/obj_print.o
fitz/obj_print.c: In function ‘fmt_array_custom’:
fitz/obj_print.c:191:4: warning: implicit declaration of function ‘fmt_obj_custom’
fitz/obj_print.c: At top level:
fitz/obj_print.c:304:13: warning: conflicting types for ‘fmt_obj_custom’
fitz/obj_print.c:304:13: error: static declaration of ‘fmt_obj_custom’ follows non-static declaration
fitz/obj_print.c:191:4: note: previous implicit declaration of ‘fmt_obj_custom’ was here
make: *** [build/debug/obj_print.o] Errore 1
What's wrong? the default version of the functions already call each other the same way.
In line 191, the function fmt_array_custom is called without prior declaration. So the compiler implicitly assumes a declaration (non-static).
Later in line 304, it sees the actual function declaration/definition which is static. This is a conflict.
For fixing this you can add a declaration before line 191. Just copy the function proto-type (without the body) from line 304.

act.offensive.c: In function âdo_fireâ: act.offensive.c:631: warning: incompatible implicit declaration of built-in function âabortâ

I'm rather new to coding but when compiling ( I use putty and SHH ) i receive this error
act.offensive.c:631: warning: incompatible implicit declaration of built-in function âabortâ
act.offensive.c:637: warning: incompatible implicit declaration of built-in function âabortâ
On lines 631 and 637
CREATE (lodged->next, LODGED_OBJECT_INFO, 1);
CREATE (target->lodged, LODGED_OBJECT_INFO, 1);
I did a search for aaborta and abort through the files in the SRC (for the compile) directory and did not find a match anywhere to explain it or find the file to index it to.
I was wondering if someone might be able to help me
You could try including <stdlib.h> in the file where the built-in function abort is declared.
The error message says about incompatible implicit declaration, so it might be that there's no explicit declaration anywhere in your code and the macro CREATE (I believe it's a macro?) tries to use it.
If that doesn't help, it'd be helpful if you could edit your question and describe what's CREATE in your code.

Header included but declarations still missing?

Here's a simple example:
#include <stdlib.h>
int main(void) {
_set_error_mode(_OUT_TO_STDERR);
return EXIT_SUCCESS;
}
When compiling this program, I get the following problems:
main.c: In function 'main':
main.c:4: error: implicit declaration of function '_set_error_mode'
main.c:4: error: '_OUT_TO_STDERR' undeclared (first use in this function)
main.c:4: error: (Each undeclared identifier is reported only once
main.c:4: error: for each function it appears in.)
The header does contain the function declaration and the macro:
_CRTIMP int __cdecl __MINGW_NOTHROW _set_error_mode (int);
# define _OUT_TO_STDERR 1
How come I get the errors? Notice that I also used the EXIT_SUCCESS macro which is also defined in the same stdlib.h header but for some reason GCC doesn't complain about it. Odd.
I'm using MinGW + GCC on a Vista machine.
Your code snippet works fine for me with MinGW 3.4.5
Are you sure you have your include file path set correctly? Maybe the wrong stdlib.h is being processed. Alternatively, maybe MingGW isn't defining __MSVCRT__ which is necessary to get that function prototype (MinGW seems to define that automatically for me - I'm not sure how one would turn it off).
edit:
tyranid's comment seems to have the answer - if I specify the -ansi option, I get the exact same set of errors as in your example.
Setting to CW and will delete if tyranid posts an answer.

Resources