I tried to run this Github repository called 'Karel the Robot' for my work in university:
Karel the Robot for MacOS
I use macOS Monterey V12.2.1 and run this through an IDE called Clion. I tried to work on the projects via the built in VCS option of the IDE and also tried to simply download and open it from the desktop. Whenever I try to run the basic project (without any additions or changes made by me) I get this error:
/Library/Developer/CommandLineTools/usr/bin/cc -I/Users/nox/CLionProjects/karel/include -I/usr/local/include -g -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk -mmacosx-version-min=12.2 -std=gnu11 -MD -MT CMakeFiles/StarterProject.dir/HelloKarel.c.o -MF CMakeFiles/StarterProject.dir/HelloKarel.c.o.d -o CMakeFiles/StarterProject.dir/HelloKarel.c.o -c /Users/nox/CLionProjects/karel/HelloKarel.c
In file included from /Users/nox/CLionProjects/karel/HelloKarel.c:10:
In file included from /Users/nox/CLionProjects/karel/include/karel.h:3:
In file included from /Users/nox/CLionProjects/karel/include/structs.h:48:
/Users/nox/CLionProjects/karel/include/config.h:1:10: fatal error: 'SDL/SDL.h' file not found #include <SDL/SDL.h>
I understand that he can't find the SDL.h file on my system so I installed and reinstalled it with brew by doing the following:
brew install sdl sdl_image sdl_ttf
and brew reinstall sdl sdl_image sdl_ttf
Nothing seemed to work for me. Can anyone help me with this please?
Related
How can I compile a sdl project using gcc in the linux command line without using Cmake?
EDIT;
gcc SDLGAME.c pkg-config --cflags --libs sdl2
but i get error.
gcc: error: Pkg-config: No such file or directory
gcc: error: sdl2: No such file or directory
gcc: error: unrecognized command line option ‘--cflags’
gcc: error: unrecognized command line option ‘--libs’; did you mean ‘--libs=’?
#HolyBlackCat
source code --->>
#include <stdio.h>
#include <SDL2/SDL.h>
int main(int argc,char *argv[])
{
if (SDL_Init(SDL_INIT_VIDEO) !=0)
{
printf("error SDL");
return 0;
}
SDL_Window* win=SDL_CreateWindow("Game",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
500,500,0);
return 0;
}
I get this error--->>
error: XDG_RUNTIME_DIR not set in the environment.
error SDL
Caveat: This isn't a total solution but some suggestions and is prefaced by top comment's and comments under OP's [now deleted] answer.
To review ...
After fixing the original issue by use of:
gcc -o SDLGAME SDLGAME.c `pkg-config --cflags --libs sdl2`
OP running the program produces:
error: XDG_RUNTIME_DIR not set in the environment.
This may be a general issue about the ubuntu install itself. Some resources for that: https://askubuntu.com/questions/872792/what-is-xdg-runtime-dir and
https://askubuntu.com/questions/456689/error-xdg-runtime-dir-not-set-in-the-environment-when-attempting-to-run-naut
A workaround may be:
export XDG_RUNTIME_DIR=/tmp/dir
mkdir -p /tmp/dir
But, I ran the program successfully on my home system, running fedora 29 and my ubuntu system running 18.04.5
On my systems, XDG_RUNTIME_DIR was set to /run/user/1000. However, with/without the workaround and even doing unset XDG_RUNTIME_DIR worked on my systems.
However: On my ubuntu system, I had removed the standard libsdl2 package and rebuilt and installed it from the source package a year ago due to some issues I had.
So, if the workaround doesn't work, I recommend libsdl2 rebuild/reinstall from source.
Even if the standard package is working, when debugging your app, it can be helpful to be able to consult the libsdl2 source.
Note that one change I made to your app was to add a sleep(3) at the bottom so you can see the window come up.
Here is the method I used to build/install from source:
It's probably necessary to uninstall/remove the binary libsdl2 package. So, you'll have to do (e.g.)
sudo apt-get remove libsdl2 libsdl2-dev
Or, whatever the binary package is called [I forget]. But, those also came from: apt-cache search libsdl2
So, once that's cleaned out, what I did was:
Create a directory (e.g.): $HOME/aptsrc
cd $HOME/aptsrc
Download the source package [without sudo]: apt-get source libsdl2
This extracts several files (e.g. *.tar.gz, *.tar.xz, *.dsc and a directory. On my system, it was: libsdl2-2.0.8+dfsg1, but for you it may be different. Do (e.g.): DIR=$HOME/aptsrc/libsdl2-2.0.8+dfsg1
cd $DIR
Configure with: $DIR/configure
Run cmake: cmake $DIR
Run make with: make
Install with: sudo make install
Note that this comes from an internal script I created. Even after the cd $DIR, I think it's necessary to use full path on the commands [where indicated].
Now, the library should be installed under /usr/local. The output of pkg-config --cflags --libs sdl2 should reflect this:
-D_REENTRANT -I/usr/local/include/SDL2 -L/usr/local/lib -Wl,-rpath,/usr/local/lib -Wl,--enable-new-dtags -lSDL2
The original output of this command would have looked like:
-I/usr/include/SDL2 -D_REENTRANT -lSDL2
This is for the standard install from the binary package, so if you still have that, the binary package may still be installed.
Otherwise, you should now be able to rebuild your app using the original gcc command. Now, it should be attached to the source built version of the library. You can confirm this with: ldd ./SDLGAME but just running it might be easier.
I come to you with a weird problem I've been facing.
So last week, I installed llvm and libomp for a C project, and it compiled just fine with this at the start of my makefile:
CC=clang
CFLAGS = -O2 -fopenmp
CFLAGS += -I/usr/local/opt/libomp/include
LDFLAGS = -fopenmp
LDFLAGS += -L /usr/local/opt/libomp/lib
Today I meant to finish that project, I opened vs code (I don't know if that's relevant), added some code left and right, and when I wanted to compile the code again to test if everything was fine, it gave me
me#macbookPro% make
clang -c -O2 -fopenmp -I/usr/local/opt/libomp/include bubble.c -o bubble.o
bubble.c:1:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
^~~~~~~~~
1 error generated.
make: *** [bubble.o] Error 1
which has left me dumbfounded since it worked just fine a few days ago.
I tried to do an export CPATH with
export CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
but I got a bunch of warning and it didn't work either.
Any help is greatly appreciated !
Info: I'm running the latest version of BigSur and VSCode.
Apparently a macOS update had uninstalled the XCode developer tools.
I ended up uninstalling llvm and libomp, and when reinstalling it told me brew didn't have CLT (use brew config to check that).
Then I ran the classic xcode-select --install then brew install llvm and brew install libomp, edited my path to include the llvm's bin and it works again.
My solution:
masOS12.3.1 monterey
"software update" --> "update commandLineTool" if push --> you can compile correctly without 'stdio.h' file not found.
I am on a Debian linux build environment and cannot change this. We build our apps using mingw and would like to use the openssl suite of tools in one of our applications. The linux version contains the includes openssl/md5.h and compiles gcc with the -lcrypto flag and works great.
What do I need to do to build the Windows dll using mingw and include openssl?
My build command looks like this
x86_64-w64-mingw32-gcc -shared -s FILE.c FILE.def -lcrypto -lws2_32 -o OUT.dll
This produces the error fatal error openssl/md5.h no such file or directory.
I have tried to add the -I /path/to/openssl/includes
Then get the ld error cannot find -lcrypto. I have the libssl-dev libraries.
I have the source for openssl and have tried to compile it using mingw as some other articles have suggested. "cannot find -lcrypto -lssl" with OpenSSL on Windows with MinGW
But the build always fails with multiple files missing the include bits/libc-header-start.h. My thinking was if I can get the windows dlls on the linux system maybe that was what mingw needed.
I have tried to install gcc-multilib as suggested in this post "fatal error: bits/libc-header-start.h: No such file or directory" while compiling HTK but that leads to a basket of missing dependencies.
Is it even possible to build a Windows dll including openssl dependencies from a Debian dev environment?
Thanks for any assistance.
kplot is a UNIX programming library for plotting graphs on a Cairo surface. The source code is available here.
After downloading the source code I extraced it to the directory kplot-master and cd into it. Simple ls now shows
array.c
border.c
bucket.c
buffer.c
....
example0.c
example1.c
....
I am using Ubuntu 14.04 LTS. Cairo is installed in my system and I tested it by successfully compiling C codes available in [zetcode dot com slash gfx slash cairo slash cairobackends slash] (Sorry as I am not allowed to link more than two).
I am new to GTK and Cairo plotting library and would like help in the following directions:
I do not want to install kplot in my system.
I just want to learn how kplot uses Cairo.
When I use the following command:
gcc example0.c -o example `pkg-config --cflags --libs gtk+-3.0`
it produces the following error message:
example0.c:17:20: fatal error: compat.h: No such file or directory
#include "compat.h"
^
compilation terminated.
It will be very helpful if somebody shows me how to test those kplot examples without installing it.
There is no need to install.
First you will need to compile the kplot library. For that, cd to the kplot directory and run a make command. This will generate the file compat.h. After that you will be able to compile example by example with make example(n) command, or with gcc example(n).c -o example(n) `pkg-config --cflags --libs gtk+-3.0` libkplot.a -lbsd -lm command.
If you have GTK+-3.0 and Cairo dev libraries installed, everything should go well.
I am trying to install the driver for a serial device, and when I run the installation executable I get this error:
cc -DLINUX -c -DMODVERSIONS -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe -m64 -mcmodel=kernel -I/usr/src/linux-3.8.0-27-generic/include -I/usr/src/linux-2.4/include -I/usr/src/linux/include -D__SMP__ npreal2.c
npreal2.c:40:31: **fatal error: linux/modversions.h: No such file or directory**
compilation terminated.
I don't find any solutions to this after searching the forums. I noticed that there is a modversions.h in the /usr/src/linux-3.8.0-27-generic/include/config , but not in the linux folder.
Please help!
Try passing -I /usr/src/linux-3.8.0-27-generic/include/config as an argument to make?
or
Check if the header is a part of a certain package and update the package.
You can compile modversions on your system by navigating to the linux directory (usually usr/src/linux). Inside the linux source directory, there should be a file called Rules.make. Inside this make file are build commands for making modversions.h. You can make it by running:
make update-modverfile
Now, while this will make the modversions.h library, if you compile it with a newer compiler than the libraries that this file relies on, many times you will get an error when trying to run a program that uses this header. This then turns into a nightmare.
Another method, I tried it successfully with Xubuntu 13.10:
Open /etc/default/grub
Add this Line and save it.
GRUB_CMDLINE_LINUX="CONFIG_MODVERSIONS=true"
reboot
(no, sudo update-grub,ok)
open a terminal window, enjoy.
locate modversions.h
(Please don't forget modversion'S')