switches in Triangle program - c

A weeks ago, I started learning about the Triangle program, which is used to generate meshes.
I attach the link from where you can download its zip file and read about it:
http://www.cs.cmu.edu/~quake/triangle.html
I am having trouble running the example using in Linux Ubuntu, which is supposed to be run trivially.
In particular, I don't understand what are exactly the switches that are mentioned in the makefile.
How exactly am I supposed to choose the optimization using switches? Do I need to modify the C source code or is something I need to specify before compiling it on Linux terminal somehow?
Besides, I am required to use the -DLINUX switches in order for arithmetics to run well. I would also need to know where I need to specify this.
If it helps, I am getting errors in the terminal notifying me that there are: "Undefined reference to sqrt" and " "Undefined reference to cos".
I really need help on this because my understanding on Linux and C is quite weak.
Thanks very much.

Related

Using make to compile code in c in terminal on Mac

I'm trying to learn to program in C and I'm getting used to compiling the code after writing it. I'm actually using K&R 2nd edition to start off and they use 'cc' to compile. I originally started using Zed Shaw's Learn C The Hard Way but I've stopped because I haven't heard many good things about it. Zed Shaw's way was to use 'make' to compile code, at least in the beginning.
Is there any technical difference between using 'make' and using 'cc' that I should be concerned about right now?
make simply gives commands to the compiler, such as cc. It automates building a project which has multiple files. To begin, you do not need to concern yourself with those details. Building a single file directly with cc is fine. In fact, you will understand how the compiler works so that you can get the most out of make when you eventually learn it.
I agree with code-apprentice. I would just add that it is important to have a good understanding of different cc command line options before moving on to make. When you reach the point of a more complexe compilation project and the build process of your final binary becomes a pain, that's when you can transition to learning Make!

Including basics library of C (unistd.h) on window

I've been programming at my school on a Mac for one month. We did C programming on an UNIX shell.
Now i'm back at home and I use my own PC that is on window 10. I have tried to make a similar set up, but i don't know much about all that. I installed git and bash, this made it like a UNIX shell. Also I have installed the gcc compiler.
So, now that i'm making a basic program, it should be working but when I make the include <unistd.h>, the shell can't find it.
I know my question is probably silly but I really couldn't find how to solve the problem. I downloaded the unistd.h file.
I also found this http://processors.wiki.ti.com/index.php/Compiler/diagnostic_messages/5
It explain that i should be putting the .h folder in some kind of defined path, but I don't know how to do that.
Does anyone know how I can fix this?
If you installed gcc as part of mingw or something similar, it should have included a unistd.h. Just having the gcc compiler is not likely to get you very far.
You probably want to start over and install something different than you did (mingw or cygwin or just set up a vm as suggested) that provides a more complete environment.

Building standalone OCaml program

I'm getting crazy while trying to understand how to produce a binary in OCaml that doesn't need anything too specific (eg. having anything as OCaml build tools installed).
I'm using OMake and everything seems enough cool while working on my machine, also linking libs with
OCAMLPACKS[] = str unix batteries
works quite well, but if I try to distribute the executable it gives me the following error:
Fatal error: exception Sys_error("/usr/godi/share/camomile/database/general_category.mar: No such file or directory")
yes I'm using GODI but I don't see any apparent reason for this error, can anyone enlighten me? In addition, if you have any tricks regarding building stand-alone applications please tell me (I'm already arguing with GODI that compiled everylib just in its x64 version and now I'm unable to produce x86 executables)
Thanks in advance
The camomile library requires runtime configuration. See README.txt for informations about how to set it up.
In particular, it requires runtime files (the missing .mar you see) to correctly work.
I don't use OMake, neither batteries, neither GODI nor Camomile. But from what I see the problem seems to come from the fact that you link against Batteries which I guess must use Camomile internally and Camomile relies on data stored in the file system to provide some of its service. It fails to load if that data is not present on the final host.
Note that shipping purely static excutables is something that is fairly simple to do with OCaml. But for that you need to consider which libraries you use (e.g. if you use camomille you will have to ship the support files with).

Trying to compile code from OS Dev tutorial

This is a hard question to ask because I'm positive I'm about to be bombarded with haters commenting on "if I can't write an operating system already, I won't ever to be able to write an operating system". Well I've read Modern OS by Tanembaum, Linux Kernel Development, Understanding the Linux kernel and others I still don't know if or not I can write an operating system and only by pushing forward to write one will I realise what I don't know. On top of that none of the books I read even bother to describe the boot sequence / compilation sequence.
Anyway I hate to be negative but I would just like to build the example code from the bkerndev tutorial below and have an absolutely minimum operating system:
http://www.osdever.net/bkerndev/index.php?the_id=90
You can download the associated source code in a zip format from here:
http://www.osdever.net/bkerndev/bkerndev.zip
When you try and compile this kernel you run into all sorts of errors caused by the fact that some of the code is broken. Another user was seeking help for this here on stack overflow here:
compiling my own kernel (not from linux-kernel source)
Although didn't get much help. I have addressed those errors by adding the gcc flag fleading-underscores and by changing some of the data types. You can see my code here:
http://github.com/PhillipTaylor/farmix
The code will compile sucessfully and leave me with a kernel.bin executable but when I boot into it from grub I get:
Error 13: Unrecognised or unsupported format (or something to that nature)
When I take the kernel.bin directly from the authors zip file and run it on my eeepc it boots absolutely fine so I think I have a problem with compiling the code correctly. The author is building it from a Windows machine, I believe, but I am trying to compile it using Fedora 10 i386 with GNU GCC 4.3 and I think this is what is causing the issue so I ask you, how do I build a valid executable kernel? Am I missing the correct target or the wrong binary format?
I would really appreciate someone helping me over this embarrassing "first step"
My comment above wasn't very clear. What I meant is "What does the 'file' command report on your kernel.bin vs. theirs?". The output of the linker is a raw binary file. It should start with a few magic words that grub recognizes. They are defined in start.asm near "mboot". I suspect yours is different than theirs.
I don't have nasm handy so I can't build, but you might want to start by comparing the first few words of the .bin file.
It turns out that the line used to compile the app was explicitly set to compile to "aout" format which was what the guide said and what I assumed to be true. Only reading stuff in the "barebones" guide convinced me that I may have been confused. As soon as I changed that one line to "nasm -f elf" it all worked.
This is a tag in my repository that points to a basic WORKING version of bkerndev tutorial code (How to write your own Operating system) for future reference and people who were in my position..
It comes with a makefile for building it from a 32 bit Linux system.
http://github.com/PhillipTaylor/farmix/tree/bkerndev_tutorial_working

C makefile to compile OpenGL project directly on iphone

Please direct me if this question has already been asked; I did a search on the topic unable to find yet.
I am having trouble putting together a makefile that will take one or more .c OpenGL project files, uses apple-arm-darwin9 and OpenGL framework to compile into object directly on the iphone (using bash). For some reason whatever combination of framework or LIBPATH I use I am constantly seeing exceptions thrown - if anyone can point me to the right direction I'd be well on my way. Thanks
Too generic, and two different issues.
One, the problem of finding a command (or series of commands) that does correctly compile your code.
Two, writing a Makefile to do the job.
I'd help you with the latter, but you have to figure out the former first (which has nothing to do with Makefiles at all)...

Resources