Compiling a program on a server - mysql

I'm new to servers and programming in general, and I have a question regarding remote acces to a server, and how much I can actually do on it.
The thin is I have a working program on a linux server, which I acces with my windows machine using mobaxterm. I can acces the server, I see folders and a cmd line, where I can compile a makefile. Everything runs well, however when I run the makefile it just compiles, and doesn't do anything. No error messages, but also no opening of a program. I don't understand anything. Is it a delimitation of the servers structure, that it can only store files on it?

When you compile under linux using a make, it produces an executable but does not run it. Make builds executable objects, but it does not run them. You should include your makefile in the question (reduced to a minimum if it is large). Inside it, you will see that it generates a executable file with a specific name. To run it, you need to invoke this from the command line.
To find out what it is building, a quick way is to type "make clean" (press enter of course) to clean up any built objects. Then type the "ls" command to see what is in your directory.
Next, build the program with the "make" command, then type "ls" to see what has been added. Ignore any new files that end in .o or .a or .so and look for any new files. These are the files built by make and at least one of them is the program you built.
Assuming you found a new file called "myprogram". To run it, type:
./myprogram

Related

How to run a program from Files, coded using MonoDevelop, Gtk#, Ubuntu

I wrote my HelloWorld.cs using MonoDevelop, and Gtk# 2.0. It runs fine in the debugger, and it builds HelloWorld.exe. When I run from a terminal window "mono ./HelloWorld.exe" then the program runs as expected so I know it is coded as expected. However when I attempt to run it by double clicking on it from Files (Linux version of Windows Explorer) it opens Archive Manager with an error "An error occurred while loading the archive".
I am using Ubuntu 18.04.02 LTS, if that makes a difference.
I tried creating a link "ln -s ./HelloWorld.exe ./meow", and double clicked on meow, however that also opens Archive Manager with the same error.
I don't want my end product to require the user to open a Terminal window to run my program, what do I do so that the user can double click on my program from Files to run?
EDIT: [18FEB2019]
Thanks Some programmer dude, I like the bundle idea as I may port this project to a different flavor of linux and I hope this gives me a path to get there.
However, I got error:
Failure to load i18n assemblies, the following directories were searched for the assemblies:
Path: .
In Custom mode, you need to provide the directory to lookup assemblies from using -L
ERROR: Couldn't load one or more of the i18n assemblies: Failed to load I18N.dll
I searched and found
https://www.mono-project.com/docs/tools+libraries/tools/mkbundle/
I followed those directions and got stuck at this part
mkbundle -o CacheServer --cross mono-5.8.0-ubuntu-16.04-x64 CacheServer.exe --machine-config /etc/mono/4.5/machine.config
my error is
ERROR: Unable to load assembly `gtk-sharp' referenced by `/home/amccombs/Projects/HelloWorld/HelloWorld/bin/Debug/HelloWorld.exe'
I tried
mkbundle --fetch-target gtk-sharp
with result
Failure to download the specified runtime from https://download.mono-project.com/runtimes/raw/gtk-sharp
I then tried
sudo apt-get install gtk-sharp
with result
E: Unable to locate package gtk-sharp
Files is detecting the .exe extension as an archive, and therefore it opens it with File Roller or similar.
Just right-click the file HelloWorld.exe and select "Open With Other Application", click on "Find New Applications", and then type "mono" and press ENTER. The app will open.
Another possibility is to create a .desktopfile, and place it under ~/.local/share/applications, with this contents:
[Desktop Entry]
Exec=mono %F
MimeType=application/x-ms-dos-executable;
Name=mono
NoDisplay=true
Type=Application
MKBundle creates a native app from a mono application. The downside is that you have to compile both the app and all its dependencies, which can be tricky. In any case, the package you are looking for is gtk-sharp2.
An alternative to MKBundle is to include a text file, say HelloWorld.sh with the contents:
mono HelloWorld.exe
And then make it executable with:
chmod +x HelloWorld.sh
You can then pack both files together (use a .tar.gz target, which preserves attributes such as the executable one), and probably with a README file explaining to double-click HelloWorld.sh.
Or maybe you can pack the .exe with the .desktop file, and explain in the README file where it must be placed.
There are tons of possibilities.

InstallShield 2014, Custom Actions and executing sql files into MySQL

