Author Topic: How to set up C::B for Android NDK compiler?  (Read 56356 times)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: How to set up C::B for Android NDK compiler?
« Reply #15 on: November 15, 2012, 09:47:02 pm »
[...]
Your compiler setup is wrong.

Accoridn to your config, you setup a wrong C toolchain executable. If your compiler does not have a GCC, setup the G++ here, too.

I just successfully configured NDK on my PC - so it definitely works with the right setup.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: How to set up C::B for Android NDK compiler?
« Reply #16 on: November 15, 2012, 09:51:01 pm »
Related: because the IsValid() check returns false, we get this "invalid" compiler message instead of attempting to run the toolchain command. It's bizarre that the check is only based on the C toolchain command and apparently not anything else.
Well the reason for this is that i.e. for MSVC you might only have a C compiler and nothing else. So we don't want to have it overdone. the only exception I can think of is to check for if either the C or the C++ executable is present. But the rest we should leave. Remember that there might even be no "make", no "linker", no "resource compiler".

I think IsValid() should return an enumeration that helps to identify what the error is. Or (maybe a bit ugly) a wxString with the exact error description and wxEmptyString if all is OK.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline amarty

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: How to set up C::B for Android NDK compiler?
« Reply #17 on: November 15, 2012, 09:56:41 pm »
Next, The executable are under bin subdirectory of taken directory, but I can't understand, is path incorrect or something wrong then compiler tryed to run.
Well you can - what I told you is true: If you see this message, CodeBlocks cannot find the compiler computed by [list of path's] + compiler executable.

But compiler exact under that path - I try to copy path, paste it to console, type "\bin\", copy and paste execuatable name, press enter - compiler launches.

Fourth, near all fields, near [...] button will be cool if one more button be placed, [AutoLocate] - pressing on it C::B looks for files in "compiler/install/dir/bin" with mack "*gcc", "*g++", "*ar", "*gdb" etc.
Nope. We also support compilers like MSVC where you don't have such executables and even non c/c++ compiler (take Fortran, for example). Also, we support compilers that do not have such a standard folder structure. So your suggestion will break all these cases. the way it is now works for all of them and more.[/list]

Yes, I understand this. I gave just one example of search mask for C/C++ toolset tools. Also, as I see, in that dialog only C/C++ toolsets can be configured.

Offline amarty

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: How to set up C::B for Android NDK compiler?
« Reply #18 on: November 15, 2012, 09:59:51 pm »
I think IsValid() should return an enumeration that helps to identify what the error is. Or (maybe a bit ugly) a wxString with the exact error description and wxEmptyString if all is OK.

Yes, I told about something like your proposal too.

Offline amarty

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: How to set up C::B for Android NDK compiler?
« Reply #19 on: November 15, 2012, 10:12:22 pm »
[...]
Your compiler setup is wrong.

Accoridn to your config, you setup a wrong C toolchain executable. If your compiler does not have a GCC, setup the G++ here, too.

Can you tell me, what is wrong, exact?
Configuring CodeSourcery toolchain in the same manner works fine, and it's executables also named as "arm-none-linux-gnueabi-*.exe".
Also, under Eclipse these executables working fine.
Next, I find another executables in NDK under the deeper path D:\android-ndk-r8b\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\arm-linux-androideabi\bin - they have short "standard" names - gcc.exe, g++.exe and so on, but configuring C::B with that path also reports error.

I just successfully configured NDK on my PC - so it definitely works with the right setup.

Hmm, I can't undestand, why I can't start it work.
My configuration is Win7 x64; C::B 8.05 with MinGW, 32 bit; 32bit NDK.

Can you export your C::B settings for NDK and attach it?
« Last Edit: November 15, 2012, 10:14:50 pm by amarty »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: How to set up C::B for Android NDK compiler?
« Reply #20 on: November 15, 2012, 10:14:20 pm »
But compiler exact under that path - I try to copy path, paste it to console, type "\bin\", copy and paste execuatable name, press enter - compiler launches.
No. You setup "arm-linux-androideabi-gcc.exe" as C toolchain application. This file does not exist. Therefore, your compiler setup is wrong. Thats what the error message tells you.

(...or maybe I misunderstood. Is it working now?!)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: How to set up C::B for Android NDK compiler?
« Reply #21 on: November 15, 2012, 10:16:38 pm »
My configuration is Win7 x64; C::B 8.05 with MinGW, 32 bit; 32bit NDK.
Oh dear - you mean 08/02? You really try to use an IDE that is so old that android did not even exist at that time?! :o
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline amarty

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: How to set up C::B for Android NDK compiler?
« Reply #22 on: November 15, 2012, 10:16:57 pm »
But compiler exact under that path - I try to copy path, paste it to console, type "\bin\", copy and paste execuatable name, press enter - compiler launches.
No. You setup "arm-linux-androideabi-gcc.exe" as C toolchain application. This file does not exist. Therefore, your compiler setup is wrong. Thats what the error message tells you.

(...or maybe I misunderstood. Is it working now?!)

This file exist in my NDK. List of files under "D:\android-ndk-r8b\toolchains\arm-linux-androideabi-4.4.3\prebuilt\windows\bin"
arm-linux-androideabi-addr2line.exe
arm-linux-androideabi-ar.exe
arm-linux-androideabi-as.exe
"arm-linux-androideabi-c++.exe"
"arm-linux-androideabi-c++filt.exe"
arm-linux-androideabi-cpp.exe
"arm-linux-androideabi-g++.exe"
arm-linux-androideabi-gcc.exe
arm-linux-androideabi-gcc-4.4.3.exe
arm-linux-androideabi-gcov.exe
arm-linux-androideabi-gdb.exe
arm-linux-androideabi-gprof.exe
arm-linux-androideabi-ld.exe
arm-linux-androideabi-nm.exe
arm-linux-androideabi-objcopy.exe
arm-linux-androideabi-objdump.exe
arm-linux-androideabi-ranlib.exe
arm-linux-androideabi-readelf.exe
arm-linux-androideabi-run.exe
arm-linux-androideabi-size.exe
arm-linux-androideabi-strings.exe
arm-linux-androideabi-strip.exe

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: How to set up C::B for Android NDK compiler?
« Reply #23 on: November 15, 2012, 10:19:42 pm »
This file exist in my NDK.
Ok - but what shall I say? Even if I setup with this executable, it works for me. Maybe you should try a  nightly (or 12/11-RC1).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline amarty

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: How to set up C::B for Android NDK compiler?
« Reply #24 on: November 15, 2012, 10:21:32 pm »
My configuration is Win7 x64; C::B 8.05 with MinGW, 32 bit; 32bit NDK.
Oh dear - you mean 08/02? You really try to use an IDE that is so old that android did not even exist at that time?! :o
Yes. I use only official releases, not nightly builds or release candidates. And, I'm lazy for installing MinGW separately, so I'm waiting for C::B 12.11.
And what the problem with old C::B? Executables still executables, GCC still GCC.

PS. Sorry, my C::B version is 10.05, 8.02 is my first used C::B version.


UPD Few days ago I'm looking for new C::B, and see news about 12.11-RC1, but can't find link to download this package.
« Last Edit: November 15, 2012, 10:24:19 pm by amarty »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: How to set up C::B for Android NDK compiler?
« Reply #25 on: November 15, 2012, 10:22:25 pm »
...btw: You are not down the road once you made this work I can tell you - you'll need to do a lot low-level stuff in addition so it actually not only compiles, but also links.

My suggestion: Try at the command line first with the "hello world" project. Because you'll definitely need the platform flags, #defines and a lot more to setup your compiler correctly. Its easy if you see the command line one time so you are not stepping in the dark (...at least I found no good tutorial about it).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline amarty

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: How to set up C::B for Android NDK compiler?
« Reply #26 on: November 15, 2012, 10:29:45 pm »
...btw: You are not down the road once you made this work I can tell you - you'll need to do a lot low-level stuff in addition so it actually not only compiles, but also links.

My suggestion: Try at the command line first with the "hello world" project. Because you'll definitely need the platform flags, #defines and a lot more to setup your compiler correctly. Its easy if you see the command line one time so you are not stepping in the dark (...at least I found no good tutorial about it).

Configuring compilers flags for android platfrom seems not hard for me - I can grab them from eclipse build logs, so, I think, this is next step after NDK compiler can run under C::B.  
Currently I'm really thinking about the work from the command line, but using C :: B would be much more convenient.

UPD Setting "C compiler" same as "C++ compiler" to g++ not solve the problem.
« Last Edit: November 15, 2012, 10:33:28 pm by amarty »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: How to set up C::B for Android NDK compiler?
« Reply #27 on: November 15, 2012, 10:44:22 pm »
Configuring compilers flags for android platfrom seems not hard for me - I can grab them from eclipse build logs
Can you provide me with one here, so I can try, too?

Currently I'm really thinking about the work from the command line, but using C :: B would be much more convenient.
Sure, in the end it will be way more convenient - but I said that to get the command line - if you have the Eclipse way - do it like this.

UPD Setting "C compiler" same as "C++ compiler" to g++ not solve the problem.
Well that is weird. What you can try now: Use the EnvVar plugin and clean up your PATH environment variable. You have plenty of compilers in the path, so this may interfere.

Alternatively, just create yourself a batch file like this:
Code
set CB_ROOT=[...DO IT!...]
set WIN_ROOT=[...DO IT!...]

SET PATH=%WIN_ROOT%;%WIN_ROOT\sytem32;%CB_ROOT%
"%CB_ROOT%\codeblocks.exe" %*
...and run it.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline amarty

  • Multiple posting newcomer
  • *
  • Posts: 41
Re: How to set up C::B for Android NDK compiler?
« Reply #28 on: November 15, 2012, 10:59:22 pm »
Configuring compilers flags for android platfrom seems not hard for me - I can grab them from eclipse build logs
Can you provide me with one here, so I can try, too?

Code
**** Build of configuration Default for project GorgeousKarnaugh ****

bash D:\android-ndk-r8b\\ndk-build V=1
Invalid attribute name:
    package
rm -f ./libs/armeabi/lib*.so ./libs/armeabi-v7a/lib*.so ./libs/mips/lib*.so ./libs/x86/lib*.so
rm -f ./libs/armeabi/gdbserver ./libs/armeabi-v7a/gdbserver ./libs/mips/gdbserver ./libs/x86/gdbserver
rm -f ./libs/armeabi/gdb.setup ./libs/armeabi-v7a/gdb.setup ./libs/mips/gdb.setup ./libs/x86/gdb.setup
Compile++ arm    : GorgeousKarnaugh <= GorgeousKarnaugh.cpp
/d/android-ndk-r8b/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-g++ -MMD -MP -MF ./obj/local/armeabi/objs/GorgeousKarnaugh/GorgeousKarnaugh.o.d.org -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__  -march=armv5te -mtune=xscale -msoft-float -fno-exceptions -fno-rtti -O2 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 -I/d/agg-2.5/include -I/f/work/carno/include -I/d/android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/4.6/include -I/d/android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include -I/d/android-ndk-r8b/sources/cxx-stl/system/include -Ijni -DANDROID -Werror -Wa,--noexecstack   -O2 -DNDEBUG -g   -I/d/android-ndk-r8b/platforms/android-14/arch-arm/usr/include -c  jni/GorgeousKarnaugh.cpp -o ./obj/local/armeabi/objs/GorgeousKarnaugh/GorgeousKarnaugh.o && ./obj/convert-dependencies.sh ./obj/local/armeabi/objs/GorgeousKarnaugh/GorgeousKarnaugh.o.d
In file included from jni/GorgeousKarnaugh.cpp:2:0:
d:/android-ndk-r8b/platforms/android-14/arch-arm/usr/include/jni.h:592:13: note: the mangling of 'va_list' has changed in GCC 4.4
Compile arm    : GorgeousKarnaugh <= gkcstuff.c
/d/android-ndk-r8b/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-gcc -MMD -MP -MF ./obj/local/armeabi/objs/GorgeousKarnaugh/gkcstuff.o.d.org -fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__  -march=armv5te -mtune=xscale -msoft-float -O2 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300 -I/d/agg-2.5/include -I/f/work/carno/include -I/d/android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/4.6/include -I/d/android-ndk-r8b/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include -I/d/android-ndk-r8b/sources/cxx-stl/system/include -Ijni -DANDROID -Werror -Wa,--noexecstack -O2 -DNDEBUG -g -I/d/android-ndk-r8b/platforms/android-14/arch-arm/usr/include -c  jni/gkcstuff.c -o ./obj/local/armeabi/objs/GorgeousKarnaugh/gkcstuff.o && ./obj/convert-dependencies.sh ./obj/local/armeabi/objs/GorgeousKarnaugh/gkcstuff.o.d
SharedLibrary  : libGorgeousKarnaugh.so

/d/android-ndk-r8b/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/
arm-linux-androideabi-g++ -Wl,-soname,libGorgeousKarnaugh.so
-shared --sysroot=/d/android-ndk-r8b/platforms/android-14/arch-arm
./obj/local/armeabi/objs/GorgeousKarnaugh/GorgeousKarnaugh.o ./obj/local/armeabi/objs/GorgeousKarnaugh/gkcstuff.o ./obj/local/armeabi/libstdc++.a   
-Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now
-L/d/android-ndk-r8b/platforms/android-14/arch-arm/usr/lib
-lstdc++ -lc -lm -o obj/local/armeabi/libGorgeousKarnaugh.so

Install        : libGorgeousKarnaugh.so => libs/armeabi/libGorgeousKarnaugh.so
mkdir -p ./libs/armeabi
install -p ./obj/local/armeabi/libGorgeousKarnaugh.so ./libs/armeabi/libGorgeousKarnaugh.so
/d/android-ndk-r8b/toolchains/arm-linux-androideabi-4.6/prebuilt/windows/bin/arm-linux-androideabi-strip --strip-unneeded  ./libs/armeabi/libGorgeousKarnaugh.so



UPD Setting "C compiler" same as "C++ compiler" to g++ not solve the problem.
Well that is weird. What you can try now: Use the EnvVar plugin and clean up your PATH environment variable. You have plenty of compilers in the path, so this may interfere.

Alternatively, just create yourself a batch file like this:

Code
set CB_ROOT=C:\Program Files (x86)\CodeBlocks
set WIN_ROOT=C:\Windows
SET PATH=%WIN_ROOT%;%WIN_ROOT\system32;%CB_ROOT%
"%CB_ROOT%\codeblocks.exe" %*
Same result - error.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: How to set up C::B for Android NDK compiler?
« Reply #29 on: November 16, 2012, 12:54:34 am »
Didnt we once have issues with mingw installed on d drive and C::B on c drive on win 7? Did you try putting everything on one drive?