Problems building on linux

Of course, but the tutorial isn’t much descriptive on the android sdk/ndk/jdk part, so there’s not much to follow up until the point where I had problems. I’ll just ask guys on the android/ubuntu community.

I think you can refer the official docs of Android.

I think the problem is in JDK though.

EDIT3: TAKING THIS BACK!
OK I’ve managed to make the eclipse compiler find jni.h.

14 more errors to resolve.

How to link JDK in Eclipse:
Right click the project in the Package Explorer.
Enter Properties.
C/C++ Build —> Settings
Tool Settings —> GCC C++ Compiler
Includes> Add new path(icon up right) /pathtoJDK/JDK/include-
It can look like this /home/dany/JDK/include

You don’t need any more, click Apply, then OK. Build it.

Now to the android/log.h not found error =/


EDIT:
add /pathtondk/android-ndk/platforms/android-Xversion you're using/arch-arm/usr/include/ to the includes…

Now I get all these errors:
http://img23.imageshack.us/img23/2543/errorsj.png
http://img31.imageshack.us/img31/9481/warningsc.png

~~:.
Enter Properties.
C/C++ General
Paths And Symbols
Add /pathtojdk/JDK/include and /yourpathtondk/android-ndk/platforms/android-9/arch-arm/usr/include/
Apply.
Click OK.
Click OK.
Build.
38 errors —> 28 errors… restarted eclipse… 22 errors! I think these are only some GCC errors so I don’t know what to do with them… But better then seemingly cocos2d-x related errors. I will disable error on these and see if it compiles. Seems like GCC is really strict on this, maybe it will work it just needs to stop over thinking, haha.
EDIT5:
~~Nope, these errors are real.-

EDIT6:
Is it just me or it looks like Eclipse isn’t compiling using the NDK toolchain?
EDIT7:
… Project properties > C/C++ Build> Edit Tool CHains -> Android GCC; but it’s for whole project I’m afraid it won’t build the linux.

However:

/home/dany/android-ndk/ndk-build V=1 Android NDK: Could not find application project directory ! /home/dany/android-ndk/build/core/build-local.mk:85: *** Android NDK: Aborting . Stop. Android NDK: Please define the NDK_PROJECT_PATH variable to point to it.

:frowning: am I unlucky or stupid?
EDIT8:
I cd to the android folder, run exactly what eclipse does
/home/dany/android-ndk/ndk-build VM=1
Compiles perfectly.

cd to tests folder, same error… =/

anyway thanks for all the great work and trying to help me…

I have followed the tutorial again with all the knowledge I have acquired meanwhile. I have successfully build and run both projects shipped with cocos2dx. Thank you for all your help and I’ll write a better tutorial soon.

Oh and by the way:

the mangling of 'va_list' has changed in GCC 4.4 CocosDenshion line 489, external location: /home/dany/standalonetoolchain/sysroot/usr/include/jni.h C/C++ Problem

Thank you once again.

Hoping for your tutorial, and I would put it to the wiki page.

Hi,

I am also unsuccessful in building cocos2d-x under Ubuntu 32bit. I have tried building the last stable release (0.9.2) as well as the master branch from the git repo.

When I try building the git clone, libbox2d, libchipmunk and libcocosdenshion seem to build just fine. However libcocos2d fails with the following message:

