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>.
Related
i have been looking for hours for a solution and i haven't found anything
tried reinstalling curl, reinstalling CMake but nothing worked
i use visual studio code
the error is
fatal error: curl/curl.h: No such file or directory
3 | #include <curl/curl.h>
| ^~~~~~~~~~~~~
compilation terminated.
i use g++ 9.2.0
the code is
#include <stdio.h>
#include <stdlib.h>
#include <curl/curl.h>
int main() {
CURL *curl;
CURLcode res;
return 0;
}
compiled it using g++
g++ learning.c -l curl -o test
and the curl path is
C:\vcpkg\packages\curl_x86-windows
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];
^
I have a c script
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
int main(void)
{
const gsl_rng_type * T;
gsl_rng * r;
int i;
double a,b;
double num;
a=10;
b=7.2;
gsl_rng_env_setup();
T=gsl_rng_default;
r=gsl_rng_alloc (T);
for(i=0; i<10; i++)
{
num = gsl_ran_gamma(r,a,b);
printf("%.8f \n",num);
}
gsl_rng_free(r);
return 0;
}
Which I have successfully compiled on a linux machine. I want to use the gsl library for other applications on my mac. So I first installed gsl using homebrew which seemed to be successful. To make sure everything was working right I tried to compile and run this script as follows
[ACC-259-imac:GDSC Gene Expression Modeling jmannhei$ gcc -Wall gamma.c -o gamma.out -lm -lgsl -lgslcblas
which resulted in the following output
gamma.c:5:10: fatal error: 'gsl/gsl_rng.h' file not found
#include <gsl/gsl_rng.h>
^
1 error generated.
Which is exactly how I compiled it on Linux so I am not sure what is awry as I have compile c scripts in the past using this format from terminal on a mac before. My guess is it is not linking properly but I am not sure what I need to do to fix it. Thanks
Find your header file directory with brew list gsl or locate gsl/gsl_rng.h then tell your compiler where the headers are. I would need the following, for example,
gcc -Wall -I/usr/local/Cellar/gsl/1.16/include/ gamma.c -o gamma.out -lm -lgsl -lgslcblas
I followed the instructions to install GNU Readline, as well as Curses, however I get some linker issues that I am unsure how to resolve. The following is my program:
main.c
#include <stdio.h>
#include <stdlib.h>
#include <curses.h>
#include <term.h>
#include <readline/readline.h>
#include <readline/history.h>
int main()
{
char * line = readline ("Enter a line: ");
free (line);
return 0;
}
I compiled using: gcc -o main {,.c} -lreadline -lncurses (and the readline includes were where they were supposed to be, in usr/includes...
Running main gave me:
./main: symbol lookup error: /usr/local/lib/libreadline.so.6: undefined symbol: UP
Any direction as to go about resolving this would be greatly appreciated.
sudo apt-get install libreadline6-dev
gcc -o main {,.c} -lreadline -lncurses
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