Comments (16)
Thanks.
I myself do not understand, maybe this is specific to macOS (I don't have it but it shouldn't matter )
maybe I should write a python script to add absolute path to all the #includes
NOOOOOOOOOOOOOOOOOOOOOOOOOO!! ))))))))))))))))))))
Do not give up! In programming, you just need to find out where the problem is and solve it.
first try make CC=gcc-9
if you have gcc-9 if it no help open ./Corange/include/cengine.h and edit
#define likely(x) x // __builtin_expect((x),1)
#define unlikely(x) x //__builtin_expect((x),0)
and make clean && make
or make clean && make CC=gcc-9
from corange.
It’s late in the evening and I’m going to bed. Do not give up. It's not a big problem. I want to sleep and my head doesn't work. But together we will solve the problem. Maybe not right away.
from corange.
@fedor-elizarov Have a sweet dream ^^ Thanks for your help sir
from corange.
@anzhi0708 Thanks ::)
from corange.
show GCC version please
But you can try redefine macros 'unlikely'
in engine.h
-#define likely(x) __builtin_expect((x),1)
-#define unlikely(x) __builtin_expect((x),0)
+#define likely(x) x
+#define unlikely(x) x
or before try use clang make clean ; make CC=clang
from corange.
$ gcc-10 --version
gcc-10 (Homebrew GCC 10.3.0) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ vim cengine.h
$ ls
SDL2 cengine.h cnet.h data
assets centity.h corange.h entities
casset.h cgraphics.h cphysics.h rendering
caudio.h cjoystick.h cui.h ui
$ cd ..
$ ls
LICENCE.md README.md corange.ico demos obj
Makefile assets_core corange.rc include src
$ make
gcc src/cengine.c -c -I ./include -std=gnu99 -Wall -Werror -Wno-unused -O3 -g -fPIC -o obj/cengine.o
src/cengine.c:6:16: error: variable 'p' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
if (unlikely(strlen(path) >= PATH_MAX)) {
~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
./include/cengine.h:119:21: note: expanded from macro 'unlikely'
#define unlikely(x) x
^
src/cengine.c:12:10: note: uninitialized use occurs here
return p;
^
src/cengine.c:6:3: note: remove the 'if' if its condition is always false
if (unlikely(strlen(path) >= PATH_MAX)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/cengine.c:4:3: note: variable 'p' is declared here
fpath p;
^
1 error generated.
make: *** [obj/cengine.o] Error 1
$ make CC=gcc-10 CFLAGS=" -I/usr/local/include/SDL2 -L/usr/local/lib"
gcc-10 src/cengine.c -c -I/usr/local/include/SDL2 -L/usr/local/lib -o obj/cengine.o
src/cengine.c:1:10: fatal error: cengine.h: No such file or directory
1 | #include "cengine.h"
| ^~~~~~~~~~~
compilation terminated.
make: *** [obj/cengine.o] Error 1
@fedor-elizarov Actually I was going to learn C by making games... I don't really know, like, should I edit #include "cengine.h"
to something like #include "../include/cengine.h"
?
from corange.
$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.5 (clang-1205.0.22.9)
Target: x86_64-apple-darwin20.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ gcc-10 --version
gcc-10 (Homebrew GCC 10.3.0) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
from corange.
I was going to learn C by making games
Good idea!
#include "cengine.h"
== #include "../include/cengine.h"
becouse compiler have option -I../../include
- 1 Dont use sudo for compile
- 2 Dont use make install for start learning
Ok. If you learn C use simple methods
- 1 Clone Corange
- 2
make
- 3
rm libcorange.so
(for static compilation. if you have .a and .so you take conflict) - 4
cd demos
- 5 just copy someone demo (for example ui demo) folder and rename
my_awesome_game
(stay in demo folder!) - 6 rename ui.c to my_awesome_game.c
- 7 clear or modify source code
- 8 in Makefine rename APP name
APP=my_awesome_game
- 9
make && ./my_awesome_game
- Done! You app work!
if you need modify engine edit code and make; rm libcorange.so
and go you Corange/demos/my_awesome_game/
and make && ./my_awesome_game
- you system clean
- you all code experiments in
./demos
folder (for new experiments just copy new folder and rename *.c and APP in makefile. or create template) - you can modify engine and recompile without install in you system.
from corange.
you tested demos?
And sorry for my english =)
from corange.
#include "cengine.h" == #include "../include/cengine.h" becouse compiler have option -I../../include
it Makefiles in ./demo/*/Makefile
Ok. if you can give full log
git clone https://github.com/orangeduck/Corange.git
cd Corange
make
rm libcorange.so
cd ./demos/ui/
make && ./ui
from corange.
@fedor-elizarov Wow, Makefile looks interesting! ^_^
I would like to test these demos but I feel like maybe there's something tricky about macOS... Or is it just because I'm such a noob?
$ ls
Makefile noise.c noise.fs noise.mat noise.vs
$ make
gcc-10 noise.c -I../../include:/usr/local/include/SDL2 -L/usr/local/lib -std=gnu99 -Wall -Werror -Wno-unused -O3 -g -lcorange -framework OpenGL -lSDL2main -lSDL2 -lSDL2_net -lSDL2_mixer -o noise
In file included from ../../include/corange.h:24,
from noise.c:1:
../../include/cengine.h:30:10: fatal error: SDL2/SDL_opengl.h: No such file or directory
30 | #include <SDL2/SDL_opengl.h>
| ^~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [noise] Error 1
I do have everything under /usr/local/include/SDL2
tho,
$ pwd
/usr/local/include/SDL2
$ ls | grep SDL_opengl.h
SDL_opengl.h
so I'm just trying to fix every #include
statement by hand (adding ../../include
inside of <>
) since -I../../include
not seem working...
This is what I'm doing right now: #include <corange.h>
==> #include <../../include/corange.h>
seems working? so far so good...
from corange.
#include "cengine.h" == #include "../include/cengine.h" becouse compiler have option -I../../include
it Makefiles in ./demo/*/MakefileOk. if you can give full log
git clone https://github.com/orangeduck/Corange.git cd Corange make rm libcorange.so cd ./demos/ui/ make && ./ui
$ git clone https://github.com/orangeduck/Corange.git
正克隆到 'Corange'...
remote: Enumerating objects: 9288, done.
remote: Counting objects: 100% (22/22), done.
remote: Compressing objects: 100% (19/19), done.
remote: Total 9288 (delta 7), reused 6 (delta 2), pack-reused 9266
接收对象中: 100% (9288/9288), 234.88 MiB | 3.40 MiB/s, 完成.
处理 delta 中: 100% (6085/6085), 完成.
正在更新文件: 100% (666/666), 完成.
$ cd Corange
$ make
mkdir obj
gcc src/casset.c -c -I ./include -std=gnu99 -Wall -Werror -Wno-unused -O3 -g -fPIC -o obj/casset.o
gcc src/caudio.c -c -I ./include -std=gnu99 -Wall -Werror -Wno-unused -O3 -g -fPIC -o obj/caudio.o
gcc src/cengine.c -c -I ./include -std=gnu99 -Wall -Werror -Wno-unused -O3 -g -fPIC -o obj/cengine.o
src/cengine.c:6:7: error: variable 'p' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
if (unlikely(strlen(path) >= PATH_MAX)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/cengine.h:115:21: note: expanded from macro 'unlikely'
#define unlikely(x) __builtin_expect((x),0)
^~~~~~~~~~~~~~~~~~~~~~~
src/cengine.c:12:10: note: uninitialized use occurs here
return p;
^
src/cengine.c:6:3: note: remove the 'if' if its condition is always false
if (unlikely(strlen(path) >= PATH_MAX)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/cengine.c:4:3: note: variable 'p' is declared here
fpath p;
^
1 error generated.
make: *** [obj/cengine.o] Error 1
$
@fedor-elizarov Here's the full log...
from corange.
OK I give up, there're hundreds of .h
files in there, maybe I should write a python script to add absolute path to all the #include
s
from corange.
@jdek Hello, why is this happening ?
from corange.
Hi @anzhi0708 you try compile engine with gcc-9 or/and replace likely/unlikely macros?
from corange.
Hi @anzhi0708 ,
I got the same error while compiling the library on macOS Mojave.
The problem is on the compiler and the LFLAGS for the linker.
As @fedor-elizarov has mentioned:
Hi @anzhi0708 you try compile engine with gcc-9 or/and replace likely/unlikely macros?
You need to change the compiler to gcc-9. Better not use other versions, because I tried gcc-11 and the compilation failed at the linker stage.
$ gcc-9 --version
gcc-9 (Homebrew GCC 9.4.0) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
For some reasons, the gcc-9 on macOS cannot find the header files correctly.
Change your the CFLAG and LFLAG in your Makefile like this:
-CFLAGS = -I ./include -std=gnu99 -Wall -Werror -Wno-unused -O3 -g
-LFLAGS = -lSDL2 -lSDL2_mixer -lSDL2_net -shared -g
+CFLAGS = -I ./include -I /usr/local/include -std=gnu99 -Wall -Werror -Wno-unused -O3 -g
+LFLAGS = `sdl2-config --libs --cflags` -lSDL2_mixer -lSDL2_net -shared -g
I installed SDL2 and other dependencies using homebrew, thus I added the path where the headers are installed. This works for me.
Good luck.
from corange.
Related Issues (20)
- Stuff to add to the wiki HOT 1
- Orange doesn't rhyme with purple. HOT 6
- Multiple definition error on compiling HOT 6
- Cannot compile demo "metaballs" HOT 12
- MinGW Compilation: "redeclared as different kind of symbol" errors HOT 2
- Why are there multiple definitions of quadratic()? HOT 2
- Is the "quadratic()" function being properly calculated? HOT 5
- SDL currently breaks MinGW Compile (For some time now?) Temp Fix Herein
- Unable to compile in MSYS2 MINGW64 HOT 12
- Why do the "mesh" and "model" types exist? HOT 4
- bug in "image_rotate_inplace()" function HOT 2
- ani files HOT 1
- Doesn't build on linux HOT 3
- /usr/bin/ld: -lcorange not found HOT 2
- How should I run this on MacOS(Big Sur)? HOT 1
- Segmentation Fault HOT 1
- Sea demo bug HOT 1
- Notice: Mesa - R600 - NIR - TGSI - translation from TGSI failed
- metaballs demo has issues with newer OpenCL(?) error on clGetPlatformInfo: Invalid value
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from corange.