Building F# .fsproj on Mac (Mono) - macos

I have an .fsproj (and .sln) from an F# project that was developed on Windows that I want to build on the Mac.
I've built several single-source-file F# programs with Mono, and it's great. Unfortunately, this .fsproj is non-trivial, as there are several source files and a number of references.
Devising the command line to build the project by hand doesn't seem fun.
Is there a tool that will analyze the .sln/.fsproj and give the correct command line? Or perhaps just do the build from the .sln/.fsproj?
I'd like to do this without MonoDevelop or SharpDevelop if possible, though answers along those lines are welcome.

Here is a simple makefile that I use
FSC=/home/john/FSharp-2.0.0.0/bin/fsc.exe
FSFILES= tokenizer.fs BuildTree.fs symtable.fs mkVMCommands.fs codegen.fs
compiler: compiler.exe
compiler.exe: $(FSFILES)
$(FSC) --define:LINUX --debug:full --debug+ $(FSFILES) -o:compiler.exe --sig:sigfile.fs
run: compiler
mono compiler.exe
note that the lines after each target - compiler.exe:... need to be indented with a TAB rather than spaces. If you need reerences, you just add -r "Somefile.dll" to the commandline.

You may want to look at xbuild, which directly read sln and fsproj files and build them on Mono platform.
As #JPW mentioned in the comment, it also works on Mac OS X. Although xbuild's F# support seems to be immature, someone has managed to build F# projects with xbuild on Linux. Hopefully, it is helpful for you to set up the build environment on Mac.

Related

How to add a kit to Qt Creator from the command line, or other programmatic manner? [duplicate]

SO!
Let's say I have a number of settings (GCC compiler 9.3.0 built from source, as the distribution I have to use has a very old one, along with environment setup) for a new Kit in QtCreator.
I have managed to setup an environment for compilation and execution of compiled binaries, and made a script to make it work (like qmake -nocache -recursive/make/sudo make install, direct execution of g++, and other stuff).
One thing that script can't do at the moment, is that it cannot create a kit for QtCreator with new compilers and environment being set as required, so after running a script, its user has to go through setting it up himself through GUI, which is bad, because this can cause misconfiguration.
This thing I'm trying to create is going to be used by around ~200 people in my company, so leaving readme.txt with instructions just doesn't go well enough for me - I don't want running around fixing missing "{" and "}" in Environment description in created Kits, and other stuff.
Are there ways to create Kits for QtCreator automatically from command line? Maybe, there's some files to edit?
I've looked into this one a few years back (I wanted to do something similar for registering Buildroot toolchains automatically in QtCreator), and I was unable to find an off the shelf solution. So i think there are 2 ways to implement this:
a) Implementing a command line utility the manipulate the ~/.config/QtProject/qtcreator/{toolchains,profiles}.xml files. Maybe by (re)using the existing C++ implementation within QtCreator, or just re-implement it ie. in Python. Back than I didn't start to work on this as there was no real business need.
b) Switching to qbs, as qbs has support for setting up toolchains from the command line ( see: https://doc.qt.io/qbs/cli-setup-toolchains.html)
If you decide to go with solution a), please let me know and maybe we can partner up to implement it.
Check out the command line sdktool bundled with QtCreator:
The SDK tool can be used to set up Qt versions, tool chains, devices
and kits in Qt Creator.
There still is a lot of knowledge about Qt Creator internals required
to use this tool!
I haven't tried it yet, but I did find the executable under Tools/QtCreator/libexec/qtcreator subdirectory of the Qt Creator installation directory. ./sdktool --help works for me under Linux.

XERCES XML parser

I am relatively new to programming and have been tasked with writing an xml parser using Xerces. My project is in c++ on Microsoft Visual Studio 2015. Are there any good examples for Xerces being used on Windows? I have looked through Apache and it is horrible and has been talked down on by all my coworkers. Most of the help I've found has been for Linux command line or overly complicated examples for specific use cases. Is there anywhere to find a simple example of xerces being used to parse a simple, known xml file? Thank you for any and all help as it is much appreciated!
The official Xerces documentation provides a lot of examples using both DOM and SAX parsing technique. You can find it here: https://xerces.apache.org/xerces-c/samples-3.html.
In order to build the examples and use them as direct references for your code, you have to follow the build instructions in https://xerces.apache.org/xerces-c/build-3.html.
For my personal requirements I created a VS 2013 solution for both Xerces library generation and samples compilation. The command to invoke for generation of the VS solution should for you be something simliar like
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=D:\libs \path\to\xerces-c\source
where you can set the destination path of the output files via CMAKE_INSTALL_PREFIX , while \path\to\xerces-c\source should be the top level directory of the Xerces download, where the CMakeLists.txt file is located. Naturally you will need to install cmake on your Windows computer, which can be downloaded here: https://cmake.org/download/
Finally in order to start the examples, just use the generated VS solution or open a command prompt and start the desired program. For example use the "DOMPrint" application by calling .\DOMPrint.exe xxx.xml. The location of the binaries is in ${CMAKE_INSTALL_PREFIX}/bin.
Please be aware that you will have to compile or provide the Xerces .dll files to be able to start any programm related with the library. It also can be built using the generated VS solution out of cmake.
Please don't hesitate to ask further questions, if the issue is still up-to-date!

