GLBasic forum

Main forum => GLBasic - en => Topic started by: marovada on 2013-Jun-30

Title: iPhone.sdk
Post by: marovada on 2013-Jun-30
Is iphone-sdk-4.1 packaged with GLBasic? 

There is a reference to -isysroot"%CYG_GLBASIC%Compiler/platform/iPhone/iphone-sdk-4.1 in the platform.ini file but I can't find iphone-sdk-4.1 in the /Compiler/platform directory.
Title: Re: iPhone.sdk
Post by: bigsofty on 2013-Jun-30
Glbasic had the ability to compile for the iPhone without the need for a Mac and XCode, this was removed to keep Apple happy, this reference may be a remnant of that feature?
Title: Re: iPhone.sdk
Post by: marovada on 2013-Jul-01
It makes sense that Apple wouldn't want its sdk packaged, but how does GLBasic create object files for the iPhone?

I'm asking because xcode will not compile a GLBasic iPhone project against GLBasic object files compiled from iphone-sdk-6 and above. Anyone using the command line in OS X to compile GLBasic projects must therefore have an older version of the sdk which is quite limiting.

Or maybe I'm missing something...
Title: Re: iPhone.sdk
Post by: bigsofty on 2013-Jul-01
GLBasic creates static libs using the GCC ARM compiler, all XCode does is link them. I am using the latest XCode version and it works fine?
Title: Re: iPhone.sdk
Post by: marovada on 2013-Jul-01
I'm talking about creating the static libs.  If you look at the platform ini file, there is a command line for creating the object files that links against isysroot/iphone-sdk-4.1.  It then uses libtool to package the object files into a static library.

I'm linking against isysroot/iphone-sdk-6.1.  I create the object files and then package them into the static lib but I when I create the xcode project and link against the static lib it doesn't compile.

If I use the GLBasic editor to create the static lib then xcode compiles perfectly as you've observed.  My question is what sdk is the GLBasic editor using to make the static lib. 
Title: iPhone.sdk
Post by: Kitty Hello on 2013-Jul-01
I won't say. Can we quit this conversation? ;)
Title: iPhone.sdk
Post by: Kitty Hello on 2013-Jul-01
Oh. You can't link my libs? What error do you get?
Title: Re: iPhone.sdk
Post by: Ian Price on 2013-Jul-01
Quote from: Kitty Hello on 2013-Jul-01
I won't say. Can we quit this conversation? ;)
No! Please continue ;)

Especially since I can't test on my iPod anymore due to XCode. Direct testing would be incredibly useful. After all Gernot, you wanted to see AquaVenture on iOS...
Title: Re: iPhone.sdk
Post by: spacefractal on 2013-Jul-02
Linking libs is not illigal, but not sure what you want to doing?

But compile it without Xcode is illegal, why gernot won't tell and might have been some early test and then removed. The curent sdk weight some gb too and is impossible to include anyway.

Project with Xcode and glbasic still accept by apple and did a recent release of greedy mouse. but iPhone 5 support is required. but damn you can't test it anymore or get a newer used retina iPod.
Title: Re: iPhone.sdk
Post by: marovada on 2013-Jul-02
Quote from: Kitty Hello on 2013-Jul-01
Oh. You can't link my libs? What error do you get?

Sorry, I'm not being clear.

This is for my Mac IDE.  I precompile with GPC.  I want to compile libPROGRAM.a on my mac. The platform.ini file says to do this:

Code (glbasic) Select
Gcc="%GLBASIC%Compiler\platform\iPhone\bin\arm-apple-darwin9-g++.exe" -pipe -c -O3 -marm -mno-thumb-interwork -w -isysroot"%CYG_GLBASIC%Compiler/platform/iPhone/iphone-sdk-4.1" -I"%CYG_GLBASIC%Compiler/platform/iPhone/iphone-sdk-4.1/usr/lib/gcc/arm-apple-darwin10/4.2.1/include" -I"%CYG_GLBASIC%Compiler/platform/Include" -I"%CYG_PROJECT_PATH%" -L"%CYG_PROJECT_PATH%" -DTARGET_OS_IPHONE=1 -DIPHONE %SOURCEFILES%

You can see that it refers to "iphone-sdk-4.1".  I don't have iphone-sdk-4.1

So I do this:

