Author Topic: troubles executing make from SE in cygwin environment  (Read 7792 times)

Mike H

  • Community Member
  • Posts: 25
  • Hero Points: 3
troubles executing make from SE in cygwin environment
« on: May 25, 2007, 06:08:27 pm »
I have GNU C project that builds fine in a cygwin bash window.  Now I want to have the build process done within SE but am running into troubles.  The project is setup to be used with a user-maintained makefile.
Here is the call from a cygwin window:

mikeh@MHANSEN01 /cygdrive/c/DSP_RFN/codec/gsm/s1_codec/targets/cygwin_i386/test_
codec
$ make USE_EMULATOR=0 all
make: Nothing to be done for `all'.

---------------
Now in SE it doesn't like something:
R: & cd R:\dsp\rfn_dev\gsm\s1_codec\targets\cygwin_i386\test_codec

R:\dsp\rfn_dev\gsm\s1_codec\targets\cygwin_i386\test_codec>echo VSLICKERRORPATH="R:\dsp\rfn_dev\gsm\s1_codec\targets\cygwin_i386\test_codec"
VSLICKERRORPATH="R:\dsp\rfn_dev\gsm\s1_codec\targets\cygwin_i386\test_codec"

R:\dsp\rfn_dev\gsm\s1_codec\targets\cygwin_i386\test_codec>c:\cygwin\bin\make USE_EMULATOR=0 all
make: echo: Command not found
make: *** [obj/downlink_encode.o] Error 127

R:\dsp\rfn_dev\gsm\s1_codec\targets\cygwin_i386\test_codec>
--------------------------

Why would there be an error when this run within SE vs a cygwin window?  Maybe I just don't have a setting right?  I kind of think I need to start a bash shell and run make from there.  Is there a way to invoke the base shell from SE and execute the make from there?

thanks for any help,
Mike

hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 285
Re: troubles executing make from SE in cygwin environment
« Reply #1 on: May 25, 2007, 10:14:01 pm »
Seems that you're using some cygwin tools in the Makefile. This works seamless if you're invoking your build from a cygwin shell (preferably bash). I'm using this simple wrapper (copied it into <cygwin-path>/bin) for my cygwin builds:
Code: [Select]
@REM bashcmd.cmd
@REM ensure proper bash setup running build scripts
@REM PATH is intentionally stripped down to the bare minimum needed by cygwin
@set PATH=%windir%\system32;%windir%&& <cygwin-path>\bin\bash.exe -i -c %*
To launch a shell window you could use this in a e.g. 'bashshell.cmd' script.
Code: [Select]
...
@set PATH=%windir%\system32;%windir%&& <cygwin-path>\bin\bash.exe -i
...

This is my build command in the SE Project Props:
Quote
<cygwin-path>\bin\bashcmd.cmd "cd <build-root>; make all"

The other way is to carefully setup your 'DOS' environment. This is also possible and could figure out the needed env. var's and PATH setup when trying to run make inside a cmd-shell. I had to use this way in another project but it's a bit clumsy...

Good luck,

HS2

Mike H

  • Community Member
  • Posts: 25
  • Hero Points: 3
Re: troubles executing make from SE in cygwin environment
« Reply #2 on: May 29, 2007, 05:47:41 pm »
Thanks for the help, HS2.  It seems to almost work...  I created the bashcmd.cmd file from your reply and filled in the correct cygwin path.  I updated the SE project properties.  The first problem was it couldn't find the make file so I had to give it the full path+execution name for the make to be invoked, i.e.:
C:\cygwin\bin\bashcmd.cmd "cd <proj-dir>; c:/cygwin/bin/make all"

So i think maybe something is not set right with the bash shell invoking when it couldn't find the location of make.  Anyway, once I added the path to make, the build failed with the following error:
>C:\cygwin\bin\bashcmd.cmd "cd <proj-dir>; c:/cygwin/bin/make all"

make: echo: Command not found

make: *** [obj/downlink_encode.o] Error 127

Any other suggestions or advice?

thanks!

hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 285
Re: troubles executing make from SE in cygwin environment
« Reply #3 on: May 30, 2007, 10:42:57 am »
Your bash isn't setup properly. At least you need to setup the PATH that e.g. make[.exe] and echo[.exe] is found. Later on you might need the path to your toolchain too if it's not explicitely set in the makefile.
I attach an example I'm using. It consists of a system-wide (etc subdir) and per-user part (home subdir).
I know it's quite confusing, which config files are read by bash when invoked nteractively or not...

Hope it helps,

HS2

dunkers

  • Senior Community Member
  • Posts: 601
  • Hero Points: 27
Re: troubles executing make from SE in cygwin environment
« Reply #4 on: June 01, 2007, 12:33:59 am »
That's a neat technique, HS2. I do it a bit differently:

In the tools|build dialog I have the command line set to "o:\cygwin\bin\make" (which could, of course, have any command parameter included - "make all" "make clean isntall" etc). To get the environment set up correctly I click the advanced button and then double-click to add an entry of "Set PATH=/opt/ppctools/tools/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin". The opt/ppctools/tools/bin is where my cross compiler lives, and the rest just makes sure Cygwin and its tools can find themselves. No Windows path is needed (and can break a compile due to its length).

I think this is cleaner because once the environment is set you can do on the command line any command line stuff (which can be a bit tricky from a script sometimes). The main drawback is remembering to set the environment for each tool - build, rebuild, compile, etc.

hs2

  • Senior Community Member
  • Posts: 2737
  • Hero Points: 285
Re: troubles executing make from SE in cygwin environment
« Reply #5 on: June 01, 2007, 01:38:57 am »
Hi dunkers,

right, your are doing better. Thanks for this very good hint (HP++) !
I already ripped it to my howto collection :)

However, my solution had 2 reasons:
- other team members still not using Slick (unbelievable !) needed an simple way doing builds too
- the crosscompiler was also located on a linux machine and the (bashcmd) script could be easily changed to run the build as rsh command (preferably using PuTTY->plink).

HS2

dunkers

  • Senior Community Member
  • Posts: 601
  • Hero Points: 27
Re: troubles executing make from SE in cygwin environment
« Reply #6 on: June 01, 2007, 10:19:23 am »
Quote
However, my solution had 2 reasons:

Can't argue with that :)

Mike H

  • Community Member
  • Posts: 25
  • Hero Points: 3
Re: troubles executing make from SE in cygwin environment
« Reply #7 on: June 01, 2007, 07:12:53 pm »
Thanks dunkers and hs2.  Both solutions work for my needs. hs2 was right about the path.  This line in the .bashrc fixed it:
if [ -z $PROFILE_READ ]; then
  echo "sourcing /etc/profile"
  . /etc/profile
fi

hs2, I also have adopted your method for putting all aliases in a separate .alias file. ;D

I'd give HPs to both of you but I don't see the thumbs up icon for doing that. (something about needing 5 posts?).
I think for now dunkers has the simpler solution so I've got that set in my current project.

thanks again,
Mike