I wrote this simple main.c file, to test microsoft's Raw Input API.
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
RAWINPUTDEVICE Rid[1];
int main() {
printf("Hello world!\n");
return 0;
}
But i can't compile it, i receive the following error:
gcc main.c
main.c:4:1: error: unknown type name 'RAWINPUTDEVICE'
RAWINPUTDEVICE Rid[1];
^
i'm using Code::Blocks, but i recieve the same error using Prompt.
I find just this post with an resembling error.
I also tryed to rename the main file to main.cpp and compile it with the g++ command, but i reciebed another error:
C:\Users\msouza\Desktop\Raw Input>g++ main.cpp
main.cpp:4:1: error: 'RAWINPUTDEVICE' does not name a type
RAWINPUTDEVICE Rid[1];
^
Related
I've a problem compiling the following programm:
// hauptteil.c (main part)
#include "nebenfkt.h"
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
int x =10;
int ergebnis=0;
ergebnis =ver(x);
printf("Doubled number: %d", ergebnis);
return 0;
}
//nebenfkt.h
int ver(int x);
#include "nebenfkt.h"
#include <stdio.h>
#include <stdlib.h>
int ver(int x)
{
int rueck;
rueck= x*2;
return rueck;
}
VSC gives me the feedback "* undefined reference to `ver'
collect2.exe: error: ld returned 1 exit status*"
Solution
The problem occurred because I only used the command "gcc hauptteil.c -o function"
Instead of "gcc hauptteil.c nebenfkt.c -o function"
My mistake was discovered by Eugene Sh.
My mistake was that I only used the command "gcc hauptteil.c -o function" Instead of "gcc hauptteil.c nebenfkt.c -o function".
Informations:
OS: Windows 10
Compiler: MinGW gcc
Language: C
SDL & OpenGL are already installed
When i try to compile the test file , i receive this error:
gcc test.c -o test
teste.c:1:10: fatal error: SDL2: No such file or directory
1 | #include <SDL2>
| ^~~~~~
compilation terminated.
The test file content is:
#include <SDL2>
#include <stdio.h>
void main()
{
printf("Testing");
}
This is my problem, help me pls.
In order to use the SDL header you need to use #include <SDL2/SDL.h> instead of #include <SDL2>.
This is the first gcc error on compilation, copying features.h from the web into the include folder for MinGW helped :
$ gcc -g hello_world.c
In file included from c:\mingw\include\stdio.h:55,
from hello_world.c:1:
c:\mingw\include\_mingw.h:174:10: fatal error: features.h: No such file or directory
#include <features.h>
^~~~~~~~~~~~
compilation terminated.
This is the new error :
$ gcc -g hello_world.c
In file included from c:\mingw\include\_mingw.h:174,
from c:\mingw\include\stdio.h:55,
from hello_world.c:1:
c:\mingw\include\features.h:406:10: fatal error: stdc-predef.h: No such file or directory
#include <stdc-predef.h>
^~~~~~~~~~~~~~~
compilation terminated.
The hello-world file :
#include <stdio.h> int main(int argc, const char *argv[]) {
/* I am C developer */
printf("Hello, Poftut! \n");
return ; }
C:\MinGW\bin\ is in PATH.Pretty sure I have missed some package installation.
When I compile the below program it is giving me this error.
/tmp/ccwr6gsJ.o: In function 'main':
main.cL(.text+0xa): undefined reference to 'example'
collect2: error: Id returned 1 exit status
Main.c:
#include <stdio.h>
#include "includes.h"
int main()
{
int exampleInt = example();
return 0;
}
includes.h:
int example();
includes.c:
#include "includes.h"
int example()
{
int i = 3;
return i;
}
It seems to work in Visual Studio but not on GCC on Linux
This is very likely a build error, i.e. you're calling the compiler on the wrong set(s) of files, and/or not doing a linking step.
Try:
$ gcc -o myprog main.c example.c
Note that a mere #include in a C file does not in any way tell the compiler to compile more C files.
When I try to use LD_PRELOAD as following,
LD_PRELOAD=getpid.so ./testpid
I get the following error...
ERROR: ld.so: object 'getpid.so' from LD_PRELOAD cannot be preloaded: ignored.
I compile getpid.so by using
gcc -Wall -fPIC -shared -o getpid.so getpid.c
and it contains the following code...
// getpid.c
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
pid_t getpid(void)
{
printf("Hello, world!\n");
return syscall(SYS_getpid);
}
tespid.c constains code which uses getpid as shown below and which is compiled by doing
gcc testpid -o testpid.c
What can be the problem here? Why is LD_PRELOAD not working?
// testpid.c
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int main()
{
printf( "pid = %d!\n", getpid() );
return 0;
}
Looks like the loader is unable to find getpid.so as you've not mentioned the path to the library.
Try:
LD_PRELOAD=/full/path/to/getpid.so ./testpid
I was also facing error as below
ERROR: ld.so: object '/usr/lib64/libjemalloc.so.1' from LD_PRELOAD cannot be preloaded
Below were my steps resolved the error for me.
Go to the path /usr/lib64 and look for the libjemalloc using below commands*
#cd /usr/lib64
#ls | grep libjemalloc
if you don't find you don't have that package installed in your system
$sudo yum whatprovides libjemalloc*
$sudo yum install jemalloc-3.6.0-1.amzn2.x86_64