BCB6 Post Build - c++

I am using Borland C++ Builder version 6 and would like to add some method of invoking a batch file after a project build has been performed. There is no direct support in the IDE to do this but I have read that it is possible to modify project makefiles to perform such actions. After much digging around on the internet and experimentation i have still not managed to do get this to work.
The batch file in this case will simply invoke an exe file but may also be required to copy certain build outputs files to system directories for example.
If it makes any difference I am running BCB6 on a Windows 7 x64 laptop.
Regards
FarmerJo

You can run the bpr2mak.exe utility, passing your project *.bpr
bpr2mak.exe Project.bpr
Now you have a Project.mak file and running make.exe:
make.exe -f Project.mak
you'll build the Project.
Don't change make -f Project.mak with make Project.mak or make will try to build target Project.mak of Makefile (you can rename Project.mak in Makefile and simply call make, if you prefer).
Assembling everything in a batch file:
build.bat
#echo off
bpr2mak Project.bpr || goto :error
make -f Project.mak || goto :error
yourCommand_1.exe || goto :error
...
yourCommand_n.exe || goto :error
goto :EOF
:error
echo Failed - error #%errorlevel%.
pause
exit /b %errorlevel%
Of course you can add your additional commands under the appropriate target of the Makefile, but this way you'll have to manually edit the file after every execution of bpr2mak.

Related

VS remote building: "Makefile.Targets error: Cannot copy file remotely to directory"

I'm working on a Makefile project on Visual Studio, modifying code from my laptop and remotely building on a Linux server which i connect to via ssh.
I configured my project Property pages as such:
General: https://i.stack.imgur.com/3WdP6.png
Debugging: https://i.stack.imgur.com/zI5ua.png
Remote Build > Build command line: cd $(RemoteProjectDir) && echo password |sudo -S make
In the remote project directory i have already every file of the project, Makefile too. When pressing Compile i expect VS to copy the changed code from the local directory, file by file, to the remote one, but the only error i get is this:
Linux.Makefile.Target(108,5): error : Cannot copy \foo\bar\file.cpp remotely to /home/user/projects/MyProject/file.cpp
At line 108 of the file with target extension there is this tag:
<CopySources
Sources ="#(FinalSourcesToCopyRemotely)"
AdditionalSources="#(AdditionalSourcesToCopyRemotely)"
ProjectDir="$(ProjectDir)"
RemoteProjectDir="$(RemoteProjectDir)"
RemoteTarget="$(ResolvedRemoteTarget)"
IntermediateDir="$(IntDir)"
RemoteProjectDirFile="$(RemoteProjectDirFile)"
UpToDateFile="$(CopySourcesUpToDateFile)"
LocalRemoteCopySources="$(LocalRemoteCopySources)">
<Output TaskParameter="ResolvedRemoteProjectDir" PropertyName="_ResolvedRemoteProjectDir" />
</CopySources>
Can this file be the cause of the problem for some reason? Is it good to tinker with a .targets file?
I've already remotely build another project before with same configurations and similar Makefile (adapted for paths and file names) and it worked just fine.
[EDIT]:i've added the command echo password| sudo -S make to interact with the password request prompted by sudo, this worked in the other project and i still get the error
You can't use sudo when debugging . So I'd guess you can't use sudo when building either. The problem is sudo prompts for a password and VSLinux can't handle that. One option is to configure sudo so it doesn't request a password but that's not advised. Can you change your setup so it doesn't require sudo?
Long story short: if you get this error, just create another project with the same exact property as the first one, that'll do.
The problem was probably due to the fact that I changed the property several times before using the right one, which could have created some configuration (-ish) file, unchanged after the modifications.

Invoking cmake from Contextual menu

In my work I use to invoke a lot of times cmake, building MSVS solutions. Each time I need to open a cmd line window and call cmake on my sources. I managed to create an alias to only write "cm ../source", which calls "cmake -G "Visual Studio 12" ../source".
I'd like to improve this process by adding an entry in the explorer's contextual menu.
I do not manage, only at once to call cmd.exe and execute "cmake -G "Visual Studio 12" ../source" or whatever : "cm ../source"
I read this very usefull topic
but I don't manage to pass arguments to cmd.exe and execute them :
This doesn't work:
cmd.exe /s /k pushd "%V"call "cm ../source" "%V"
Then I tried to execute a cmd file, and I manage to do it, but it's like to line inside wasn't executed and I don't understand why. My entry in the registry is :
cmd.exe /s /k pushd "%V"&call ".\cmake.cmd"
It correctly calls cmake.cmd (local file in my build directory) file which only contains:
and this executes the cmd file in an infinite loop that I don't understand :
My questions are :
Why this infinite loop. It acts like the file content wasn't executed.
Is there a better way to do without calling a separate file. I'd like to only invoke cmake without having this cmd file.
Thanks a lot :)

MingGW C++ compiler does not work

