artineering / opengles-book-samples

Automatically exported from code.google.com/p/opengles-book-samples
0 stars 0 forks source link

Iphone sample do not build on Xcode4 #1

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Open "Common.xcodeproj" and Build it. (This is successful)
2. Open any other of the iphone chapters and Build it. This fails with the 
following errors:

Ld 
/Users/angus/Library/Developer/Xcode/DerivedData/Hello_Triangle-fypnijhabknpgfcl
msxopbzgnkfq/Build/Products/Debug-iphonesimulator/Hello_Triangle.app/Hello_Trian
gle normal i386
    cd /Users/angus/XcodeProjects/opengles-book-samples-read-only/iPhone/Chapter_2/Hello_Triangle
    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/gcc-4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk -L/Users/angus/Library/Developer/Xcode/DerivedData/Hello_Triangle-fypnijhabknpgfclmsxopbzgnkfq/Build/Products/Debug-iphonesimulator -L/Users/angus/XcodeProjects/opengles-book-samples-read-only/iPhone/Chapter_2/Hello_Triangle/../../Common/build/Debug-iphonesimulator -F/Users/angus/Library/Developer/Xcode/DerivedData/Hello_Triangle-fypnijhabknpgfclmsxopbzgnkfq/Build/Products/Debug-iphonesimulator -filelist /Users/angus/Library/Developer/Xcode/DerivedData/Hello_Triangle-fypnijhabknpgfclmsxopbzgnkfq/Build/Intermediates/Hello_Triangle.build/Debug-iphonesimulator/Hello_Triangle.build/Objects-normal/i386/Hello_Triangle.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework OpenGLES -framework QuartzCore -lCommon -o /Users/angus/Library/Developer/Xcode/DerivedData/Hello_Triangle-fypnijhabknpgfclmsxopbzgnkfq/Build/Products/Debug-iphonesimulator/Hello_Triangle.app/Hello_Triangle

ld: warning: directory not found for option 
'-L/Users/angus/XcodeProjects/opengles-book-samples-read-only/iPhone/Chapter_2/H
ello_Triangle/../../Common/build/Debug-iphonesimulator'
ld: library not found for -lCommon
collect2: ld returned 1 exit status
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 
failed with exit code 1

ld: warning: directory not found for option 
'-L/Users/angus/XcodeProjects/opengles-book-samples-read-only/iPhone/Chapter_2/H
ello_Triangle/../../Common/build/Debug-iphonesimulator'

ld: library not found for -lCommon

Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2 
failed with exit code 1

What is the expected output? What do you see instead?

I expected to see something on the iPhone emulator. Instead I see "Build 
Failed".

What version of the product are you using? On what operating system?

I checked out revision 51. I'm using Xcode4 on OSX 10.6.6.

Original issue reported on code.google.com by angus.fo...@gmail.com on 19 Apr 2011 at 3:34

GoogleCodeExporter commented 9 years ago
I have the same issue... did you ever find a resolution?

Original comment by dougholu...@gmail.com on 11 May 2011 at 3:33

GoogleCodeExporter commented 9 years ago
Looks like the answer lies in the book... Appendix E says you have to build the 
Common project first.  This works on XCode 4 and OS 10.6.6.  The project 
references libCommon.a file

Original comment by dougholu...@gmail.com on 11 May 2011 at 3:57

GoogleCodeExporter commented 9 years ago
Hmm, I couldn't link the libCommon.a to my project for some reason (maybe just 
an unfamiliarity with how to link a static lib properly in XCode4?). I ended up 
just copying the files from the Common project into the test projects. This 
works, but is not very efficient. Is there anything wonky about linking to a 
static library in XCode4?

Original comment by angus.fo...@gmail.com on 11 May 2011 at 5:23

GoogleCodeExporter commented 9 years ago
One need to link the library libCommon.a.   Steps to link the library varies 
from one version of xcode to the other. I currently use XCode 4.0.2.  In this 
version of xCode,  upon highlighting the application, click "Build Phases" tab. 
You should see reference to the "Link Binary With Libraries". Expanding the 
same, you should get the option of add the additional libraries.  Hope this 
helps.

Thanks

Original comment by parthasu...@gmail.com on 11 May 2011 at 9:54

