I am trying to compile OpenLR on Linux (Ubuntu) using Mono, however, I run into the problem of the compiler (xbuild) not being able to find the project's dependency, Itinero.
I used nuget.exe to install Itinero, but it didn't work. I also tried googling for something like Classpath in C#, but found that C# doesn't have it.
Is there a way to make the xbuild see the dependencies? How can I specify the paths to the directories where those dependencies are?
You have to do a package restore:
git clone https://github.com/itinero/OpenLR.git
cd OpenLR
nuget restore OpenLR.sln
xbuild OpenLR.sln
It should compile with zero errors, there are 27 warnings that need cleaned up in the code....
Note: Make sure the you are on an updated/modern install of Mono as if you are using the default Mono package from Ubuntu you might need to update it:
Ref: http://www.mono-project.com/download/#download-lin
Related
I'm trying to get antlr working in VS. I’ve not touched VS for a very long time. I've added the AntlrVSIX extension per the Antlr online docs, this created a sample calculator project for me but I can't compile it (I uninstalled and reinstalled AntlrVSIX but it made no difference to the following problem).
VS complains “The type or namespace name 'Antlr4' could not be found (are you missing a using directive or an assembly reference?)” and points to the line “using Antlr4.Runtime.Misc;” (and lots more similar).
If I look in menu Tools:NuGet Package Manager:Manage NuGetPackages for Solution… it clearly shows Antlr4.Runtime.Standard present and installed (showing version 4.8.0).
I guess I have to add a reference to this dll to my project so I I right click on References:Add Reference... in Solutions Explorer but I can’t find it in any list, however I search.
There is a Browse button which I assume I could use to link to the DLL directly, so I’ve searched the disk, found the dll and linked to that. This now works in that all those errors go away, but this can’t possibly be the right way.
So how do you add a reference to it properly, using References:Add Reference...? VS knows it’s there, it displays it, but doesn’t let it be referenced like that because it won’t show it within VS via References:Add Reference...
On your specific question, yes, you don't want to add a reference to the dll. Instead, you need to add a "<PackageReference>" in the csproj for these dependencies. All this lives in Nuget.org. So, in VS2019, right click on a project in the Solution Manager, then look for "Manage Nuget packages" to add Antlr4BuildTasks and Antlr4.Runtime.Standard.
Note, I've been updating the Antlrvsix extension, but haven't made a release for 2 months, longer than my usual schedule, because the next version has a huge number of changes. I will be cutting version 8 in a week. The template in VS2019 was removed because it is old and out of date. It uses an ancient version of the Antlr4BuildTasks. Instead, use the Antlr4BuildTasks.Templates v8.1 to create a C# project from scratch. Please follow the directions here. You don't need to download the Antlr tool kit, Java, or set any environmental variables. You also don't even need to use VS2019. You only need Net Core 3.1 and to install Antlr4BuildTasks.Templates. Then, type "mkdir foo; cd foo; dotnet new antlr; dotnet restore; dotnet build; dotnet run" at a command-line shell to create a C# application with Antlr4. Once you create the application, you can modify that to what you need. If you start from a Net Standard or Net Core project that doesn't have Antlr yet, you will need to add in the project reference for Antlr4.Runtime.Standard 4.8 and Antlr4BuildTasks 8.1, add in all grammars, and driver to set up and call the parser--harder to do, but it can be done through VS, or you can edit the CSPROJ file more easily and faster. The Antlr4BuildTasks looks at your CSPROJ file and will see that Antlr4.Runtime.Standard 4.8 is referenced, then will use the correct version of the Antlr JAR file to generate the parser and lexer. Any questions, let me know.
I suggest you using Antlr4.CodeGenerator NuGet package, it's gonna generated all necessary files (visitors, listeners) to work with your grammar in antlr. Check out my article for the details, there is a link to Github repo with the solution that works in VS 2019.
I am trying to set up GTK# to work with mono on windows. the install was successful, and I can get windows forms programs to compile with mono. I have GTK# in my PATH. this is what i get when trying to compile it. i don't see the output it's referencing. i really don't know what to do from this point. i have repaired the install, i have reinstalled it, i have rebooted the computer, but it still didn't work.
thx in advance
If you read the Mono's documentation for Gtk#, it says:
To some of you that have used the csc compiler on windows may notice
the “-pkg:” as a little odd. This doesn’t exist in csc because Mono
comes from the world of Linux. What that does is lookup for a package
config file under that name. In the package config folder exists a
file name “gtk-sharp-2.0.pc” which contains (amongst other
information) on the location of the libraries for that package. That
way we don’t have to type out “-r:gtk-sharp-2.0.dll
-r:atk-sharp-2.0.dll -r:pango-sharp-2.0.dll ….” all by hand.
One would assume that, provided the docs, everything needed to compile is present, including pkg-config, the executable that actually reads the gtk-sharp-x.y.pc file and configures the compilation. However, either it does not exist, or the PATH has not been correctly configured.
First of all get sure that you have installed Mono and Gtk#. I know it seems it is redundant, but both installers are needed.
Then, decompose the compilation command so pkg-info is not needed.
$ mcs -r:/usr/lib/mono/gtk-sharp-2.0/gtk-sharp.dll -r:/usr/lib/mono/gtk-sharp-2.0/atk-sharp.dll -r:/usr/lib/mono/gtk-sharp-2.0/glib-sharp.dll gtksharpdemo.cs
I'm in a Linux machine, so the complete paths to the assemblies won't be those ones. I guess it will be something like:
$ mcs -r:"C:\Program Files (x86)\Mono\lib\gtk-sharp-2.0\gtk-sharp.dll" -r:"C:\Program Files (x86)\Mono\lib\gtk-sharp-2.0\glib-sharp.dll" -r:"C:\Program Files (x86)\Mono\lib\gtk-sharp-2.0\atk-sharp.dll" gtksharpdemo.cs
Finally, this is all much easier if you work with MonoDevelop. You can start your project from the Gtk# 2.0 template, and everything will be set up for you. If you prefer to start from the empty template for some obscure reason, then go to the "references" section of the project, and add "System", "gtk-sharp", "glib-sharp", and "atk-sharp".
This is also all possible from Visual Studio, but I don't have any experience using it.
First, I develop a program with "Any CPU".
Setting is "32 bit priority" and Any CPU. because It was default.
after I finish development, No compile error.
then, I switch Platform x64 and re-compile.
VS2017 show lot of error all installed NuGet package.
I tried to remove folder "obj", "bin". but I can not resolve anything. There is 28 errors. All is class name that I installed with NuGet.
SHould I not switch this ?
Why VS2017 has so many trouble ? Is this normal ?
When I develop with win-form, There is no trouble when I change target x86,x64...
How to resolve this un-linked class ?
All must be work...
My Nuget package is UwpDesktop, InputSimulator.
Update 1: I tried to re-install NuGet. but it does not resolve.
Update 2: I give up to use "x64". but I tried to modify the setting "AnyCPU" for 64 bit. Now, I success to compile again with 64 bit setting. I am also disable to un-check "32bit priority" option too. but.. I still feel big pain with VS2017 development , haha, It's really.
I compared Project setting with
(A) Any CPU = build success, Output folder is bin\Debug\
(B) x64 in Project setting, Output folder is bin\x64\Debug\
Both is "same" Except output folder name.
Is it important ??
I can not understand Why VS2017 can not build.
I think , Main cause is NuGet installed path. I do not know it, because I am 2nd week to learn VS2017, UWP : )
Now, There is still problem,
If I switch back to "x64", I can not compile..
but I can compile "AnyCPU".
Looks like some manual setup is required for that package. I quote https://preview.nuget.org/packages/UwpDesktop/10.0.14393.3
"We are working on updating this package with the latest release. Meanwhile as a workaround please add the following winmds to your project..."
Perhaps you want to downgrade that package and install a previous version, or follow those steps to be able to use it.
First, Thank you Tetsuya, Leo, bradbury9 for many hint.
I resolve this issue by my self.
As Leo wrote , Here is solution.
NuGet will install the dll to the Debug folder by default
To build with "Release" , We have to copy necessary DLL from "Debug" to "Release".
and Sometime, We have to copy x64/Release , x86/Release folder too.
perhaps Im getting old but Im really confused on how to use a nupkg on Linux. Resolving and installing dependencies/adding libs for C is easier for me (never would thought I would say so).
I got a package from a vendor (YYYYY_linux.3.0.77.nupkg) and want to run their example code (version for windows with visual studio worked out of the box) but they told me their linux pack would also work.
What I did:
dotnet init
... coding ...
dotnet restore
dotnet build
/home/tobiass/code/XXXX/Program.cs(27,11): error CS0246: The type or
namespace name 'YYYYY' could not be found (are you missing a using
directive or an assembly reference?)
Afterwards I tried two things:
1.
I edited NuGet.Config
dotnet restore
The nupkg shows up as a feed.
But I still get the same error.
2.
I also tried to create a local feed
mono nuget.exe add ../YYYYYYY_linux.3.0.77.nupkg -source ./
but it always results in
The requested feature is not implemented.
What is the correct way on Linux to add a library? Must it be also a part of project.json? Some config in .nuget?
Best,
Tobias
I suspect your project is not a .NET Core project so you should be using nuget.exe instead of dotnet.
So first I would take a look at the example code. Does it have a .csproj file? Does it have a packages.config file? Does it have a packages folder with the .nupkg file in it already? If so then nothing needs to be done and it should just compile.
From the error message one or more of the above are not correct. If the project file (.csproj) has references to the files in the NuGet package and there is an existing packages.config file then all you need to do is restore the package. To do that you need to put the NuGet package somewhere so it can be restored. You could simply just copy the .nupkg file into ~/.local/share/NuGet/Cache/ which is the machine cache for all NuGet packages and then restore it into the project by running nuget restore Path/To/YourSolution.sln.
If the project does not have a packages.config file then you would need to install it into the project. The simplest way would be to use MonoDevelop. That has built-in support for adding NuGet packages to projects.
Otherwise you could just unzip the .nupkg file and copy the files where they need to go into the solution's packages directory based on the information in the .csproj file.
I downloaded Python for .NET.
Inside the zip is clr.pyd, nPython.exe, Python.Runtime.dll and 2 debug database files.
I put the clr.pyd and Python.Runtime.dll in my python DLLs dir C:\Python27\DLLs thinking this is all that's needed for installation. I then open up the Python GUI and type import clr and I get:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import clr
SystemError: dynamic module not initialized properly
New to python but not .NET and want to use the CPython and not IronPython. What am I missing in this installation? The readme of Python for .NET says there is an installation for Windows package but all I found was the zip file.
The proper way to load CLR in Python is like this:
Make sure no old stuff is left from Python.NET in Python installation folder (e.g. C:\Python27). In my case I had legacy clr.pyd in one of folders. Note that pip for some old versions did not remove all parts of Python.NET.
Append the directory with Python.NET files (clr.pyd and Python.Runtime.dll) to sys.path
Now you can load CLR the most flexible way without even installing to Python directories!
You can compile from source on github:
pip install git+https://github.com/pythonnet/pythonnet
or use Windows wheels/installers from Christoph Gohlke:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pythonnet
PyPI package is available for installation from pip:
https://pypi.python.org/pypi/pythonnet
More installation options such docker, WinPython, conda, nuget, choco are listed here:
https://github.com/pythonnet/pythonnet/wiki/Installation
The correct way to install Python for .NET is to copy ALL the files from the .zip into the directory that contains your .py file.
Then if you execute
python yourfilename.py
you should find that your "import clr" statement works. I have tested this using python 2.7 x86 and pythonnet-2.0-Beta0-clr4.0_140_py27_UCS2_x86.zip
I was able to replicate your error by only copying the clr.pyd file into my working directory.
Note that I was unable to make this work in Python 3.3 x86 or Python 3.3 x64
I actually took matters in to my own hands here and created a Python.Net Chocolatey package.
to install, simply run
cinst pythonnet
at the command line. Maybe this will help users having issues getting this to run.
I don't know why yet but the only way I could get it to work is to copy those 3 files into the C:\Python27\ directory directly.
If you are planning to freeze with py2exe or pyinstall be sure to install the dev version. There is something wrong with the 2.0.0 release when packaged with py2exe, pyinstaller and maybe other freezers. But 2.1.0.dev1 works well. So...
pip install --pre pythonnet
And you'll have to add the pythone.runtime.dll to the bundle (see docs for your preferred bundler).
There is also a problem with how py2exe loads the dll when using bundle_files: 1 (single exe).