Executable directory where application is running from?

This is the first post on google so I thought I’d post different ways that are available and how they compare. Unfortunately I can’t figure out how to create a table here, so it’s an image. The code for each is below the image using fully qualified names. My.Application.Info.DirectoryPath Environment.CurrentDirectory System.Windows.Forms.Application.StartupPath AppDomain.CurrentDomain.BaseDirectory System.Reflection.Assembly.GetExecutingAssembly.Location System.Reflection.Assembly.GetExecutingAssembly.CodeBase New … Read more

Adding multiple executables in CMake

My suggestion is to tackle this in two phases: Build a library from the .cpp and .h files, using add_library Iterate through all your .cxx files and create an executable from each, using add_executable and foreach Build the library This could be something as simple as file( GLOB LIB_SOURCES lib/*.cpp ) file( GLOB LIB_HEADERS lib/*.h … Read more

How does DOS load a program into memory?

When command.com is asked to execute a .com or .exe file, it will call the interrupt service 21h/AH=4B, the EXEC service. It is up to the calling program to: build a DOS EXEC parameter block (see http://www.delorie.com/djgpp/doc/rbinter/it/90/15.html ) (includes information on environment variables, command lines arguments, FCBs and register values on return) free up all … Read more

How to run SWI-Prolog from the command line?

ISO directive: initialization. This should work. :- initialization main. main :- write(‘Hello World\n’). edit sorry, I skipped over most interesting details. Here is a sample script, let’s say saved in ~/test/main.pl #!/home/carlo/bin/swipl -f -q :- initialization main. main :- current_prolog_flag(argv, Argv), format(‘Hello World, argv:~w\n’, [Argv]), halt(0). and made executable with chmod +x ~/test/main.pl then I … Read more

How to implement readlink to find the path

This Use the readlink() function properly for the correct uses of the readlink function. If you have your path in a std::string, you could do something like this: #include <unistd.h> #include <limits.h> std::string do_readlink(std::string const& path) { char buff[PATH_MAX]; ssize_t len = ::readlink(path.c_str(), buff, sizeof(buff)-1); if (len != -1) { buff[len] = ‘\0’; return std::string(buff); … Read more