g++ -Wall -g -O2 -fPIC -I.. -I../platform/third_party/linux/libfreetype2 -I../include -I../platform -I../platform/third_party/linux/libpng -I../platform/third_party/linux/libxml2 -I../platform/third_party/linux/libjpeg -DLINUX -c ../actions/CCAction.cpp -o ../actions/CCAction.o In file included from ../include/ccMacros.h:138:0, from ../include/CCNode.h:31, from ../include/CCAction.h:33, from ../actions/CCAction.cpp:27: ../include/CCDirector.h:219:9: error: ‘CCNode’ does not name a type ../include/CCDirector.h:220:34: error: ‘CCNode’ has not been declared ../include/CCDirector.h:472:2: error: ‘CCNode’ does not name a type ../include/CCDirector.h: In member function ‘void cocos2d::CCDirector::setNotificationNode(int*)’: ../include/CCDirector.h:222:3: error: ‘m_pNotificationNode’ was not declared in this scope ../include/CCDirector.h:223:3: error: ‘m_pNotificationNode’ was not declared in this scope make: *** [../actions/CCAction.o] Error 1 cp: cannot stat `libcocos2d.so': No such file or directory

Does anyone have a clue about how to fix that?

On a side note, building the win32 version under Windows 7 with msvc works like a charm. Is there some kind of configuration on g++ that I have to make?

I have resolved the problem, please get the latest code from github.

You are a machine! Thanks heaps, it builds fine now

Can’t build latest git version tests on Linux:

…/…/cocos2dx/platform/third_party/linux/libraries/libcurl.a(timeval.o): In function `curlx_tvnow’:
timeval.c:(.text+0x89): undefined reference to `clock_gettime’
collect2: ld returned 1 exit status
make: ***** Error 1
huh? Builds on android well, works nice so far on HTC Desire w/ 4.0.1, but lots of “called unimplemented OpenGL ES API” on the emulator. I guess you’ve started on the glES2.0 port already? Ahh should’ve stayed w/ stable version haha. Though I believe 0.9.3 will be awesome!

Edit:
Okay few “manual” builds via console there and there, re-importing the projects and it works in eclipse. Really weird though.
Edit2:
Yeah generally if there’s a build problem, use ‘make’ and the build scripts in the folders manually, preferably w/ sudo and it should work again. Last chance, when your eclipse project files get corrupted, re-import the project and set few things like excludes from build and build paths manually and it should work again. And by the way all projects are compiling perfectly w/ Java 7 = great performance boost! It’s not ‘natively supported’ though. All Android is Java 6 only and youmust use nothing from Java 7 - but if you’re lucky you can get all the nice Java 7 optimizations… I didn’t measure it though, maybe there’s something in cc2d-x generated code that backdrops in Java 6.

Hi Dany,

Same thing here, I could not build the tests project with Eclipse but it I could, however, built it via console and the shipped makefile. Probably something skrewed up in my Eclipse project settings.

It’s funny you say that it is building fine for Android though because I seem not be able to build it [libcocos2d.so] at all, neither from console nor from Eclipse. It fails with the message:

/home/felix/Repos/cocos2d-x/cocos2dx/textures/CCTexture2D.cpp: In member function 'void cocos2d::CCTexture2D::generateMipmap()': /home/felix/Repos/cocos2d-x/cocos2dx/textures/CCTexture2D.cpp:594: error: 'glGenerateMipmapOES' was not declared in this scope make: *** [textures/CCTexture2D.o] Error 1

“Not declared in this scope” errors seem quite common, what is the usual cause for this? And why does it only error for this target when it is the same code for any other target?

For reference, the compiler was invoked with the following instructions:

arm-linux-androideabi-g++ -DANDROID -DUSE_FILE32API -I../../ -I"/home/felix/Repos/cocos2d-x/cocos2dx/include" -I"/home/felix/Repos/cocos2d-x/cocos2dx/platform" -I"/home/felix/Repos/cocos2d-x/cocos2dx/platform/third_party/android/libjpeg" -I"/home/felix/Repos/cocos2d-x/cocos2dx/platform/third_party/android/libpng" -I"/home/felix/Repos/cocos2d-x/cocos2dx/platform/third_party/android/libxml2" -O0 -g3 -c -fmessage-length=0 -MMD -MP -MF"textures/CCTexture2D.d" -MT"textures/CCTexture2D.d" -o "textures/CCTexture2D.o" "/home/felix/Repos/cocos2d-x/cocos2dx/textures/CCTexture2D.cpp"

Cheers!

The project dependencies seem to be not loaded. Probably just switch to last working version and stay with it until next stable.

And just build with ./build_native.sh.

OK with the latest stable build building for linux is impossible. Even worse then with 0.9.2. It seems like all relative paths are messed up. Could you PLEASE fix that? Please?

Well… when I mean for linux I mean for android on linux. Linux build is messed up as well, but android is more.

edit:
now even win32 doesn’t work! I’m mad!

Did you build with build_linux.sh?
win32 didn’t work?
I think you may make something mistake.

How to reproduce the same problem:

  1. Acquire new installation of ubuntu
  2. Install Eclipse, Android SDK/NDK and all the dependencies like you would normally
  3. Try to build, run and import C2D-X like the tutorials say
  4. ?
  5. 133 Errors and still counting >.<‘
    Win32 didn’t work either. I followed the tutorials closely and all I got was visual studio crashing when adding new c2d-x project, removing and installing templates didn’t help. And trying to build new android project with cygwin made a lot of “undefined glXXXX” errors.
    Maybe if it will work for you, you could record how you did it on video? Would help a lot. I wanted to do it but I never got to a point I had it 100% working by how the tutorials said it. I could make a video on how to install 0.9.2, with some fixing I remember how I did it. Installing 0.9.2 normally and then pasting 0.10.0 in the same directory got rid of the first eclipse path problem, but created a lot more problems, like missing paths to Box2D. Box2D didn’t build even via ’make’ command, don’t remember the errors, but it found no Box2D directory within the project in eclipse. Removing Box2D & chipmunk manually created even more problems, and even after an hour of cleaning it up it was no help =/
  1. eclipse project for linux has the problem, I have answered it in http://www.cocos2d-x.org/boards/14/topics/5633. I suggest you working under windows.

  2. On win32, you should do the following:
    a. install the template
    b. open cocos2d-win32.vc2008.sln or cocos2d-win32.vc2010.sln, and create a new project by the template. The project should under the root of cocos2d-x, such as HelloWorld.
    c. run build-win32.bat
    d. run the new project

  3. about the problem of building by cygwin, may be you should refer [[Some cautions of Android 4.0]] and [[Build project with ndk-r7]].

  1. But I don’t like windows :frowning: I started liking ubuntu, it’s fast and Gnome3 is really productive. Plus Cygwin is super-slow. Ok I’ll try but here look at sad bunny:

  2. I’m on it, will try reinstalling cygwin first though.

  3. I was aware of this before trying to build.

Ok, you can use makefile, I think eclipse is slow too.
You should do the following:

  1. run build-linux.sh
  2. go to HelloWorld/Linux and run make
  3. run the program generated under HelloWorld/Linux

May be you can use vi of emacs, as I know, they primary tools for the developers working on linux.

Vi isn’t the primary tool of developers working on linux. It’s the primary tool of developers developing linux :slight_smile: Emacs is much more popular. Vi is more of a geek toy.

I’m trying win32 at the moment, visual studio still crashes =/ will try one more time

EDIT:
Ok adding new project works now.

Failed at step 4:

Error 1 error C1083: Cannot open include file: ‘LuaSimpleAudioEngine.h’: No such file or directory d:dx\protoshooter\classes\cocos2dx_support\luaengineimpl.cpp 37 1 ProtoShooter.win32

I’ve renamed everything to be lowercase, but it doesn’t find it, even though it’s there 0.o’