how to add third party dll reference to F# project? - f#

I'm adding a third party dll reference to my F# project. I added the dll in references and when I use this i.e highlight the code and do Alt+Ent, I get the error "The namespace or module 'AZROLESLib' not defined." Am I missing some thing.

In short, you have to use #r "/path/to/AZROLESLib.dll" in order that F# Interactive recognizes and loads the dll file.
Adding a dll reference helps Visual Studio to find correct libraries when compiling the project, but it has nothing to do with F# Interactive. Therefore, you have to use #r directive to point to AZROLESLib.dll. If VS has some troubles to highlight the code,
you may have to open the exact module in your dll file:
open AZROLESLibModule
If the code is in a *.fs file, you may want to distinguish between using fsi and using fsc:
#if INTERACTIVE
#r "/path/to/AZROLESLib.dll"
#endif

for some things you can call them directly by name with no path
#r "EnvDte"
works for vs2013 here for instance

In my case my F# project was referencing a C# DLL but I had the same issue, "The namespace or module 'MyModule' not defined", when doing "open MyModule".
The solution was to edit the settings to use the same framework (one was using 4.5 and the other 4.0).

Related

How to add a cpp file to an existing project in Borland C++Builder 5?

Adding the line #include "newProc.h" to unit1.cpp and unit1.h is not enough. It leads to an error:
[Linker Error] Unresolved external 'newProcClass::newProc()' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER5\PROJECTS\TEST1\UNIT1.OBJ
(newProc.cpp was not compiled)
Make or Build Project1 with unit1.cpp's line #pragma link "newProc" (obj) is ok, but I want to compile the newProc.cpp in each Make or Build process.
Borland C++Builder 5 is very old - but I am pretty sure it still has a project view which shows the files used by the project. Right click on the project and select "Add..." and then navigate to the .cpp file you want to add.
If you use the main menu: File | New, and then select either VCL Form or C++ unit (the latter if you are going to develop a C++ file with no VCL GUI, can still use VCL helper functions and classes), then the file is automatically added to the project, and you don't have to do the above procedure.

In Delphi compiling a library produces an exe extension, is this correct?

I have Delphi Seattle and when I change the "program" keyword in the project source file to "library", and compile/run, it produces an exe. Is this normal? In older copies of delphi it would automatically produce a DLL instead of an exe extension.
Is the solution to change some compiler option or project option setting? There is an output file extension setting, but I thought the compiler would take care of this automatically as soon as you change "program" to "library". In old Delphi 5 it worked.
This may affect other versions than just Seattle, have not tried...
Is this a bug?
The executable extension is a project setting passed to the compiler, but if you want to control it from source, there's the $E compiler directive
If you start a project as DLL, then the library template is used (the one with the long warning comment), and you automatically get the extension .dll.
If you, however, start a project as a normal program (e.g. a console program), the extension is .exe, and that doesn't automatically change if you change the keyword program to library. I don't think it did that in any earlier Delphi either.
So, to get a default .dll extension, use
File → New → Other... → Delphi Projects → Dynamic-link Library
As already said, you can change the extension in the project options too:
Project → Options... → Application → Output Settings → Target file extension
Or simply as {$E DLL} in the .dpr source code.

F# script can't load .Net 4.5?

I have an F# library that uses the .Net 4.5 HttpClient. It compiles just fine but when I try to call functions in the library after loading it in a script the script says it can't find System.Net.Http.
Both the script and the library are in the same project targeted at .Net 4.5.
The library (in TdApi.fs) does this open System.Net.Http; but when the script does this #load "TdApi.fs" the error in the interactive window is this TdApi.fs(6,17): error FS0039: The namespace 'Http' is not defined.
I'm using VS2012 and am just getting started in F#.
There is a difference between a compiled library and a script file.
When you compile your TdApi.fs file as part of a library project, the dependencies (in your case, the HTTP library) are specified in project properties. The compiler uses the fsproj file to find the dependencies (and so everything compiles fine).
When you #load your TdApi.fs file from a script, it does not know about the project - and so it also does not know about the dependencies. To fix this, you can either use #r "TdApi.dll" where TdApi.dll is the compiled library, or you can use something like:
#r "someplace/System.Net.Http.dll"
#load "TdApi.fs"
So, you can use #r to explicitly load the HTTP library first and then TdApi.fs will see it.

Create .dll with Visual Studio

I want to create my own .dll file with visual studio.
The problem is, that I have included Open CV inside my program, because I'm using a method from Open CV.
My question now is, is it possible to create my own .dll file although I'm using a Open CV library? Is the Open CV lib, included inside my own .dll than, or how does it work?
Thank and best wishes,
Andi!
I think you can do this in two ways:
Statically link OpenCV into your DLL
Run-time Dynamically link OpenCV from your DLL
The first one requires you to build OpenCV as a static library (output is a large .lib file, no .dll).
In your own DLL, you specify you want to link with opencv.lib.
The second one requires you to build OpenCV as a dynamic library (output is a small .lib file, and a big .dll).
In your own DLL, you would have to add code to manually load the OpenCV library and find the addresses of the functions you need to call from OpenCV (see https://msdn.microsoft.com/en-us/library/windows/desktop/ms685090%28v=vs.85%29.aspx)

Xamarin Studio Starter: Why am I getting native library reference error on build without native libraries?

I've been playing around with the Starter Edition of Xamarin Studio to determine if it will meet my needs. I understand (so I thought) the limitations of this edition; 32K compiled IL limit, no native libraries, etc. Now, I understand native libraries to be C/C++ libraries, or even native Java libraries. This does not seem to be the case.
I have a solution in Xamarin Studio with 2 projects. One is an Android Class Library, the other is an Android Application. When I reference the class library from the application project and build, I get the following error.
Your app references native libraries. This functionality requires Indie Edition or higher.
I beg to differ! Every .cs file in the referenced Android class library project is simple .NET code. What am I missing? I can successfully run the Tasky Android_Starter solution without issue, and it is made up of 2 projects like mine.
I had to delete the Resources folder and manually edit the Android class library project file in order to get this working. I looked at the Tasky sample's project file as a reference.
After deleting the auto-included Resources folder from the project, edit the .csproj file in a text editor to remove the following XML elements:
Project\ProjectGroup\AndroidResgenFile
Project\ProjectGroup\AndroidResgenClass
With those things taken care of, I no longer get the error. I'm guessing, Xamarin Studio thought I was referencing another Android application instead of a class library. Not sure why the default project template includes things to break such a flow, but perhaps I'm not "doing" right" either. Go figure.
Deleting the Resources folder and manually editing the csproj file didn't work for me. I had to create a new C# Library project instead of creating an Android Library Project and import my .cs files into that. After that it compiled and ran fine.

Resources