Passing Flags in XCODE - xcode

I have configure wxWidgets in my MAC OS. In terminal my program in working fine. Here is the following command which I use to run.
gcc -o main main.cpp -I/usr/lib/wx/include/mac-unicode-debug-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXDEBUG__ -D__WXMAC__ -framework IOKit -framework Carbon -framework Cocoa -framework System -framework QuickTime -framework OpenGL -framework AGL -lwx_macud-2.8
How can I configure xcode so that it pass the Header & libs to GCC.

In XCode, bring up the Inspector for the target, look at the "Build" tab, search for "header" and "library". You'll find the relevant configuration options.

Related

Running Ionic 3 app on iPhone throws error: 2 duplicate symbols for architecture arm64

I am opening .xcworkspace of my Ionic 3 project and trying to run it on my device but I suddenly get the following error in Xcode:
Ld /Users/manuel/Library/Developer/Xcode/DerivedData/MyApp-awaxbzztsgokklgptpuoufwcwmkt/Build/Products/Debug-iphoneos/MyApp.app/MyApp normal arm64
cd /Users/manuel/Documents/MyApp/dev/copernic4-ion2/galilei/platforms/ios
export IPHONEOS_DEPLOYMENT_TARGET=9.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.3.sdk -L/Users/manuel/Library/Developer/Xcode/DerivedData/MyApp-awaxbzztsgokklgptpuoufwcwmkt/Build/Products/Debug-iphoneos -L/Users/manuel/Documents/MyApp/dev/copernic4-ion2/galilei/platforms/ios/MyApp/Plugins/cordova-plugin-google-analytics -F/Users/manuel/Library/Developer/Xcode/DerivedData/MyApp-awaxbzztsgokklgptpuoufwcwmkt/Build/Products/Debug-iphoneos -F/Users/manuel/Documents/MyApp/dev/copernic4-ion2/galilei/platforms/ios/Pods/OneSignal/iOS_SDK/OneSignalSDK/Framework -FMyApp/Plugins/com.googlemaps.ios -filelist /Users/manuel/Library/Developer/Xcode/DerivedData/MyApp-awaxbzztsgokklgptpuoufwcwmkt/Build/Intermediates/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/arm64/MyApp.LinkFileList -Xlinker -rpath -Xlinker #executable_path/Frameworks -miphoneos-version-min=9.0 -dead_strip -Xlinker -object_path_lto -Xlinker /Users/manuel/Library/Developer/Xcode/DerivedData/MyApp-awaxbzztsgokklgptpuoufwcwmkt/Build/Intermediates/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/arm64/MyApp_lto.o -Xlinker -no_deduplicate -fobjc-arc -fobjc-link-runtime -ObjC -ObjC -framework OneSignal -framework SystemConfiguration -framework UIKit -framework UserNotifications /Users/manuel/Library/Developer/Xcode/DerivedData/MyApp-awaxbzztsgokklgptpuoufwcwmkt/Build/Products/Debug-iphoneos/libCordova.a -framework Accelerate -framework CoreData -framework CoreLocation -framework CoreText -framework GLKit -framework ImageIO -lc++ -lz -framework OpenGLES -framework QuartzCore -framework SystemConfiguration -framework UIKit -framework GoogleMapsBase -framework GoogleMaps -framework GoogleMapsCore -framework EventKit -framework EventKitUI -framework AVFoundation -lGoogleAnalyticsServices -lAdIdAccess -framework AdSupport -lsqlite3 -weak_framework WebKit -lz -Xlinker -dependency_info -Xlinker /Users/manuel/Library/Developer/Xcode/DerivedData/MyApp-awaxbzztsgokklgptpuoufwcwmkt/Build/Intermediates/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/arm64/MyApp_dependency_info.dat -o /Users/manuel/Library/Developer/Xcode/DerivedData/MyApp-awaxbzztsgokklgptpuoufwcwmkt/Build/Products/Debug-iphoneos/MyApp.app/MyApp
duplicate symbol _OBJC_CLASS_$_CDVLogger in:
/Users/manuel/Library/Developer/Xcode/DerivedData/MyApp-awaxbzztsgokklgptpuoufwcwmkt/Build/Intermediates/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/arm64/CDVLogger.o
/Users/manuel/Library/Developer/Xcode/DerivedData/MyApp-awaxbzztsgokklgptpuoufwcwmkt/Build/Products/Debug-iphoneos/libCordova.a(CDVLogger.o)
duplicate symbol _OBJC_METACLASS_$_CDVLogger in:
/Users/manuel/Library/Developer/Xcode/DerivedData/MyApp-awaxbzztsgokklgptpuoufwcwmkt/Build/Intermediates/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/arm64/CDVLogger.o
/Users/manuel/Library/Developer/Xcode/DerivedData/MyApp-awaxbzztsgokklgptpuoufwcwmkt/Build/Products/Debug-iphoneos/libCordova.a(CDVLogger.o)
ld: 2 duplicate symbols for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I don't understand what is duplicated... any help would be really appreciated.
To solve the problem please have a look over this blog post from Cordova iOS 4.5.
http://cordova.apache.org/announcements/2017/09/08/ios-release.html
You need to remove plugin "cordova-plugin-console" that is installed by default when generating a new Ionic project. Now this is in core part of cordova for iOS.
Since duplicate symbols are there, just removed "-ObjC" from both Targets and Project:
Build Settings -> Linking -> Other linker flags.
also try to remove any unwanted libraries from
Targets -> Build Phases -> Link Binary with Libraries
The problem here is cordova-ios#latest.
And we could fixed this issues with:
Uninstall cordova-ios first, with npm uninstall cordova-ios
Install cordova-ios with npm install cordova-ios#4.4.0
After that we should add platform with ionic cordova platform add ios#4.4.0
The last one, run ionic cordova build ios, that open with xcode and build with your settings.
Since cordova IOS 4.5 they are including cordova-plugin-console, which results in the plugin being duplicated.
To fix just run:
cordova plugin rm cordova-plugin-console
The solution #arunraj414 worked for me, from xcode you can solve it this way:
Delete either one

