Disclaimer: I just made by hello world with gmcs yesterday
Problem
I want to use fastJSON in my project using gmcs.
How do I
compile the project, consisting of 10 or so files into a library?
statically link against that library with my 1-file project?
"install" the library on my system?
Imagined Solution
cd ~/fastJSON
gmcs --blahblah=fastJSON.csproj
cd ~/myProject
gmcs --yadayada=static ~/fastJSON/fastJSON.lib main.cs
The easiest solution is to use xbuild to build the fastJSON project:
cd path/to/fastJSON
xbuild fastJSON.csproj
This will build a library (.dll) somewhere (typically in the bin/Debug subdirectory, but it can be changed in the project file so it may be somewhere else for fastJSON).
Now you have the library, and you reference it like this when compiling your code:
gmcs -r:path/to/fastJSON.dll mycode.cs
You don't need to install the fastJSON library on your system, just put it next to your executable.
according to the man page, you need to use the -r command line option:
gmcs -r ~/fastJSON/fastJSON.dll main.cs
Related
I have been running into an error lately trying to run some code with dotnetcore. When I try to run the project in the console (dotnet run), I get this error.
Unable to run your project.
Ensure you have a runnable project type and ensure 'dotnet run' supports this project.
A runnable project should target a runnable TFM (for instance, netcoreapp2.0) and have OutputType 'Exe'.
The current OutputType is 'Exe'.
FYI, here are entries in the .csproj file
Also, I have the following skds and runtimes installed. Yet, whatever TargetFramework I set in the .csproj, I get the same error.
I found a solution to my issue.
The problem was that I had created the project using Visual studio. Hence, the .csproj project file was not in a suitable format for dotnet core.
To solve the issue, I created an empty project with dotnet core:
mkdir myNewApp
cd myNewApp
dotnet new console
Then, I added to the project all the source files I had created with visual studio by simply copying and pasting them in the app folder. I grouped them in the single directory 'src'. At build, dotnet core automatically finds these files and builds the project with them.
Mine is an Azure Durable function. I got the following error when I try to run it with dotnet cli using the command dotnet run.
Unable to run your project.
Ensure you have a runnable project type and ensure 'dotnet run' supports this project.
A runnable project should target a runnable TFM (for instance, net5.0) and have OutputType 'Exe'.
The current OutputType is 'Library'.
The solution is simple. You cannot use dotnet cli for this. Instead You need to run using the command func start as explained here.
And of course you need to install the azure function tools.
Most probably it is do something with the version you are trying, in my case, I was using .nerstandard 2.0 which was wrong and I changed it to net5.0 and I was able to run successfully.
It looks like this now -
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
I have experienced the same problem that the project refuses to create an EXE file. It was showing to compile a DLL, yet required an EXE to run.
I was using dotnet core and VS-Code and didnt suspect anything until I tried to rename the project folder to start another with the same name. What I got was greyed out folder/file names for some time about 10 sec with no name change.
Only then I realized: though I deleted "bin" folder, there was an instance of the project somehow running alive but hidden (should have prevented me deleting folder otherwise) and prevents any new EXE to be written.
Solution you might ask, simple: just close/restart IDE completely. Any program spawned with it will be terminated. trying to close/terminate terminals do not work.
Open CMD.EXE and run the following commands:
dotnet new console -o myApp
cd myApp
dotnet run
It works for me.
https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/run
reference Scrapy In Projects
This is what I do
1.create a new python project,create a new .py file;
2.reference Scrapy-master project(even I don't know how to do it);
3.write import in the new python file:
from scrapy.selector import Selector
from scrapy.http import HtmlResponse
4.the IDE report unresolved reference error(of cause):
and I don't know what to do to fix it.
Do I do the right thing ? Does it work?
In order to use/reference Scrapy in your project, your project's Python interpreter should be able to locate it. So install the Scrapy library and PyCharm will be able to load without an issue.
Install using Pycharm Package Management
You can install the package by going to File | Settings | Project Interpreter. Once there, follow the steps given in PyCharm Help Documentation
Install using Command Line
You can install Scrapy using Pip:
pip install scrapy
Or if you want to use your copy of the downloaded scrapy-master for any particular reason, change directory to scrapy-master and run:
python setup.py install
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 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
I am trying to use a specific natural language processor I found written in C# within my python application.
According to past SO posts, it seems as straightforward as:
import compile DLL file
call methods/classes of C# file from within python script with an enclosing wrapper
I have downloaded mono-develop and xamarin studio, have read the docs and attempted to "build" the C# program off of the .sln file, but have not observed any dll file being created
What step or doc am I missing?
https://msdn.microsoft.com/en-us/library/3707x96z.aspx
This link provided from MSDN shows how to compile DLLs. You use the developer command prompt which is installed when you install any version of Visual Studio.
From the link, here is an example format:
csc /target:library /out:MathLibrary.DLL Add.cs Mult.cs
You can build a solution with xbuild. check this out for more information: Microsoft.Build
or you can just download mono develop and open the solution with it and just click build. it would create the output dll file in the bin folder.