Can't find .ocamlinit file - ocaml

I'm trying to get an OCaml environment set up for the Real World OCaml book.
I need OCaml, OPAM, Utop and the Core library. I've been able to install OCaml, OPAM and Utop but I have problems setting up the Core library.
I'm in OS X and I've already installed Core by:
opam install core
opam install async
opam install core_extended
Now I should add some lines to my .ocamlinit file. The problem is, I'm kind of a noob and I don't know where this file is located exactly or how I can access it. The file should be in my home directory but I can't seem to find it and I'm not sure I know what this means exactly.
I've also tried to setup an OCaml environment on a virtual machine running ubuntu, but I run into the same problem.
Sorry for the low level question.

The file is located in your home directory. It is your current directory when you open your terminal.
You don't see this file because it starts with a ".", this it's hidden and finder can't see it. In your terminal you can see all hidden files by
ls -a
I recommend you use emacs to edit this file, by
emacs .ocamlinit
This will open the .ocamlinit file with the emacs editor.
Then just paste your text into it and do ctrl+x ctrl+s to save and ctrl+x ctrl+c to quit and you're done!

just create it. Also, you may find interesting the user-setup package, installable with opam install user-setup.

The toplevel/utop will search for .ocamlinit in the current directory and if not found there, in the home directory. It sounds like you want the home directory.
If the file you want doesn't exist already, just create it with a text editor. It's a good idea to start with something like
print_string "test\n";;
so you can see whether the init file is taking effect. If you start utop and don't see test, it didn't work.

Related

How to install dxflib [a C++ library] on Windows 8.1?

So I want to install the dxflibn (it allows for the program to read and write .dxf files). You can find the files here. I found, on there site, this Programmer's guide. If you go to page 3, it says how to install the library. It says to use cygwin and MinGW32. I have not used this tools before so need some help.
From what I read (when I was researching these tools), the MinGW32 is used to install the compiler needed and the Cygwin can emulate the Unix system. I do have some experience with Unix command line but limited.
Back to the instruction on page 3, it says to run two commands. The first command is for executable but from the file I downloaded (the dxflib zip) there is no "configure" file to execute. While searching even more, I found the the .pro file that is in the folder of the library can produce a make file but not sure how.
Questions:
What exactly do I need to do to install the dxflib?
After I install it, for me to run it from my C++ code, what do I need to do? I read here that I need to:
A) put the header files in a location which your compiler is aware of
B) put the dll files in a location which your linker is aware of.
Any help would be amazing, tnx :)
I was able to find a solution after all.
For question 1:
I first went and installed qmake (from the Qt website).
After that, I needed to include in my "system parameters" the qmake.exe so I can run it from the Command Prompt line (like it says here).
And finally, I opened cmd, navigated to the library directory and run the command qmake -spec win32-g++ dxflib.pro (as suggested here). This created the make file.
Now run the command MinGW32-make. This will create a "release" folder with with a static library (that will be needed a the next step) and come .o files.
For question 2:
I used the Dev-C++ IDE. After I had created a project, I went to "project>project options".
Under "Directories>Include Directories" I added the path of the source code of the library (path_of_where_you_unziped_the_library\dxflib-3.7.5-src\src).
Also, under "Parameters>Linker" I added the .a file that is under the "release" folder (path_of_where_you_unziped_the_library\dxflib-3.7.5-src\release)
This worked for me :)

GDB not a recognized command - Windows command prompt

I am trying to use GDB to debug a C++ program, but my system is not recognizing gdb as a command. I installed it, along with many other tools, via MinGW. I have not had any problem with the other features I have used (gcc, g++), so the issue doesn't seem to be with my general set up. I have added the MinGW\bin directory to my PATH. The gdb.exe is in that folder. But it will not run when invoked from my project directory, it simply errors: "'gdb' is not recognized as an internal or external command, operable program, or batch file." Is there some step in setup or invocation that I missed for using GDB?
EDIT: Alright, I think I found the problem: there are two MinGW directories in my PATH, one at C:\MinGW, and another in folder that got installed with some Haskell compilers I used a while ago. It appears to be defaulting to the Haskell folder, perhaps because this directory is listed first. However, this folder contains gcc and g++, but NOT gdb. I was able to get the gdb command working by creating the fstab file in the msys directory, a step I apparently forgot when setting up MinGW. I added my C:\MinGW directory to it, and now the gdb command is working properly! Out of curiosity, what does this file do?
Also, ideally I would like it to look in the C:\MinGW directory first, since this is the folder I plan to keep updated, and the one that contains ALL of the various applications. However, the Haskell directory is specified via the system PATH variable, which I've read it's not a good idea to touch. Would switching the order that they appear even fix my problem?
EDIT 2: Not 100% sure what happened, but the gdb command appears to be working now. I have always been using the Windows cmd prompt to run these tools, so per the answer below (that I should not need to mess with msys) I deleted the fstab file, and lo, it still works! However, my second question above still stands: What is the best way to get the compilers to run out of C:\MinGW\bin instead of C:\Program Files (x86)\Haskell Platform\2013.2.0.0\bin? Is moving the Haskell location out of the system PATH and to the end of the user PATH a viable option?
I had to run pacman -S mingw-w64-x86_64-gdb separately and then gdb showed up in the bin.
You do not have to run gdb (or gcc and all other MinGW tools for that matter) within msys - it is not like Cygwin in that respect. Had you run it from the Windows cmd console, it should work.
The msys shell is useful for running configure scripts generated by Autoconf used by many Linux originated open source projects, but its environment is independent of the Windows environment.

