Closed greigs closed 5 years ago
There are no special parameters for GCC/G++ required, unless the readme has a "Compilation note" for it.
In general you can compile tool.c
to an executable tool
(or tool.exe
on Windows) with this line:
gcc tool.c -o tool
There's really nothing else you need.
EDIT: I forgot that with GCC you need to link the maths library (used for pow
, sin
, etc.) explicitly. Thanks for reminding me:
gcc tool.c -lm -o tool
Maybe I may write a Makefile for them sometime in the future, but I can't make any promises.
Thanks for clarifying. Seems I have something strange with my gcc setup as I was getting errors like the one below, which prompted me to raise this issue. However g++ works just fine. So if in doubt use g++ I guess!
gcc ngp2mid.c -o ngp2mid
/tmp/ccTQdAJE.o: In function `DB2Mid':
ngp2mid.c:(.text+0xe3a): undefined reference to `pow'
ohh, you're right.
GCC needs the math library linked for some functions. (done with -lm
) I keep forgetting about that.
I used Visual Studio to develop most of these tool and VS doesn't have the maths library separated from the rest. (I don't have VS project files, because I always just add them temporarily to a generic project.)
Good to know. Whenever I see projects with simple looking .h and .c files I tend to try gcc first in linux, or g++ if I see cpp. It works most of the time. Getting VS setup for anything other than .NET be tricky - lots of things to get wrong without project files.
edit: gcc ngp2mid.c -lm -o ngp2mid works as expected in ubuntu
Just figured out if you would like to use with WSL (Ubuntu 20.04 LTS), you need to do these:
build-essential
, you should install that.gcc <tool name>.c -lm -I. -o <tool name>
This command asks GCC to compile with required headers from vgmrips/vgmtools and math library.
Then, it should works.
Actually, you don't need the vgmtools repo. Instead you change the -I
parameter to -I.
and it works.
Actually, you don't need the vgmtools repo. Instead you change the
-I
parameter to-I.
and it works.
Ah, I didn't realize that. Thanks for pointing out!
Sorry, the documentation is really lacking in that regard.
I'm trying to figure out how to build these tools but it would be good to know the parameters for the gcc / g++ command or have a makefile available.