can i write in c, c++ then compile with xcode and run in iphone? - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: can i write in c, c++ then compile with xcode and run in iphone? (/thread-8291.html)
can i write in c, c++ then compile with xcode and run in iphone? - sefiroths - Nov 10, 2010 08:05 AM
i'm a neewbie.
i have a mac, downloded xcode.
i would like to make an iphone game and use code written in c, c++.
can i use the code written in c, c++ or the game will launch only in jailbroken iphone?
RE: can i write in c, c++ then compile with xcode and run in iphone? - Skorche - Nov 10, 2010 08:21 AM
Yes. Though you will need at least a little Objective-C code to set up a drawing context and receive events.
RE: can i write in c, c++ then compile with xcode and run in iphone? - sefiroths - Nov 10, 2010 08:49 AM
the game will launch only in jailbroken iphone?
i'd like to find a library of 3d physics, i have found
written in c++, i was wondering if i can use it...
or there is someone in objective-c?
thanks for the very quik answer!!
RE: can i write in c, c++ then compile with xcode and run in iphone? - Skorche - Nov 10, 2010 09:10 AM
No, you can use pretty much whatever language you want on the iPhone. The official tools come with a C, C++, and Objective-C compilers.
For 3D physics, Bullet is probably your best bet. Unity3D has a nice physics engine built in as well, but is not free.
RE: can i write in c, c++ then compile with xcode and run in iphone? - sefiroths - Nov 10, 2010 09:12 AM
many thanks i have downloaded it, now i try
thanks a lot!
RE: can i write in c, c++ then compile with xcode and run in iphone? - sefiroths - Nov 11, 2010 06:14 AM
hi again, i have much problem...
i have downloaded bullet and cmake. (i have tried to do something with cmake but nothing, must retry)
however i think that i can compile all without cmake but using xcode right?
so i have:
1) started a new openglES application in xcode
2) on project->edit project settings i have setted header search path to Add the bullet-2.77/src folder
3) #import "btBulletDynamicsCommon.h" in main.m
4) compiled...many and many error occour
i have readed that i must change properties using Info button in the toolbar, go to the General tab and find the File Type dropdown
Change the filetype from sourcecode.c.objc to sourcecode.cpp.objcpp
but two error appears:
Ld build/Debug-iphonesimulator/provaphys1.app/provaphys1 normal i386
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk -L/Users/sefi/Documents/provaphys1/build/Debug-iphonesimulator -L/Users/sefi/Documents/provaphys1/bullet-2.77/Glut -F/Users/sefi/Documents/provaphys1/build/Debug-iphonesimulator -filelist /Users/sefi/Documents/provaphys1/build/provaphys1.build/Debug-iphonesimulator/provaphys1.build/Objects-normal/i386/provaphys1.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework OpenGLES -framework QuartzCore -o /Users/sefi/Documents/provaphys1/build/Debug-iphonesimulator/provaphys1.app/provaphys1
"btAlignedFreeInternal(void*)", referenced from:
btAlignedAllocator<btHashInt, 16u>::deallocate(btHashInt*) in main.o
btAlignedAllocator<btTriangleInfo, 16u>::deallocate(btTriangleInfo*)in main.o
btAlignedAllocator<int, 16u>::deallocate(int*) in main.o
"btTypedConstraint::serialize(void*, btSerializer*) const", referenced from:
vtable for btTypedConstraintin main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
can somone help me please?
RE: can i write in c, c++ then compile with xcode and run in iphone? - ThemsAllTook - Nov 11, 2010 09:14 AM
Sounds like you've included bullet headers without actually linking to the bullet library. In general, header files define an API at compile time, but don't provide an implementation; the corresponding library (.a) file contains the implementation which is needed at link time. You need to add libbullet.a (or whatever it's called) to the libraries linked in your project.
RE: can i write in c, c++ then compile with xcode and run in iphone? - Nobody - Nov 11, 2010 09:27 AM
Not to be rude, but it seems like you don't have much experience working with C++. if you're planning on doing development for iOS devices (iPhone/iTouch/iPad) and don't have a high level of experience with C++, I'd recommend instead looking into learning Objective-C. After you're comfortable with Obj-C, you can start learning the basics of C++ and integrating projects that use it through the use of Objective-C++.
RE: can i write in c, c++ then compile with xcode and run in iphone? - sefiroths - Nov 12, 2010 04:16 AM
hi, is the first time i use xcode and a mac.
i have follower this instructions to compile bullet:
cmake .. -G "Unix Makefiles" -DINSTALL_LIBS=ON -DBUILD_SHARED_LIBS=ON -DFRAMEWORK=ON \
-DCMAKE_OSX_ARCHITECTURES='i386;x86_64' -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX=/Library/Frameworks -DCMAKE_INSTALL_NAME_DIR=/Library/Frameworks \
sudo make install
ask for a password. when i have installed snowleopard in the profile i have choosed not to have a password, but if i click <enter> says wrong password...
with cmake from gui i have compiled all as an xcode project, and all went well.
i have found that extension of the library is .a so i added statically the library and goes well. thanks
however...how can i solve the password error so i can have the framework?
RE: can i write in c, c++ then compile with xcode and run in iphone? - ThemsAllTook - Nov 12, 2010 09:22 AM
I seem to recall sudo not accepting zero-length passwords, though I could be completely wrong about that. If that's the case, though, you can simply change your user password to something that's not blank, which isn't exactly a bad idea for security anyway.
Installing libraries you're compiling against is generally inadvisable. There's a potential annoyance and a potential danger to this: the annoyance is that you increase the overhead required to build your application on any computer other than your own by making it necessary to install the library first, and the danger is that you inadvertently link to the library in such a way that it requires end users to install it to run your application. Both of these things can be prevented by keeping the library in your project directory and never installing it (as well as being mindful of how you link to it).
RE: can i write in c, c++ then compile with xcode and run in iphone? - sefiroths - Nov 19, 2010 02:04 AM
ok many thanks for advices, so adding library statically as i have done is the best thing if i have understood well...
RE: can i write in c, c++ then compile with xcode and run in iphone? - OptimisticMonkey - Dec 16, 2010 03:02 PM
Also - If you are targeting the iphone, you definitely don't want to build your target using the build settings of 'i386;x86_64' you listed earlier....