Apple Mach-O Linker (Id) Error for OpenFrameworks

I am using XCode 7.1 on Mac OS X 10.11.1.
I am using an addon called ofXopenNI with openFrameworks, which is basically an OpenNI interface for openFrameworks. It has some requirements which I installed and linked to my XCode project. Still, there's one linking error that I am unable to fix. Here it is (I pasted an image so that I don't miss out on anything):
The problem is that libXnFormats is already included in my project, and yet this issue comes up. This is how I think it's included in the project:
(The second one)
I know there are a lot of Mach-O linking error questions on SO, but this seemed specific. Anyone knows a fix to this?
Here's the error message in text format (since it was asked for):
Ld bin/huReconDebug.app/Contents/MacOS/huReconDebug normal x86_64
cd /Users/ranveer/BTP/openFrameworks/apps/myApps/mac-huRecon
export MACOSX_DEPLOYMENT_TARGET=10.11
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -L/Users/ranveer/BTP/openFrameworks/apps/myApps/mac-huRecon/bin -F/Users/ranveer/BTP/openFrameworks/apps/myApps/mac-huRecon/bin -F/Users/ranveer/BTP/openFrameworks/apps/myApps/mac-huRecon/../../../libs/glut/lib/osx -filelist /Users/ranveer/Library/Developer/Xcode/DerivedData/huRecon-eiqxyontximqaegxzkvzzaxrfiqs/Build/Intermediates/huRecon.build/Debug/huRecon.build/Objects-normal/x86_64/huReconDebug.LinkFileList -mmacosx-version-min=10.11 -dead_strip ../../../libs/poco/lib/osx/PocoCrypto.a ../../../libs/poco/lib/osx/PocoData.a ../../../libs/poco/lib/osx/PocoDataODBC.a ../../../libs/poco/lib/osx/PocoDataSQLite.a ../../../libs/poco/lib/osx/PocoFoundation.a ../../../libs/poco/lib/osx/PocoNet.a ../../../libs/poco/lib/osx/PocoNetSSL.a ../../../libs/poco/lib/osx/PocoUtil.a ../../../libs/poco/lib/osx/PocoXML.a ../../../libs/poco/lib/osx/PocoZip.a ../../../libs/tess2/lib/osx/tess2.a ../../../libs/glew/lib/osx/glew.a ../../../libs/cairo/lib/osx/cairo-script-interpreter.a ../../../libs/cairo/lib/osx/cairo.a ../../../libs/cairo/lib/osx/pixman-1.a ../../../libs/fmodex/lib/osx/libfmodex.dylib ../../../libs/rtAudio/lib/osx/rtAudio.a ../../../libs/openssl/lib/osx/crypto.a ../../../libs/openssl/lib/osx/ssl.a ../../../libs/glfw/lib/osx/libglfw3.a ../../../libs/FreeImage/lib/osx/freeimage.a ../../../libs/freetype/lib/osx/freetype.a ../../../addons/ofxAssimpModelLoader/libs/assimp/lib/osx/assimp.a ../../../addons/ofxKinect/libs/libusb-1.0/lib/osx/usb-1.0.a ../../../addons/ofxOpenCv/libs/opencv/lib/osx/opencv.a -stdlib=libstdc++ -framework Accelerate /Users/ranveer/BTP/openFrameworks/apps/myApps/mac-huRecon/bin/data/lXnFormats.dylib -lXnFormats -framework QTKit -lXnDDK -framework GLUT -lusb-1.0.0 /Users/ranveer/BTP/openFrameworks/apps/myApps/mac-huRecon/bin/data/XnFormats.dylib /Users/ranveer/BTP/openFrameworks/libs/openFrameworksCompiled/lib/osx/openFrameworksDebug.a -framework AGL -lXnVNite_1_5_2 -lnimRecorder -framework ApplicationServices -lXnVCNITE_1_5_2 -framework AudioToolbox -framework CoreAudio -framework CoreFoundation -lnimCodecs -lXnVFeatures_1_5_2 -framework CoreServices -lXnCore -framework OpenGL -lOpenNI -framework QuickTime -lnimMockNodes -lXnDeviceSensorV2KM -framework AppKit -lXnDeviceFile -framework Cocoa -lXnVHandGenerator_1_5_2 -framework IOKit -framework CoreVideo -Xlinker -dependency_info -Xlinker /Users/ranveer/Library/Developer/Xcode/DerivedData/huRecon-eiqxyontximqaegxzkvzzaxrfiqs/Build/Intermediates/huRecon.build/Debug/huRecon.build/Objects-normal/x86_64/huReconDebug_dependency_info.dat -o /Users/ranveer/BTP/openFrameworks/apps/myApps/mac-huRecon/bin/huReconDebug.app/Contents/MacOS/huReconDebug
And then,
ld: library not found for -lXnFormats
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I had a similar issue that I got -lXnDDK linker error instead of -lXnFormats. I assume you created new groups by including include and lib folders under ofxOpenNI addon directory. Also, copied the lib folder into bin/data/openni.
I just add bin/data/openni/lib to the Library Search Paths in Build Settings.
I am using Xcode 7.0.1 on MAC OS X 10.10.5.
Rename the library to XnFormats rather than libXnFormats.
I had a strange issue on Xcode recently, when even when using the -l command (which should prefix lib) did want to work for a custom library.
This might be an Xcode bug. However this should get it working for you now.