ocaml using tuareg interactively

Why do I get the following when running ocaml interactively under tuareg 2.05?
OCaml version 4.01.0
Cannot find file topfind.
Unknown directive `camlp4o'.
I'm using OSX 10.9.
Iain
It looks like you have a .ocamlinit that tries to load topfind, which is failing because you do not have the right directory in the search path.
If I had to hazard a guess, I'd say that you've put some configuration junk (maybe something like eval `opam config env`) in a configuration file such as ~/.bashrc that arranges for this to work in the shell, but emacs doesn't get to see it because .bashrc is not consulted by the desktop environment in which you start emacs. Does running ocaml under bash in the same directory work and successfully load topfind? If so, find which configuration files your environment does consult and move the relevant code into one of those. ~/.profile, maybe.

Packaging Linux software while keeping a sane file structure

So I have created a piece of software which I wanna package and post to Arch Linux User Repositories, AUR, -should note, that I have never packaged anything for any distro before - and I have also got it packaged and installed on my own machine via Arch's package manager Pacman successfully, but now I am wondering how on earth am I gonna structure the folders and files?
Normally when I wrote software, I use this structure:
build/ | src/ | makefile
As a minimum, and in the case of this piece of software, the makefile does nothing more than compile a .cpp file from src/ to build/.
To make the Arch package, I also had to create a .rc file, to use the program properly as a daemon and the PKGBUILD file, which is the file that tells the makepkg program how to build the installer-package - these two files, though, are specific to Arch.
If I wanna package the program for say debian, I would need another set of files to do this too, but these files only work for debian. Now, I can't just put the .rc file and the PKGBUILD file in to the programs root folder, since that would "be a mess" especially if I also had files to build a package for debian, but where do I put the distro-specific files? I need to have it in the programs root folder -at-least- to be able to keep track of it, and my initial thought was to go with a structure like distro/arch/ for Arch Linux specific files, and then the PKGBUILD file would just run the makefile in the programs root folder and copy the compiled file from build/ to distro/arch/ before it did anything else, but I discovered that I couldnt get PKGBUILD to work that way, and people on #archlinux on Freenode also said it was not a smart idea.
So where do I put the distro specific files? If I knew I only had to provide this program for Arch, it would be easy to just structure it only for Makepkg, but I dont like to imprison the softwarelike that, and I could also imagine providing packages for other mayor distros like debian, so how do I achieve this while keeping a sane file structure?
Regards,
Chris Buchholz
Very often you find in tarballs a directory called 'debian' which has the debian specific files in it. I would go the same route and create a directory 'archlinux' and put the files there.
Then I would go on and put a file README in the archlinux directory that explains how to use the PKGBUILD properly.
One solution could be to write a rule into your Makefile 'package-arch' that copies the PKGBUILD into the root directory, runs makepkg, then deletes the redundant PKGBUILD.
It's hackish, so I would also write a bug report for the Arch people to fix this limitation. However, did you try makepkg -p archlinux/PKGBUILD?

How can I add a package to Qt

I downloaded a package called QtIOCompressor, I need to use the functionality like zipping a directory gzipping a directory etc etc in a application I am coding. But I dont know how to add this package into Qt or how to configure this package by which i can use it with my application which i may code in future!
InfO: http://doc.qt.nokia.com/solutions/4/qtiocompressor/qtiocompressor.html
download: http://qt.nokia.com/products/appdev/add-on-products/catalog/4/Utilities/qtiocompressor/
step: read the INSTALL.TXT that comes with the package and follow the instructions. Basically that is just: qmake and nmake
step: look at the .pro files in the example directory for usage in your program. (you just have to include src/qtiocompressor.pri