Visualstudio makefile (NMAKE)

I am in need to create a makefile for visual studio. however the documentation for this on Microsoft websites is very gently speaking: lousy. Googling doesn't help either. Could somebody paste a link or simple tutorial on how to create such makefile (for example compiling one program from two cpp files). Also mentioning if include files like in GNU are possible to use (and how to import them in makefile). Or how can i echo something in makefile.
I have seen this but is of not much help.
Try using CMake. It's a cross platform build system. I have used it to generate project and solution files for VS 2010, however there is NMake generator also.
This video should get you started - http://www.youtube.com/watch?v=w9sKd8f0kFo.

Compiling libexif as static lib with Visual Studio 2010 - then linking from Visual C++ project

Is it possible to compile libexif with Visual Studio 2010? I have been trying to do so and have been running into a whole slew of problems. I cannot find any information about whether anybody has successfully done this before. I know I can use MinGW to compile the library, but I am in a situation where I need it to be compiled with Visual Studio and then need to link to it from a Visual C++ app. Is this possible?
To answer your question: Yes it is possible... but it is a bit of a hack. Libexif uses functions that MSVC has chosen not to implement. See my working example VS2010 project below (if you don't like downloading files then skip to my explanation of what needed changing to get it to work below):
https://www.dropbox.com/s/l6wowl8pouux01a/libexif-0.6.21_CompiledInVS2010%2BExample.7z?dl=0
To elaborate, the issues that needed a "hack" (as hinted in the LibExif readme-win32.txt documentation) are:
Libexif uses inline in several places which is not defined in VS for C, only C++ (see this)
Libexif uses snprintf extensively in the code which is not defined in VS (see here)
You need to create the config.h yourself without a ./configure command to help you. You could read through the script but most of it doesn't make sense for Windows VS2010.
You will need to define GETTEXT_PACKAGE because it's probably setup in the configure file. I just choose UTF-8, whether that is correct or not I'm not sure.
There was a random unsigned static * that needed to be moved from a .c file to the .h file as C in VS doesn't allow you to create new variables inside functions in the particular way they were trying to do.
Read the "readme-win32.txt" file. Advice is:
hack yourself a build system somehow. This seems to be the Windows way of doing things.
Don't get your hopes up. The *nix way of doing things is the configuration script that needs to be run first. It auto-generates source files to marry the library to the specific flavor of *nix. The configuration script is almost half a megabyte. Three times as much code as in the actual .c files :) You cannot reasonably get that working without MinGW so you can execute the script. Once you got that done, you've got a better shot at it with a VS solution. As long as it doesn't use too much C99 specific syntax.

How to support both vcxproj to cmake on a project?

I'm developing cross-platform c++ project. The original idea is to work with msvc2010 and later compile for other systems with the help of CMake and Hudson.
It doesn't seem to be convenient manually change CMake files after changes in studio settings.
So, what’s the easiest way: to write parser for vcxproj and vcxproj.filters, or there is another good solution?
It might be useful, from time to time, to do this type of conversion, say for porting. On my travels I've found the following, in no particular order:
Specifically for VS to CMake/GYP:
vcproj2cmake
vcxproj2cmake (not a typo!)
gypify.py is a .sln/solution-reading Gyp file generator. Gyp is a Cmake alternative, currently being used by the Chromium project (base for Google's Chrome browser). Gyp will output Makefile, Visual Studio or XCode build files (see Gyp's '-f [make|scons|msvc|xcode]' switch). This Python script is quite promising, I'm hoping to modify it soon to correctly specify header-containing folders for gcc's '-I' include parameter.
Other Cmake/Make-related conversion tools:
Make It So Converts Visual Studio solutions to Linux gcc makefiles
sln2mak C# project
sln2mak Perl script
GUCEF Project includes the ProjectGenerator tool, for Cmake
gencmake (ruby) – KDE Project
'pbtomake' says it can convert XCode xcodeproj/pbproj files to Makefiles (maybe outdated)
Cheers
Rich
You're coming at it backwards -- set up all your CMakeLists.txt and then generate the MSVC project from it.
It shouldn't be hard or time-consuming. Basically you just need to say which directories to look into, declare your include paths, collect your *.cpps for each library with a glob expression, and declare your dependencies.
If you have to set up anything else, then your project probably isn't very portable :-/
The best tool for this purprose is cmake-converter

Resources