GoogleCodeExporter commented 9 years ago
Yeah, that's what I'm trying to do now... and getting this error (after 
building Common project and linking via the Build Phases tab):

ld: warning: ignoring file 
/Users/angus/XcodeProjects/opengles-book-samples-read-only/iPhone/Common/libComm
on.a, missing required architecture i386 in file.

I'm on 4.0.1, maybe I'll update and see if this is a bug they fixed...

Original comment by angus.fo...@gmail.com on 13 May 2011 at 8:32

GoogleCodeExporter commented 9 years ago
This should work if you build the "Common" project before building the 
individual chapter sample.

Original comment by zyang.po...@gmail.com on 10 Jun 2011 at 10:54

GoogleCodeExporter commented 9 years ago
I'm having the same problem reported in comment 5. I build the Common project 
first and manually copy the libCommon.a to the library search path of the 
Hello_Triangle project. Now the linker reported missing required architecture 
i386 in file. I'm using xcode 4.0.2, I saw -arch i386 is specified in the 
linker command, but I don't know how to remove it in the project settings and 
build phase.

Original comment by angbo...@gmail.com on 15 Jun 2011 at 8:28

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I'm able to build the static Common library and linked it with the sample code 
by changing the Base SDK of the Common project to iphonesimulator.

Original comment by angbo...@gmail.com on 18 Jun 2011 at 3:43

GoogleCodeExporter commented 9 years ago
I add the common folder to the sample code and it helps for chapter 2 and 8 but 
for the rest of the code is not working. Has anybody found a solution?

Original comment by istrateh...@gmail.com on 22 Jun 2011 at 2:36

GoogleCodeExporter commented 9 years ago
I added the libCommon.a to the frameworks via the Build Phase by deleting the 
existing file and dragging & dropping  the file from the Common project and 
everything works fine now.

Original comment by istrateh...@gmail.com on 22 Jun 2011 at 3:02

GoogleCodeExporter commented 9 years ago
To build using XCode 4;

1. create a new workspace (File -> New -> New Workspace)
2. drag and drop the xcode project files into the workspace (e.g. 
Hello_Triangle.xcodeproj, Common.xcodeproj etc..) but be careful not to add a 
project as a subproject of another project.
3. Compile and run

Hope this helps.

Original comment by 20028...@mail.wit.ie on 10 Oct 2011 at 9:30

GoogleCodeExporter commented 9 years ago
The last post doesn't help (why should it? The hardcoded path is still there).

And after creating the linked path manually, I still have the problem described 
in comment 5. 

Original comment by ivanschu...@gmail.com on 3 Sep 2012 at 11:05

GoogleCodeExporter commented 9 years ago
Interesting is that you can't find the linked path even running $ grep -r 
"iphonesimulator" . from the example's root directory. Probably it's binary!?

In a moment of despair I created a new project and copied all the source files, 
also the source files from common and that builds, at least. But I get a black 
screen on the simulator. Will check it tomorrow...

Original comment by ivanschu...@gmail.com on 3 Sep 2012 at 11:59

GoogleCodeExporter commented 9 years ago
The problem seems to be that that the sample code depends on the libCommon.a 
library being built in the project folder.  Recent versions of Xcode hide the 
build products deep inside your ~/Library folder by default, and the other 
projects can't find the library there.

The fix is to tell Xcode to put the build products for the "Common" project in 
the old "legacy" location.

I've tested this with Xcode 4.5.2, and all the sample projects seem to build 
fine now.

Here are detailed instructions:

1. Open the "Common" Xcode project.
2. In the Project Navigator pane on the left side of the window, click on the 
"Common" project icon.
3. Choose "Project Settings..." from the File menu.
4. Click the "Advanced..." button.
5. Select the "Legacy" build location radio button.
6. Click "Done" and "Done" again to close the dialogs.
7. Choose "Build" from the "Product" menu.
8. Select "iPhone 6.0 Simulator" on the right side of the "Scheme" popup.
7. Choose "Build" from the "Product" menu again.  (This builds the simulator 
version of the library.)
8. You're done.  All projects should build fine now, for device or simulator.

Original comment by jbre...@jera.com on 19 Jan 2013 at 11:51

GoogleCodeExporter commented 9 years ago
Thank you so much.

Original comment by attal.be...@gmail.com on 20 Jan 2013 at 8:59