I am building an installer for our product which works well. I've managed to build custom actions to install our services including a MySQL server.
The problem I have is executing a sql file to build the schema structures.
I have a custom action which uses mysql.exe and the command line arguments:
--port=### --user=### --password=### < "[INSTALLDIR]db\EmptyStruct.sql"
It tries to execute this ok but the cmd window which pops up, during the install, just runs through the mysql.exe command line options, which says to me that the command line it gets passed is not correct. However if I run the command manually after the install, it works perfectly.
Does anyone has any ideas please.
I'm making a few assumptions here:
You have a Windows Installer exe custom action that specifies mysql.exe and a command line as you showed
You are expecting the contents of [INSTALLDIR]db\EmptyStruct.sql to be redirected to mysql.exe's standard input
This will not happen. Behind the scenes, Windows Installer's exe custom action support uses the CreateProcess API and this API will interpret command lines literally. However the redirect < needs special handling to actually perform redirection.
To get that behavior, you must use a layer of indirection. For example, you could run cmd.exe as the exe, and give it a command line that will make it interpret and run the command line mysql.exe --port= ... < "[INSTALLDIR]...". However, if you didn't already have a command prompt showing, this would cause one to show up. If you want to avoid that, you could write a custom wrapper that performs the redirection for you, either as a C++ DLL or, say, InstallScript action.
Alternately, if there is a parameter that tells mysql.exe to run a script from a file, you could pass that instead of using redirection. I wasn't able to find evidence of such a parameter in a quick web search.
Thanks for your comments Michael and I used cmd.exe /k AddStruct.bat to accomplish the task!

How to open a window in Vivado using Tcl script?

I'd like to open a .vhd and .vhi file in window for editing in Vivado from Tcl Console, but I can't find any command for that.
As of at least Vivado 2014.2 any unrecognized Tcl command will be sent to the OS shell for execution, so you can simply open whatever editor you like as if you were not in the Tcl shell. It basically automatically runs exec for you. Older versions you may have to run exec yourself.
eg
nedit file.vhd
Vivado being a design tool works on projects instead of individual files. So to edit a file, say xyz.vhd, the file needs to be part of a project. This can be done through Tcl console by creating a new project, adding xyz.vhd file to it and then loading the project.
Create a new project using the following command:
project -new
Add files:
add_file -vhd "xyz.vhd"
Save the project and run.
project -save
project -run
You can find further resources at this link.

caffe: libglog.so.0 missing (error while loading shared libraries)

I've installed caffe on a server a while ago, and back then it worked properly.
Now I'm following the LeNet MNIST tutorial again (http://caffe.berkeleyvision.org/gathered/examples/mnist.html), and running
./examples/mnist/create_mnist.sh
returns
build/examples/mnist/convert_mnist_data.bin: error while loading shared libraries: libglog.so.0: cannot open shared object file: No such file or directory
I've noticed that liibglog.so.0 is not in /lib which might be the reason for it, but I'm not allowed to copy that file into /lib directory, since I'm not a root user.
Is there workaround for this?
The easiest way to work around the lack of shared libraries in system directories is to use LD_LIBRARY_PATH with the directory where the shared library lives.
Before running the the command that requires a library, run the following in the following the same shell.
export LD_LIBRARY_PATH=~/local/lib
You can also stick this in your .bashrc for convenience.
An alternate solution is to use the following command line flag while compiling, but that requires mucking with other people's build scripts.
-Wl,-rpath,$(DEFAULT_LIB_INSTALL_PATH)

Trying to get RmySQL to work but not understanding bash's export or filesystem conventions

