Helloween!
What is the easiest way to compile a normal C-program linked with linux-libraries?
If I look at the gcc manual I see thousands of unnecessary options.
So, would you tell me a little about some necessary options like
-c, -o, -f and so on which do you think might help?
To this moment I've needed to specify the library paths in my makefile; wouldn't that have to be automatic feature of Gcc when I use #includes in C?
Btw, can gcc output ms-exe or com, and if can, how?
Compiling normal C programs in Linux
Re:Compiling normal C programs in Linux
MinGW and Cygwin produce Windows executables.
Building standard apps in Linux is extremely simple (you should have easily been able to find a tutorial on this):Standard libraries (libgcc, libc, libstdc++) should be automatically linked but you will need to specify others manually using the library option (ie. -l<Name>)
A more complex build involving multiple C files is:
Building standard apps in Linux is extremely simple (you should have easily been able to find a tutorial on this):
Code: Select all
gcc mysource.c -o myapp
./myapp
A more complex build involving multiple C files is:
Code: Select all
gcc -c mysrc1.c -o mysrc1.o
gcc -c mysrc2.c -o mysrc2.o
gcc mysrc1.o mysrc2.o -o myapp
Re:Compiling normal C programs in Linux
There are no options that are unnecessary. You might not need them, but that doesn't mean that I don't need them, or that you won't need them in the future.OSMAN wrote: What is the easiest way to compile a normal C-program linked with linux-libraries?
If I look at the gcc manual I see thousands of unnecessary options.
By enabling the linker to output that kind of file. You can enable that in its configuration. LD is contained in binutils.Btw, can gcc output ms-exe or com, and if can, how?
Re:Compiling normal C programs in Linux
If there is a makefile included then it's even easier. Usually just type "make" and it compiles for you.
There is also some programs that include a configuration generator that creates the stuff that the makefile uses.
For instance to compile sarien for linux I type this:
Then this:
Of course you have to have both gcc and make installed for this.
Cross platform takes a bit more work... I had to install some mingw32 stuff and I usually have to modify the makefile to make it use mingw32, but then I can compile windows executables from linux.
There is also some programs that include a configuration generator that creates the stuff that the makefile uses.
For instance to compile sarien for linux I type this:
Code: Select all
./configure
Code: Select all
make
Cross platform takes a bit more work... I had to install some mingw32 stuff and I usually have to modify the makefile to make it use mingw32, but then I can compile windows executables from linux.
Re:Compiling normal C programs in Linux
"configure" is a shell script created by "autoconf" from a configuration file that you still have to write to begin with (using "m4").