Iphone - device - linker error - objective-c

I have added libpng to my application. If I build for simulator, everything is OK. When I build application for device, I got linker error:
Undefined symbols for architecture armv7: "_png_init_filter_functions_neon", referenced from: _png_read_filter_row in libpng-arm7-release.a(pngrutil.o)
I have build libpng manually from source, same way for simulator and device (only with changed target of compilation). I have tried to find this problem, but noone seems to post anything about this problem.

I "solved" this by replacing lines 117-121 in libpng's pngpriv.h:
# ifdef __ARM_NEON__
# define PNG_ARM_NEON_OPT 2
# else
# define PNG_ARM_NEON_OPT 0
# endif
by
#define PNG_ARM_NEON_OPT 0
This disables ARM's NEON optimizations, which seems to be the cause of the problem.
This is merely a workaround though, I didn't have time to investigate the real cause of the problem further.

Adding to PSyton's comment, here is how we solved it.
Compile the arm/*.c files. This however does only work for Android. For iOS, we additionally had to create a new pnglibconf.h with the entries:
#undef PNG_ARM_NEON_API_SUPPORTED
#undef PNG_ARM_NEON_CHECK_SUPPORTED
#define PNG_ARM_NEON_OPT 0
Looking at the ARM defines in libpng, it seems like they are a bit buggy currently, as PNG_ARM_NEON_API_SUPPORTED should be sufficient to turn NEON compilation off.

I experienced a similar error on macOS.
After getting libpng from the source
https://sourceforge.net/projects/libpng/files/
and compiling with the PNG_ARM_NEON option off, the error disappeared.

Related

CocoaFob - linker command failed with exit code 1

This is a weird error! I'm getting:
ld: framework not found CocoaFob
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've checked all my build settings - and they appear correct. CocoaFob.framework is in my Linked Frameworks and Libraries - showing healthy and black. For some reason though, the damned framework isn't found when I try to link. Does anyone have any ideas?
Once possible clue is that when I try to the cocoafob application ( from here: https://github.com/glebd/cocoafob ) I get exactly the same error. I'm using Xcode 8.2.1
Okay. So the solution for me (and hopefully this will help anyone else who's experiencing a similar problem) was to:
build CocoaFob as release (I'd already done this, but in the interests of completeness) copy the resultant built framework to /Library/Frameworks and use it from there.
Do not attempt to use it in the location where it was built! Neither should you create a symlink in /Library/Frameworks to the location where it was built.
This done, all works well. Phew!

My plugin won't load because of a "Wrong architecture"

I'm developing a plugin for a 32bit software.
The coding process is almost done, but to test it, I've got to load my plugin into the software.
There is no warning/error when compiling, but the plugin won't load.
Using the mac console logs, I found out that the error was :
> 17/08/2015 12:04:51,271 Hidden[7518]: Error loading
> /Library/Application
> Support/Hidden/Plugins/MultiUsersPreferences.hiddenplugin/Contents/MacOS/MultiUsersPreferences:
> dlopen(/Library/Application
> Support/Hidden/Plugins/MultiUsersPreferences.hiddenplugin/Contents/MacOS/MultiUsersPreferences,
> 265): no suitable image found. Did find: /Library/Application
> Support/Hidden/Plugins/MultiUsersPreferences.hiddenplugin/Contents/MacOS/MultiUsersPreferences:
> mach-o, but wrong architecture
I tried to change the Architectures (build settings) to
Universal (32/64-bit Intel) (x86_64, i386) - $(ARCHS_STANDARD_32_64_BIT)
But the same error keep poppin' up.
So far, I did not find any solution to set it right, I don't know Xcode enough to do it by my own, does anyone could give me a hint ?
Thanks.
In the project settings, set the architecture to just 32-bit:
Using the 'file' command, you can check the binary's architecture. For example:
$ file /Applications/Calculator.app/Contents/MacOS/Calculator
/Applications/Calculator.app/Contents/MacOS/Calculator: Mach-O 64-bit executable x86_64
Alternatively, change "Build Active Architecture Only" to "No". You're probably building a debug build, which by default on 64-bit machines builds only a 64-bit slice.

Warnings on XCAbstractTest.h, XCTestCase.h, and XCTestSuite.h

I recently turned on stricter warnings for a project, and Xcode started throwing warnings on some of Apple's classes. I'm not sure if this is an Apple bug, or if I'm doing something wrong. I'm using Xcode 6.1.1 on Yosemite.
TL;DR: adding some strict warning flags to your project starts throwing warnings in various XC*Test*.h headers. The issue is intermittent, but the steps below have reproduced the issue on multiple computers.
Steps to reproduce:
Create a new Xcode project via File → New → Project.
Choose iOS → Application → Single View Application.
For Product Name, type MyApp. Choose Objective-C and Universal. Save the project.
Build the project with CommandB. Run the tests with CommandU. Observe that they both finish with no errors or warnings.
Click on the Project to go to the Project Settings.
Click on the blue MyApp Project (as opposed to MyApp or MyAppTests targets).
Click on the Build Settings tab.
Search for Other Warning Flags.
Enter the following string for the Other Warning Flags for the app:
-Weverything -Wno-objc-missing-property-synthesis -Wno-objc-property-synthesis -Wno-direct-ivar-access -Wno-assign-enum -Wno-float-equal -Wno-sign-compare -Wno-switch-enum -Wno-gnu -Wnewline-eof
Build the app again. You should see three or four warnings about treating #import as #import, which is expected given the warnings you just enabled.
Clean the project with CommandShiftK
Build again. You may see extra warnings. If not, then you need to…
Delete the DerivedData folder, at least for this project. It is located at /Library/Developer/Xcode/DerivedData/MyApp-*, where * is some random identifier string. You may also need to delete /Library/Developer/Xcode/DerivedData/ModuleCache.
Clean and build again. And again. It may take a few times. Eventually...
You will see code and documentation warnings on XCAbstractTest.h, XCTestCase.h, and XCTestSuite.h. Screenshot:
As you can see, these warnings would be quite valid on my own code, but this is Apple’s framework code. Is there any way to stop these weirdly intermittent warnings from appearing? Or is it an Apple bug that the file gets warnings at all? I’m leaning Apple bug, because plenty of other Apple headers use #import instead of #import, and none of them is throwing warnings.
Update: I filed a radar: http://www.openradar.me/20038246
Update 2: I was able to glean some more information that may be helpful:
The issue appears to be at least partly related to where Derived Data is stored. See this screen recording, courtesy of Sam Marshall for details: http://cl.samdmarshall.com/a4Hy
Note that, when I reproduce the same steps as in Sam's video on my computer, I am not able to get rid of the extra warnings. They always come back. Possible differences between my and Sam's setups:
Sam is on Xcode 6.1, while I am on 6.1.1.
Sam is on Mavericks, while I am on Yosemite (10.10.2).
When I build in Xcode 6.3b2, I get an additional warning about "building module 'UIKit'". See screenshot: http://cl.ly/a3sK
Update 4: Radar was closed as a duplicate of an issue.
Update 5: I have a workaround, which is to disable the problem warnings on the Tests target only. Here’s a partial diff. Xcode won’t add the $(inherited) automatically, so you’ll have to add it yourself.
+ WARNING_CFLAGS = (
+ "$(inherited)",
+ "-Wno-documentation-unknown-command",
+ "-Wno-auto-import",
+ "-Wno-incomplete-module",
+ );

Connecting HTTPKit to a Theos application project. Undefined symbols error

Aim
I am trying to build the simplest Theos application that is acting like HTTP server.
I have no specific preferences on what libraries to use, but I tried by best using HTTPKit this time. I will appreciate any comments and/or links on how to build such applications.
Question in a couple of words
Failed to use HTTPKit in Theos application project. Getting "Undefined symbols" when using any of the HTTPKit classes.
Personal thoughts
I am sure the "Undefined symbols" error is caused by wrong linking. And I am almost sure that it has to do something with the dependencies folder since I have no idea where to put it and how to link it.
It's not completely neccessary to use HTTPKit, but I am having quite the same troubles trying to implement CocoaHTTPServer in Theos application.
I will also appreciate any comments on what I am doing wrong while installing Theos and making applications.
How I installed and configured Theos
Installed Theos using the following guide
Downloaded everything from one of the headers repository into
$(THEOS)/include
Downloaded (additionally) IOSurfaceAPI.h from here into
$(THEOS)/include/IOSurface
Making a simple project
1.Created a Theos application using NIC
cd ~
$THEOS/bin/nic.pl
NIC 2.0 - New Instance Creator
------------------------------
[1.] iphone/application
[2.] iphone/library
[3.] iphone/preference_bundle
[4.] iphone/tool
[5.] iphone/tweak
Choose a Template (required): 1
Project Name (required): name
Package Name [com.yourcompany.name]:
Author/Maintainer Name [***]:
Instantiating iphone/application in name/...
Done.
2.Put the whole repository HTTPKit into newly created folder
~/name/HTTPSources
3.Added the following line
name_FILES += $(foreach ext, c cpp m mm x xm xi xmi, $(wildcard
HTTPSources/*.$(ext)))
into the Makefile, so it looks like this
4.Put all files from here into newly created
$THEOS/include/HTTPKit
5.Now the $(THEOS) folder looks like this
6.Calling make now doesnot cause fatal errors (except ldid command, which I guess is not vital) resulting in
~/name/theos/makefiles/targets/Darwin/iphone.mk:41: Deploying to iOS 3.0 while building for 6.0 will generate armv7-only binaries.
Making all for application name...
Copying resource directories into the application wrapper...
Compiling main.m...
Compiling nameApplication.mm...
Compiling RootViewController.mm...
Linking application name...
Stripping name...
Signing name...
/bin/sh: ldid: command not found
Trying to use HTTPKit, getting errors
1.Added HTTPKit import and a few simple lines from the example
HTTPServer * serv = [[HTTPServer alloc] init];
[serv handleGET:#"/hello/*"
with:^(HTTPConnection *connection, NSString *name) {
return [NSString stringWithFormat:#"Hello %#!", name];
}];
into ~/name/main.m so it looks like this
2.Now calling make causes "Undefined symbols for architecture armv7" error
~/name/theos/makefiles/targets/Darwin/iphone.mk:41: Deploying to iOS 3.0 while building for 6.0 will generate armv7-only binaries.
Making all for application name...
Copying resource directories into the application wrapper...
Compiling main.m...
Linking application name...
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_HTTPServer", referenced from:
objc-class-ref in main.m.f3071598.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [obj/name.app/name.ba964c90.unsigned] Error 1
make[1]: *** [internal-application-all_] Error 2
make: *** [name.all.application.variables] Error 2
Additional info
find ~/name
make clean all messages=yes
Try adding
export ARCHS = armv7 arm64
export TARGET = iphone:clang:7.0:7.0
to your makefile.
That fixed a similar error for me. If the error is different would you be so kind as to post the output?
I think you missing library. You only have HTTPServer header but lack of implement. Compile HTTPKit and put it on $THEOS/lib. Then add name_LIBRARIES = nameoflibHTTKit in Makefile

FreeType2 Crash on FT_Init_FreeType

I'm currently trying to learn how to use the FreeType2 library for drawing fonts with OpenGL. However, when I start the program it immediately crashes with the following error: "(Can't correctly start the application (0xc000007b))"
Commenting the FT_Init_FreeType removes the error and my game starts just fine. I'm wondering if it's my code or has something to do with loading the dll file.
My code:
#include "SpaceGame.h"
#include <ft2build.h>
#include FT_FREETYPE_H
//Freetype test
FT_Library library;
Game::Game(int Width, int Height)
{
//Freetype
FT_Error error = FT_Init_FreeType(&library);
if(error)
{
cout << "Error occured during FT initialisation" << endl;
}
And my current use of the FreeType2 files.
Inside my bin folder (where debug .exe is located) is: freetype6.dll, libfreetype.dll.a, libfreetype-6.dll.
In Code::Blocks, I've linked to the lib and include folder of the FreeType 2.3.5.1 version.
And included a compiler flag: -lfreetype
My program starts perfectly fine if I comment out the FT_Init function which means the includes, and library files should be fine.
For people who might stumble upon the same problem and can't find it out. I'll post my solution:
It seemed the error code ussualy comes up with loading .dll's. I used process explorer to check if my program was actually loading the correct .dll but it wasn't. I deleted my FreeType dll's and replaced them with a version compiled specifically for my version of windows to make sure I have the right dll's. Replacing the old one with the new one helped.
I had the same problem, turnes out that I had forgotten to copy over the zlib1.dll file.
I had the same "cant correctly start" error. It turned out my program was finding a zlib1.dll in something like c:\intel\wifi\bin, that DependencyWalker flagged as AMD64 (my PC is Win7 64, but my app is 32 bits.) It was fixed when I copied freeType's zlib1.dll to SysWOW64. Tough nut to crack!