How can I compile sfml project via command line on mac?

I am trying to compile a sfml project via command line under mac osx. Currently, I'm not able to get it to compile. Any help guys?
For the simple window application they include as part of the templates. I was able to compile it with the following command.
g++ -framework OpenGL -framework SFML -framework SFML-window main.cpp
I hope that helps
You can compile with only one instruction:
g++ -framework sfml-window -framework sfml-graphics -framework sfml-system main.cpp -o main

Apple Mach-O Librarian (libtool) error with no specific error

I've had to deal with plenty of libtool errors previously, but I really don't know what to do with one that doesn't give me a hint.
Here is the full error:
Libtool /Users/programmingstation7/Library/Developer/Xcode/DerivedData/RZFramework-fglhxeoyynfgoxgrgpqwrywuaexk/Build/Products/Debug-iphoneos/libRZFramework.a normal armv7
cd /Users/programmingstation7/Documents/CleanedFramework
setenv IPHONEOS_DEPLOYMENT_TARGET 5.0
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool -static -arch_only armv7 -syslibroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -L/Users/programmingstation7/Library/Developer/Xcode/DerivedData/RZFramework-fglhxeoyynfgoxgrgpqwrywuaexk/Build/Products/Debug-iphoneos -L/Users/programmingstation7/Documents/CleanedFramework/.. -filelist /Users/programmingstation7/Library/Developer/Xcode/DerivedData/RZFramework-fglhxeoyynfgoxgrgpqwrywuaexk/Build/Intermediates/RZFramework.build/Debug-iphoneos/RZFramework.build/Objects-normal/armv7/RZFramework.LinkFileList -lxml2 -ObjC -all_load -framework CoreData /Users/programmingstation7/Library/Developer/Xcode/DerivedData/RZFramework-fglhxeoyynfgoxgrgpqwrywuaexk/Build/Products/Debug-iphoneos/libarc.a /Users/programmingstation7/Library/Developer/Xcode/DerivedData/RZFramework-fglhxeoyynfgoxgrgpqwrywuaexk/Build/Products/Debug-iphoneos/libEISRenderHelpful.a -framework CFNetwork -framework MobileCoreServices -framework Security /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/libxml2.dylib /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib/libz.dylib -framework CoreLocation -framework CoreText -framework UIKit -framework Foundation -framework CoreGraphics -framework MediaPlayer -framework QuartzCore -framework AVFoundation -framework OpenGLES -framework MapKit -framework MessageUI -framework SystemConfiguration -framework EventKit -framework EventKitUI -o /Users/programmingstation7/Library/Developer/Xcode/DerivedData/RZFramework-fglhxeoyynfgoxgrgpqwrywuaexk/Build/Products/Debug-iphoneos/libRZFramework.a
Command /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/libtool failed with exit code 1
I'm using the linker flags -lxml2 -ObjC -all_load
Any ideas as to what causes a exception-less libtool failure?
Oh, and I'm building a static library target. Previously, this was an app and I tore out all the unreusable stuff for the beginning of an app framework I'll be able to use.
I've had exactly the same problem yesterday and I found the solution.
remove the -lxml2 from your other linker flags.
It makes libtool link the library statically which causes problems.

