Debugging C++ code using Eclipse on Windows

3,071 views
Skip to first unread message

Ike Starnes

unread,
Sep 8, 2011, 3:50:08 PM9/8/11
to android-ndk
I'm having problems trying to debug my C++ code using Eclipse on
Windows.
I've installed CYGWIN and all the prerequisites for Eclipse. I can
build the project fine.
I followed some instructions that I found here:
http://mhandroid.wordpress.com/2011/01/23/using-eclipse-for-android-cc-debugging/

However, when I try to run under the debugger, I get the following
error in the Eclipse Console:
(no debugging symbols found)
(no debugging symbols found)
Remote communication error: Bad file descriptor.

Does anyone have any experience doing this?

Kevin Kowalewski

unread,
Sep 8, 2011, 6:50:36 PM9/8/11
to andro...@googlegroups.com
Hi,

Yes I do have experience with debugging on the Native side of Android.
Can you answer me these following questions that will help me help you?

1. Did you copy the first gdb.setup to gdb2.setup and configure the
Native Debugger to use this setup?
2. Did you take out the target remote:5039 line from gdb2.setup?
3. Did you start the Java (Application) debug mode first, then run
$NDK/ndk-gdb from your projects directory, then return to your project
(in Eclipse) and run the second debugger?
4. Did you issue adb forward tcp:5039 tcp:5039?
5. Is your windows firewall completely disabled?

Thanks
Kevin

Ike Starnes

unread,
Sep 8, 2011, 7:35:14 PM9/8/11
to andro...@googlegroups.com, andro...@googlegroups.com
1. Yes
2. Yes
3. That's the step that fails.
4. No. Did not get to that point yet.
5. No.

Thanks for your help.

> --
> You received this message because you are subscribed to the Google Groups "android-ndk" group.
> To post to this group, send email to andro...@googlegroups.com.
> To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
>

PRIVILEGED AND CONFIDENTIAL: This electronic message and any attachments are confidential property of the sender, LEAD Technologies, Inc. and/or its affiliates. The information is intended only for the use of the person to whom it was addressed. Any other interception, copying, accessing, or disclosure of this message is prohibited. The sender takes no responsibility for any unauthorized reliance on this message. If you have received this message in error, please immediately notify the sender and delete the message you received. Please do not forward this message without permission.

Ike Starnes

unread,
Sep 8, 2011, 9:08:02 PM9/8/11
to andro...@googlegroups.com
By the way, if I start a command prompt, run BASH, and then try to start the ndk-gdb, I get:
ike@IKE /cygdrive/c/Users/ike/workspace/HelloAndroid
$ $ANDROID_NDK_ROOT/ndk-gdb
awk: fatal: can't open source file `/cygdrive/c/Users/ike/workspace/HelloAndroid
/C:\cygwin/usr/android-ndk-r6b/build/awk/check-awk.awk' for reading (No such fil
e or directory)
ERROR: Could not run 'awk' command. Do you have it installed properly?

Kevin Kowalewski

unread,
Sep 9, 2011, 3:52:52 PM9/9/11
to andro...@googlegroups.com
If you're doing this on windows with Cygwin, install awk and try again.

Ike Starnes

unread,
Sep 9, 2011, 4:14:46 PM9/9/11
to andro...@googlegroups.com

I have it already in this path:

C:\cygwin\bin

It came with the CYGWIN install.

 

Also, there are some AWK related files in this path:

C:\cygwin\usr\android-ndk-r6b\build\awk

Which came with the NDK install.

jbierling

unread,
Feb 5, 2012, 10:56:28 PM2/5/12
to andro...@googlegroups.com


On Thursday, September 8, 2011 9:08:02 PM UTC-4, Ike Starnes wrote:
ERROR: Could not run 'awk' command. Do you have it installed properly?


Were you able to work out a solution for this?

felipe valdez

