I'm getting errors in XCode attempting to build OSG for iOS 7.0. I've followed these instructions:
http://www.openscenegraph.org/index.php/documentation/platform-specifics/ios/23-configuring-cmake-for-ios
with the additional step of changing the framework version to 7.0 in the CMakeLists.txt file, as using the default of 6.0 caused XCode to complain about an unknown framework. I chose the IPHONE_SIMULATOR option.
When I attempt to build the project after generating it with CMake, I get three errors in osgDB complaining about stat64, and one about a missing header (perhaps related but I get the feeling something else is going on):
/Users/clay2/src/OpenSceneGraph-3.2.0/src/osgDB/FileUtils.cpp:153:9: error: call to unavailable function 'stat64': not available on iOS
if( stat64( path.c_str(), &stbuf ) == 0 )
^~~~~~
In file included from /Users/clay2/src/OpenSceneGraph-3.2.0/src/osgDB/FileUtils.cpp:87:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/sys/stat.h:380:5: note: candidate function has been explicitly made unavailable
int stat64(const char *, struct stat64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA);
^
/Users/clay2/src/OpenSceneGraph-3.2.0/src/osgDB/FileUtils.cpp:176:13: error: call to unavailable function 'stat64': not available on iOS
if( stat64( dir.c_str(), &stbuf ) < 0 )
^~~~~~
In file included from /Users/clay2/src/OpenSceneGraph-3.2.0/src/osgDB/FileUtils.cpp:87:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/sys/stat.h:380:5: note: candidate function has been explicitly made unavailable
int stat64(const char *, struct stat64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA);
^
/Users/clay2/src/OpenSceneGraph-3.2.0/src/osgDB/FileUtils.cpp:301:10: error: call to unavailable function 'stat64': not available on iOS
if ( stat64(filename.c_str(), &fileStat) != 0 )
^~~~~~
In file included from /Users/clay2/src/OpenSceneGraph-3.2.0/src/osgDB/FileUtils.cpp:87:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/sys/stat.h:380:5: note: candidate function has been explicitly made unavailable
int stat64(const char *, struct stat64 *) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_5,__MAC_10_6,__IPHONE_NA,__IPHONE_NA);
^
/Users/clay2/src/OpenSceneGraph-3.2.0/src/osgDB/FileUtils.cpp:881:18: fatal error: 'CoreServices/CoreServices.h' file not found
#include <CoreServices/CoreServices.h>
^
4 errors generated.
CMake version is 2.8-12, OSG 3.2.0, XCode 5.0.2.
Various things I've tried:
iphone instead of iphone_simulator setting; iphone complains about openthreads being a dynamic library, even though I unchecked DYNAMIC_OPENTHREADS in cmake. It does, however, appear to make the other errors go away.
Blowing away the build directory and re-doing the config step, several times
Manually setting the framework settings for ios in xcode after configuration
I did previously get an OSX build of OSG to work without issue, for what it's worth.
Related
This question already has answers here:
'filenames are used to distinguish private declarations of the same name' error
(8 answers)
Closed 4 years ago.
my team and I are having problems for compile a Objective C project in Xcode 9.4. Anyone have an idea of what's happening??
<unknown>:0: error: filename "Message+CoreDataClass.swift" used twice: '/Users/josepmmirabent/houtel-ios-2016/Houtel2/DerivedData/Jumbotours/Build/Intermediates.noindex/Jumbotours.build/Debug-iphonesimulator/Jumbotours.build/DerivedSources/CoreDataGenerated/Model/Message+CoreDataClass.swift' and '/Users/josepmmirabent/houtel-ios-2016/Houtel2/DerivedData/Jumbotours/Build/Intermediates.noindex/Jumbotours.build/Debug-iphonesimulator/Jumbotours.build/DerivedSources/CoreDataGenerated/Model/Message+CoreDataClass.swift'
<unknown>:0: note: filenames are used to distinguish private declarations with the same name
<unknown>:0: error: filename "Message+CoreDataProperties.swift" used twice: '/Users/josepmmirabent/houtel-ios-2016/Houtel2/DerivedData/Jumbotours/Build/Intermediates.noindex/Jumbotours.build/Debug-iphonesimulator/Jumbotours.build/DerivedSources/CoreDataGenerated/Model/Message+CoreDataProperties.swift' and '/Users/josepmmirabent/houtel-ios-2016/Houtel2/DerivedData/Jumbotours/Build/Intermediates.noindex/Jumbotours.build/Debug-iphonesimulator/Jumbotours.build/DerivedSources/CoreDataGenerated/Model/Message+CoreDataProperties.swift'
<unknown>:0: note: filenames are used to distinguish private declarations with the same name
<unknown>:0: error: filename "Model+CoreDataModel.swift" used twice: '/Users/josepmmirabent/houtel-ios-2016/Houtel2/DerivedData/Jumbotours/Build/Intermediates.noindex/Jumbotours.build/Debug-iphonesimulator/Jumbotours.build/DerivedSources/CoreDataGenerated/Model/Model+CoreDataModel.swift' and '/Users/josepmmirabent/houtel-ios-2016/Houtel2/DerivedData/Jumbotours/Build/Intermediates.noindex/Jumbotours.build/Debug-iphonesimulator/Jumbotours.build/DerivedSources/CoreDataGenerated/Model/Model+CoreDataModel.swift'
<unknown>:0: note: filenames are used to distinguish private declarations with the same name
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
Thanks!
Go into your project settings > select your main app target > Build phases > Compile Sources and remove the duplicate entries in that list referring to the files listed in your compile errors. It looks like some files are listed for compilation twice which would cause this issue.
This is usually an issue in the xcode project file, I have had this issue occur due to manually resolving git conflicts in the project file.
If that does not solve your issue make sure you do not have files with the same name in the project.
I have this code from a library I am using.
#ifdef __IPHONE_8_0
if (&SKStoreProductParameterAffiliateToken) {
if (self.affiliateToken) {
[appParameters setObject:self.affiliateToken forKey:SKStoreProductParameterAffiliateToken];
if (self.campaignToken) {
[appParameters setObject:self.campaignToken forKey:SKStoreProductParameterCampaignToken];
}
}
}
#endif
Xcode is saying that the first line will always evaluate to be true but what is this line doing exactly? I never saw a if with & and a constant in that way.
SKStoreProductParameterAffiliateToken is defined as
SK_EXTERN NSString * const SKStoreProductParameterAffiliateToken NS_AVAILABLE_IOS(8_0);
What is the developer trying to check, the address of a constant? Is he trying to check if the version of iOS has this constant defined and by doing that, he is trying to check the instruction inside the if should run? But he already has ifdef __IPHONE_8_0... (??!!)
I don't get it.
Anyway I am compiling for iOS 9.3, so I can delete the if and the ifdef, right?
It is a check to see if a weak-linked symbol is available. If the library/framework containing the symbol has been weakly linked and is not available its address will evaluate to NULL and the if condition will be false.
See Using Weakly Linked Methods, Functions, and Symbols in Apple's Using SDK-Based Development for full details.
#ifdef __IPHONE_8_0 checks if Xcode should compile code inside. Ohterwise older version of Xcode will show an error about unknown variable SKStoreProductParameterAffiliateToken.
But when using newer Xcode version (with iOS SDK 8+), we may still can set a lower minimum target for our project. In this case to avoid crash on devices with lower than iOS 8 version we should check first if variable, class, method or function exists.
In your case, we are checking if pointer to SKStoreProductParameterAffiliateToken is not NULL, which means app is currently running at least on iOS 8.
Under delphi tokyo, when I link a static libraries (*.a) inside an Ios project like this :
procedure StubProc1; cdecl; external 'FBSDKCoreKit.a' name 'OBJC_CLASS_$_FBSDKAccessToken';
I receive a lot of warnings like this one:
ld: warning: unknown dwarf DW_FORM_strp (offset=0xFFFF6E38) is too
big in
C:\Dev\lib\ios\facebook\FBSDKShareKit.framework\FBSDKShareKit.a(FBSDKAppInviteContent.o)
Any idea what goes wrong? What exactly does unknown dwarf DW_FORM_strp mean?
Reference code:
https://opensource.apple.com/source/cxxfilt/cxxfilt-9/cxxfilt/binutils/dwarf.c.auto.html
/* Process the contents of a .debug_info section. If do_loc is non-zero
then we are scanning for location lists and we do not want to display
anything to the user. */
static int
process_debug_info (struct dwarf_section *section, void *file,
int do_loc)
Then it calls read_and_display_attr -> read_and_display_attr_value -> fetch_indirect_string:
offset -= section->address;
if (offset > section->size)
{
warn (_("DW_FORM_strp offset too big: %lx\n"), offset);
return _("<offset is too big>");
}
So, it seems that this warning is only for debug purpose only.
Maybe your third party library lacks debug info, or something incompatible for debug (remember, even if you are building for release, there can still be some debug info in your app).
As it is for debug only, once you have successfully compiled your project, this warning shouldn't matter.
I was able to cross-compile llvm/clang for i386 and i'm trying to use it in my ios app.
Also i was able to add headers and static libs (both libLLVM*.a and libclang*.a) and compile/link the project with no errors.
But when trying to run simple app i'm getting error:
Detected an attempt to call a symbol in system libraries that is not
present on the iPhone: pthread_mutexattr_destroy$UNIX2003 called from
function _ZN4llvm3sys9MutexImplC2Eb in image LibClangUsageDemo3.
What can i do in order to fix it?
Is it llvm/clang issue or i'm doing smth wrong?
Update: i was able to find error line - Mutex.cpp:
// Destroy the attributes
errorcode = pthread_mutexattr_destroy(&attr);
assert(errorcode == 0);
I followed Claus's post to set up code coverage on Xcode 4.2 with LLVM 3.0. I'm able to see test coverage files, but they're only for my unit test classes, not my actual project classes. I've tried setting Generate Test Coverage Files and Instrument Program Flow to Yes on my main target, but that didn't help, as it failed with the following error:
fopen$UNIX2003 called from function llvm_gcda_start_file
To clarify, I don't think that's even the right approach - I just tried it to see if it would generate code coverage on my project classes.
At this point, I'd be happy to try anything that gets code coverage working on my app. Any suggestions?
You are expecting linker problem, profile_rt library uses fopen$UNIX2003 and fwrite$UNIX2003 functions instead of fopen and fwrite.
All you need is to add the following .c file to your project:
#include <stdio.h>
FILE *fopen$UNIX2003( const char *filename, const char *mode )
{
return fopen(filename, mode);
}
size_t fwrite$UNIX2003( const void *a, size_t b, size_t c, FILE *d )
{
return fwrite(a, b, c, d);
}
This code just remaps the missing functions to standard ones.
Note on $UNIX2003 suffix:
I've found an Apple document saying:
The UNIX™ conformance variants use the $UNIX2003 suffix.
Important: The work for UNIX™ conformance started in Mac OS 10.4, but was not completed until 10.5. Thus, in the 10.4 versions of libSystem.dylib, many of the conforming variant symbols (with the $UNIX2003 suffix) exist. The list is not complete, and the conforming behavior of the variant symbols may not be complete, so they should be avoided.
Because the 64-bit environment has no legacy to maintain, it was created to be UNIX™ conforming from the start, without the use of the $UNIX2003 suffix. So, for example, _fputs$UNIX2003 in 32-bit and _fputs in 64-bit will have the same conforming behavior.
So I expect libprofile_rt to be linked against 10.4 SDK.
I use CoverStory http://code.google.com/p/coverstory/ a GUI for .gcda and .gcno files.
The documentation explains the settings needed to generate these files http://code.google.com/p/coverstory/wiki/UsingCoverstory.