Xcode ignoring Other Linker Flags

In my current project I am unable to set the "Other Linker Flags" as I have in others projects. No matter what I put in the "Other Link Flags" section of my xcode project settings it does not show up in the detailed build log, and the desired linking does not happen:
Ld build/Debug-iphonesimulator/MyProject.app/MyProject normal i386
cd /Users/theUser/Development/xm8vc/MyProject/trunk
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.2.sdk -L/Users/theUser/Development/xm8vc/MyProject/trunk/build/Debug-iphonesimulator -L/Users/theUser/Development/xm8vc/MyProject/trunk -F/Users/theUser/Development/xm8vc/MyProject/trunk/build/Debug-iphonesimulator -F/Users/theUser/Development/xm8vc/MyProject/trunk -filelist /Users/theUser/Development/xm8vc/MyProject/trunk/build/MyProject.build/Debug-iphonesimulator/MyProject.build/Objects-normal/i386/MyProject.LinkFileList -mmacosx-version-min=10.6 -lxml2 -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework CoreGraphics -framework CoreData -framework QuartzCore -framework AVFoundation -framework AddressBook -framework AddressBookUI -framework AudioToolbox -framework OpenGLES -framework CFNetwork -framework SystemConfiguration -framework MediaPlayer -lxml2 -lz -framework SpeechKit -o /Users/theUser/Development/xm8vc/MyProject/trunk/build/Debug-iphonesimulator/MyProject.app/MyProject
Is there something that would cause xcode to ignore the "Other Linker Flags?"
Where are you setting these flags? You can set flags like this at various levels in your project - project settings, target settings, etc. There's a full description in Working with Xcode Build Settings. It's possible that, for example, you are setting it in your project settings, and then it is being overridden by your target settings.

Resources