unread,
Feb 6, 2012, 8:46:38 AM2/6/12
to andro...@googlegroups.com
one way out is perhaps looking for win32 gnu utils.


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/3ltJD6Owx5UJ.

To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.



--
312-444-2124
Skype: f3l.headhunter
Casa: 8043901


Yaroslav Barsoukov

unread,
Feb 26, 2012, 3:02:43 AM2/26/12
to android-ndk
I've stumbled upon this problem yesterday and here's what happens.

Awk, gawk and gnu utils have nothing to do with it.

The new NDK has a Windows version of ndk-build, but ndk-gdb is still a
bash script. This doesn't only mean that you need Cygwin to run it, it
also means that everything written in ndk-gdb is written from a Linux
standpoint.

I had an ANDROID_NDK_ROOT environment variable, its value set to "c:
\android-ndk-r7b".
When I ran "bash c:\android-ndk-r7b\ndk-gdb", I got more or less the
same log as Ike Starnes:

=================================
cygwin warning:
MS-DOS style path detected: c:\android-ndk-r7b\ndk-gdb
Preferred POSIX equivalent is: /cygdrive/c/android-ndk-r7b/ndk-gdb
CYGWIN environment variable option "nodosfilewarning" turns off this
warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
awk: fatal: can't open source file `/cygdrive/c/Users/barsoukov/c:
\android-ndk-r
7b/build/awk/check-awk.awk' for reading (No such file or directory)
ERROR: Could not run '/usr/bin/awk' command. Do you have it installed
properly?
=================================

Then I ran ndk-gdb with --verbose, and the problem became clearer:

=================================
cygwin warning:
MS-DOS style path detected: c:\android-ndk-r7b\ndk-gdb
Preferred POSIX equivalent is: /cygdrive/c/android-ndk-r7b/ndk-gdb
CYGWIN environment variable option "nodosfilewarning" turns off this
warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
Android NDK installation path: /cygdrive/c/Users/barsoukov/c:\android-
ndk-r7b
...
=================================

Notice the mangled "Android NDK installation path" at the end of the
log. A quick look inside the ndk-gdb explained what had happened:

=================================
# We need to ensure the ANDROID_NDK_ROOT is absolute, otherwise calls
# to get_build_var, get_build_var_for_abi and run_awk_manifest_script
# might fail, e.g. when invoked with:
#
# cd $NDKROOT
# ./ndk-gdb --project=/path/to/project
#

path_is_absolute ()
{
local P P2
P=$1 # copy path
P2=${P#/} # remove / prefix, if any
[ "$P" != "$P2" ]
}

if ! path_is_absolute "$ANDROID_NDK_ROOT"; then
ANDROID_NDK_ROOT=$(pwd)/$ANDROID_NDK_ROOT
fi
=================================

In other words, ndk-gdb reads ANDROID_NDK_ROOT and checks if it's
absolute, but does so from a Linux standpoint. Since "c:\android-ndk-
r7b" doesn't begin with a "/" and thus isn't an absolute path in Linux
sense, ndk-gdb considers it to be relative and appends it to the end
of the current directory.

To fix this, set ANDROID_NDK_ROOT to the Cygwin's INNER PATH:

/cygdrive/c/android-ndk-r7b

Hope this helps.
> --312-444-2124begin_of_the_skype_highlighting            312-444-2124
> Skype: f3l.headhunter
> Casa: 8043901

Yaroslav Barsoukov

unread,
Mar 1, 2012, 5:00:40 AM3/1/12
to android-ndk
As a general rule of thumb, one should always use the "verbose"
option. This applies to the ndk-gdb script as well as Eclipse's own
build system (there's a "verbose" option on one of the C/C++ debugging
configuration tabs).

Chengyuan Lin

unread,
Apr 28, 2016, 10:14:56 AM4/28/16
to android-ndk
That is really helpful! Thank you very much for pointing this out!
Reply all
Reply to author
Forward
0 new messages