Code (glbasic) Select
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin10-llvm-g++-4.2 -pipe -c -O3 -marm -mno-thumb-interwork -w -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk -I/Applications/Xcode.app/Contents/Developer/platform/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk/usr/include -I/Users/marovada/Documents/GLBasic/Compiler/platform/include -I~/Desktop/Test -L~/Desktop/Test -DTARGET_OS_IPHONE=1 -DIPHONE ~/Desktop/Test/*.cpp

I then package into a lib by doing this:

Code (glbasic) Select
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool -static -o  libPROGRAM.a ./*.o
        chmod 777 libPROGRAM.a


That all works fine, but when I create an xcode project and try to compile against libPROGRAM.a, I get link errors about undefined symbols for armv7s.

So I tried to use iphone-sdk-5.0 to create the libPROGRAM.a file and I got no errors in xcode.  This makes me think that it is not possible (maybe because of armv7s architecture) to create libPROGRAM.a with iphone-sdk-6.0.

There is nothing illegal about this.  Anyone can create a static library for iphone from c++ or obj-c files.

But maybe this is something you don't want to disclose because it involves the inner workings of GLBasic.  If that's the case, I fully understand (although I'm a bit confused about the platform.ini file).  But also, that possibly means that no one can compile an iphone static libPROGRAM.a on the command line using GPC and the latest iphone-sdk, unless I am making some other kind of mistake.
Title: iPhone.sdk
Post by: Kitty Hello on 2013-Jul-05
The libprogram.a is not using any kind of libs to build. Headers are fine from sdk 6.x. My libprogram is armv6, though. Can you change that in you gcc line?
Title: Re: iPhone.sdk
Post by: spacefractal on 2013-Jul-05
armv6 is unsupported today, so you should change it to armv7 (or build two libs)? Yes some users might cant test it anymore, but this is Apple have done.
Title: iPhone.sdk
Post by: Kitty Hello on 2013-Jul-05
armv6 is a subset of armv7.
Title: Re: iPhone.sdk
Post by: marovada on 2013-Jul-06
Quote from: Kitty Hello on 2013-Jul-05
The libprogram.a is not using any kind of libs to build. Headers are fine from sdk 6.x. My libprogram is armv6, though. Can you change that in you gcc line?

I used -march=armv6 but got the same errors.  Maybe it's the version of gcc that comes with sdk 6.1?

The error when I build the iphone xcode project is this:

Code (glbasic) Select
Undefined symbols for architecture armv7s:
  "__GLBASIC__::GLB_LIC_MAIL", referenced from:
      __GLBASIC__::PrepLic() in libGLBasiciPhone-egl.a(glb-full.o)
  "___GLB_Defaults", referenced from:
      -[EAGLView createFramebuffer] in libGLBasiciPhone-egl.a(iPhoneEAGLView.o)
      _iPhoneMain in libGLBasiciPhone-egl.a(glb-full.o)
  "__GLBASIC__::__g_pSubCalls", referenced from:
      __GLBASIC__::CALLBYNAME(__GLBASIC__::DGStr const&) in libGLBasiciPhone-egl.a(glb-full.o)
  "__GLBASIC__::__MainGameSub_()", referenced from:
      _iPhoneMain in libGLBasiciPhone-egl.a(glb-full.o)
  "__GQuitNProfile()", referenced from:
      ___GLB_close_all_filehandles in libGLBasiciPhone-egl.a(glb-full.o)
  "__GLBASIC__::GLB_LIC_CODE", referenced from:
      __GLBASIC__::PrepLic() in libGLBasiciPhone-egl.a(glb-full.o)
ld: symbol(s) not found for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)


It doesn't happen with gcc and headers in iphone sdk 5.

Note that the error is in libGLBasiciPhone-egl.a, but it depends on which version of iphone sdk I use to build libPROGRAM.a.
Title: Re: iPhone.sdk
Post by: marovada on 2013-Jul-09
It's definitely an architecture problem because I'm getting this warning with iphone sdk 6.1:

Code (glbasic) Select
ld: warning: ignoring file /Users/marovada/Desktop/TypeTest/distribute/xcode/Lib/libPROGRAM.a, file was built for archive which is not the architecture being linked (armv7): /Users/marovada/Desktop/TypeTest/distribute/xcode/Lib/libPROGRAM.a

I've tried using the -arch switch when building libPROGRAM.a but no luck.  Gernot, what is the correct command line argument?
Title: Re: iPhone.sdk
Post by: marovada on 2013-Jul-10
I've figured this out in case anyone else wants to know.

ios 6 was introduced with the iPhone 5.  The original iphones had an armv6 processor and iPhone 4 had an armv7 processor.  iPhone 5 has an armv7s processor.  Since the introduction of the iPhone 5, the default is for xcode to build the binary for both armv7 and armv7s.  You can see this in the build settings under 'Valid architectures'.

I was building libPROGRAM.a either for armv7 or armv7s with the -arch switch.  But it has to be built for both (unless you change the 'Valid architectures' to either one or the other.  You wouldn't want to build it only for armv7s). You can build for both architectures by using the -arch switch twice when building libPROGRAM.a ie -arch armv7 -arch armv7s

It's explained pretty well in this article that I was lucky enough to find:http://www.galloway.me.uk/2012/09/hacking-up-an-armv7s-library/ (http://www.galloway.me.uk/2012/09/hacking-up-an-armv7s-library/)

This wasn't an issue building libPROGRAM.a with gcc from the iPhone 5 sdk.
Title: iPhone.sdk
Post by: Kitty Hello on 2013-Jul-10
You gorgot an C++ file to include. gpc_tempg.cpp maybe?
They are definitely in one of these files.
Title: Re: iPhone.sdk
Post by: marovada on 2013-Jul-11
Quote from: Kitty Hello on 2013-Jul-10
You gorgot an C++ file to include. gpc_tempg.cpp maybe?
They are definitely in one of these files.

I included all of the cpp files.
Title: Re: iPhone.sdk
Post by: hardyx on 2013-Jul-11
Quote from: marovada on 2013-Jul-10
It's explained pretty well in this article that I was lucky enough to find:http://www.galloway.me.uk/2012/09/hacking-up-an-armv7s-library/ (http://www.galloway.me.uk/2012/09/hacking-up-an-armv7s-library/)

This wasn't an issue building libPROGRAM.a with gcc from the iPhone 5 sdk.
Then, iOS SDK 6.x needs the library to have armv7 and armv7s architectures. If not, XCode doesn't find the functions defined in the library. We have a problem...
Title: Re: iPhone.sdk
Post by: marovada on 2013-Jul-11
It shouldn't be a problem if you use the GLBasic editor in windows because Gernot has his own program to create the libPROGRAM.a

Edit: Also, you can change the build settings in Xcode to only compile for armv7 bceause armv7s is backward compaitable with armv7.  Anyway, GLBasic editor in windows works fine.  I'm compiling from the command line on a Mac and I've found a solution, so no problem.