I am trying to install C and C++ compiler on Windows 8.
I have already installed MinGW, downloaded and installed mingw32-base and mingw32-gcc-g++ packages and the other required packages, added to the user environmet Path the string "C:\MinGW\bin", and I also tried following this guide
http://www.mingw.org/wiki/Getting_Started
so after installation I created a new file named "fstab" containing "C:\MinGW /mingw" in C:\MinGW\msys\1.0\etc because it was only present the file named "fstab.sample".
After all this I typed on cmd : gcc sample.cpp -o sample.exe
and it doesn't work at all returning me an error:
gcc: fatal error: no input files
compilation terminated
But if I typed gcc --version it gives me gcc 4.9.3 etc...
so the packages are installed but I can't compile any of my programs
Are you in the correct directory in cmd when compiling?
You can navigate to the correct one with cd and check if your .cpp is there with ls
possibly some problem with folders. probably you are not compiling from source directory.
Check out this mingw distro by STL. It contains a few .bat files that open a cmd prompt with compiler in PATH. I use these for all my mingw installations. BAT files are to be placed in mingw folder:
mingwvars.bat
#echo.
#echo Setting up environment for using MinGW with GCC from %~dp0.
#set PATH=%~dp0bin;%PATH%
set_distro_paths.bat
#echo off
if not exist "%~dp0bin\gcc.exe" goto epicfail
if "%X_DISTRO%" == "nuwen" goto :eof
set X_DISTRO=nuwen
if exist "%~dp0git\cmd\git.exe" set PATH=%~dp0git\cmd;%PATH%
set PATH=%~dp0bin;%PATH%
goto :eof
:epicfail
color 4f
echo ERROR: You must run %~nx0 from the root of the distro.
echo Don't copy or move this batch file.
title ERROR
goto :eof
open_distro_window.bat
#echo off
if not exist "%~dp0bin\gcc.exe" goto epicfail
if "%X_DISTRO%" == "nuwen" goto :eof
set X_DISTRO=nuwen
if exist "%~dp0git\cmd\git.exe" set PATH=%~dp0git\cmd;%PATH%
set PATH=%~dp0bin;%PATH%
goto :eof
:epicfail
color 4f
echo ERROR: You must run %~nx0 from the root of the distro.
echo Don't copy or move this batch file.
title ERROR
goto :eof
It's a very common error when you are not in the current directory where your source files are residing.
So just navigate to the current directory and run the command it will compile the source code.

Sublime Text 3: how to create a build system?

I m a ROS user. With that framework you usually define a working directory:
$ mkdir -p ~/catkin_ws/src
$ cd ~/catkin_ws/src
// Here create your c++ packages
and then let the system to compile your packages by typing the following:
$ cd ~/catkin_ws/
$ catkin_make
But this means that you should keep at least one more console open, to call the command:
$ catkin_make
which compiles at once all the packages you ve written in that working directory.
Since I m using Sublime Text 3 to write my software I want to be able to call that function from Sublime
I went through this tutorial so many times, but I still don't understand how I can create my building system.
I tried already with the following:
{
"path": "~/workspace_ros",
"cmd": ["catkin_make"]
}
but I get the following error message:
[Errno 2] No such file or directory: 'catkin_make'
[cmd: ['catkin_make']]
[dir: /home/will/workspace_ros/src/flight_system/src/include]
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games]
[Finished]
I tried even with the following options:
path
shell_cmd
but still it doesn't recognize catkin as command for compiling
What's wrong?
PS: in the workspace I have already a CMakeLists.txt file. Calling catkin in the shell compiles everything fine.
I am not sure if this is the best way to accomplish it, but this is what I did. Keep in mind that I did this for a winros project, so for regular ROS projects, you just need to tweak it a bit.
First, I created a build system for the project as follows (so append this to your project file):
"build_systems":
[
{
"name" : "ROS",
"cmd" : ["$project_path/build.bat"],
"working_dir" : "$project_path",
"variants" : [
{
"name" : "Run",
"cmd" : ["$project_path/run.bat"]
}
]
}
]
I then created the build.bat and run.bat scripts referenced in there in the project's root directory (in your case ~/workspace_ros). I created these scripts because there is more to building/running the nodes than just calling catkin_make. You also need to call the setup scripts first.
Here's build.bat
#ECHO OFF
REM Basically, change the cwd to the project's root dir
SET ws_path=%~dp0
cd /D "%ws_path%"
call setup.bat
winros_make -i
You might want to change this to a bash script for your linux system, and tweak the script itself. The idea is to change your cwd to the project's path and call the setup file and build afterwards.
Here's run.bat
#ECHO OFF
REM Call the setup script and launch the node
call "C:\opt\ros\hydro\x86\setup.bat"
roslaunch eyetracker_talker talker.launch
Again, you might need to change this to a bash script. In my case, I use roslaunch to run the node.
Finally, this gives you two build options (Build and Build: Run). The output of both should be shown in the build output window.
Hope this helps.
I realize this is a bit of an old question, but it is still top on google for using catkin with Sublime, so heres my shameless self plug.
I recently wrote a Sublime 3 Package, Catkin Builder that bulids ROS packages inside Sublime. It uses catkin build as opposed to catkin_make but it might help you out.

What exactly does changing/setting a MINGWDIR environment variable do?

I am trying to install boost on code::blocks on a windows 8 computer. I am using mingw as my compiler because of a library I am using. What exactly does changing/setting a MINGWDIR environment variable do and how does this help me install boost?
Many installations, programs, use this variable to quickly watch exactly where there is a certain environment.
For example:
It is easier to work with your own config batch files.
Also install Boost looking for "MINGWDIR".
Below is a generic example.(Nothing to do with boost).
#echo off
if [%MINGWDIR%] == [] goto environment_not_set
goto start_develop
:environment_not_set
echo
#############################################################################
echo Please adjust environment variables within this file:
set MINGWDIR=c:\mingw
echo
#############################################################################
rem instead of setting MINGWDIR here you could also set them
rem within the registry using the system control
:start_develop
set PATH=%MINGWDIR%\bin;c:\windows;
echo MINGWDIR = %MINGWDIR%
:end
pause