I am trying to install RMySQL on my mac (mavericks) and it errors out when I try to build it from source, saying:
Configuration error: could not find the MySQL installation include
and/or library directories. Manually specify the location of the
MySQL libraries and the header files and re-run R CMD INSTALL.
INSTRUCTIONS:
Define and export the 2 shell variables PKG_CPPFLAGS and PKG_LIBS to include the directory for header files (*.h) and
libraries, for example (using Bourne shell syntax):
export PKG_CPPFLAGS="-I"
export PKG_LIBS="-L -lmysqlclient"
Re-run the R INSTALL command:
R CMD INSTALL RMySQL_.tar.gz
I tried to follow the instructions by entering:
export PKG_CPPFLAGS="-I/usr/local/mysql/include" export
PKG_LIBS="-L/usr/local/mysql/lib -lmysqlclient"
but when I re-run RMySQL it still doesn't work. Moreover, if I type
$PKG_LIBS
to see what that variable holds, I get
-bash: -L/usr/local/mysql/lib: No such file or directory'
I know that /usr/local/mysql/lib exists and it does contain a mySQL header. Am I misunderstanding the instructions?
I'm asking here only after a lot of effort to find solutions and/or work arounds. Sucks being a noob sometimes.
I am going to assume you're trying to get RmySQL to run on R 3.1.0 on Mavericks? Rather than worry about exporting variables etc, here is a simple clean solution for you that should avoid the headaches.
The RMySQL install link Pascal provided above really is your solution. You're probably just stumbling on syntax, or getting things to work from the terminal.
Even if you're a "noob", you should be able to get this working. I'll try to offer a "dummy's guide" walk through here, as I bet there are many others who have this problem too, even after trying to read the RMySQL installation readme.
I would bet with very high confidence the problem is just that you aren't specifying correctly the locations of the library and header folders for compiling. Read the errors carefully when you try to compile... the errors will probably tell you a file/header is missing, or some .so file (shared object) is missing.
One simple way compile RMySQL from source on R 3.1.0, mavericks is as follows (this does not require you to set any environmental variables, no editing of the Renviron file, etc):
Does MySQL work by itself? i.e. Can you open/run it no problems? If not, fix that first.
Find the precise location of your mysql installation. For me, on Mavericks, I see mysql installed at /usr/local/mysql-5.6.17-osx10.7-x86_64 (your version number may be different). There is also another folder /usr/local/mysql which is an alias to /usr/local/mysql-5.6.17-osx10.7-x86_64 (/usr/local/mysql finds the current version of mysql you are using, if multiple mysql file folders exist, I think). In this directory, I see two sub directories (among many) called "include" and "lib". Take a look; "include" will contain header files (include as in #include , etc, in simple C++ programs). The "lib" folder contains compiled source code of the mysql library.
An easy way to compile and install RMySQL which doesn't exactly follow the suggested way to do it in the installation guide is this. Note that this is doing the same thing as in the installation guide, just a little easier as it's one command line from the terminal, once you know where your mysql install folder is. Go to the terminal, and type the following exactly, with one space between each chunk (with your mysql folder name adjusted appropriately for the version number):
PKG_CPPFLAGS="-I/usr/local/mysql/include/" PKG_LIBS="-L/usr/local/mysql/lib/ -lmysqlclient" R CMD INSTALL RMySQL_0.9-3.tar.gz
OR (the same thing, just more typing)
PKG_CPPFLAGS="-I/usr/local/mysql-5.6.17-osx10.7-x86_64/include/" PKG_LIBS="-L/usr/local/mysql-5.6.17-osx10.7-x86_64/lib/ -lmysqlclient" R CMD INSTALL RMySQL_0.9-3.tar.gz
Note for dummies: Make sure when you run this command, that you are doing it from the terminal in the directory that contains the RMySQL_0.9-3.tar.gz file (or whatever the name of your folder is that contains the RMySQL source code)
and RMySQL compiles!
Don't be afraid about trying to compile source code -- it's not just for 'compiled language programmers' or 'computer science graduates'. Most of the time when compiling fails it's just because files are "missing" (there is no corruption on the source code) -- the user hasn't properly specified the locations of the header and libraries (shared objects). Now pull your big boy/girl panties up and just do it .... it's easy.
Notes for people clueless about compiling source code for packages in R:
a) pay special attention to the spacing in the above, otherwise it may not work. Do not have any spaces between the = and the variable/file names (e.g. don't try and have in the above PKG_CPPFLAGS ="-I/usr/local/mysql/include/" as it won't work)
b) When compiling, you want to specify the locations of the header files and the library files and this is what the "-I/ .... " and "-L/ ...." are doing. The -I directory specifies the location of the header files, and the -L the location of the library files. The library files also require the -l[name of library] extension (the -l is short for -lib in the library object names).
c) Note that in the directory /usr/local/mysql-5.6.17-osx10.7-x86_64/lib/ I do not see a file called "lmysqlclient", or even "libmysqlclient", but I do see files named (among others) "libmysqlclient.a" and "libmysqlclient.18.dylib". So don't worry about your MySQL installation not being correct if you don't see a file just called "libmysqlclient" in the lib folder.