I have a C library which I need to use in my ongoing Xcode project. I used Cmake to build and install that Library. I gave the paths to Headers files and I can include the files into my Xcode project. However, when I run the project it says:
linker command failed with exit code 1 (use -v to see invocation)
I suspect that problem is with Linker Flags. I haven't included any Linker Flags and I don't know which flags do I need to add. Please tell me where in the library would I get all the required Linker Flags.
git hub link of the library which I want to add:
https://github.com/cbalint13/pba
From xcode left side window.
Under Project Navigator, click on your project, click on build settings.
Select "All" and "Combined" sections, then search for "Linker Flag"
Don't forget to switch to your target's build settings as well. As you might change just the "Project", not the "Target".
Related
I am trying to build an interface with glade using C language and Xcode. I installed the library add added it to "other linker flags" in Xcode. I guess I am not linking it properly in the IDE. I get the following error:
"ld: library not found for -lgobject-introspection
clang: error: linker command failed with exit code 1 (use -v to see invocation)"
How to properly link libraries in Xcode?
The answer is available in another post Linking Libraries in Xcode
The idea is to properly link the library in the linker flags like this:
-lgobject-introspection
then to add the path of the library in the Search header paths in Xcode.
This way, you tell Xcode to search the specified library in the added path.
I am attempting to add an ObjC++ file to a large Xcode 5 C++ project.
For legacy reasons, the "Compile Sources As" setting must remain "C++". If I could change this setting to "According to File Type" the ObjC++ file would build properly, but it won't compile if Xcode thinks its a C++ file.
I have tried explicitly setting the Type of the .mm file under Identity and Type to "Objective-C++ Source" and the compiler still attempts to build it as a C++ file. I have tried adding the "-ObjC" and "-ObjC++" compiler flags to to the individual file under Build Phases > Compile Sources, and I get a warning that the argument is unused during compilation.
I have tried this process in reverse, adding an ObjC++ file to a different project that is compiling sources as "According to File Type," and setting the Type to C++. As expected, the file fails to build. This shows that specifying the type of an individual file takes precedence over the project setting.
Is there no way to force Xcode5.1.1/llvm5.1 to build a single ObjC++ or ObjC file as the correct type? The project setting is overridden by the individual file setting in every case I've tested, except trying to build an ObjC++ file. Is this a bug or missing feature?
You were close with the ObjC++ flag.
Set the file's Compiler Flags in the Compile Sources Build Phase to -x objective-c++ $(inherited).
Is there a way to specify in Xcode which binaries to use for compilation? I have recently cross-compiled clang, ld, libtool, etc, and I want to test them.
I am fully aware that I could just do something like:
/Path/To/My/Tools/clang -c file.c
/Path/To/My/Tools/ld file.o -o executable
# or
/Path/To/My/Tools/libtool -static -arch_only x86_64 -o myLib.a *.o
# and so on...
However I am looking for a way to integrate this nicely into Xcode. As my tools should (technically - this is what I want to test) be equivalent to the built-in tools, I don't need to change any of Xcode's default compilation args, etc. I just need to tell it to find the binaries some place other than /usr/bin or somewhere in the ${SDKROOT} or *.xctoochain directories. Is this possible?
There is a project setting for this. In your Xcode project, open the "Project Navigator" and click on the icon for your project. It should show the project settings. In the "Project" section of the project settings, click on the "Build Settings" tab. Type "compiler" into the search field, and it should show you the "Build Options" setting for "Compiler for C/C++/Objective-C". It defaults to Apple LLVM 5.0, but you can change it. Click on "Default (Apple LLVM 5.0)" and select "Other…" It will pop up a text field where you can enter the path to your own tools. It should look like this:
I am a noob and am having an issue with linker flags.
I tried building my own ssh2 libraries, and then afterwards I cloned a git repository with a project in the libraries already built.
Before I downloaded the compiled binaries, I was building with gcrypt and added the -lgrcrypt library to the other linker flags.
With this new library set that I am using, I no longer require gycrpt and so I removed the linker flags. However that did not clear the linker options. I am still getting all of the old linker flags in spite of clearing them in the project properties.
The error shows that the -lgrypt is still being processed as a linker flag:
-no_implicit_dylibs -mios-simulator-version-min=6.0 -lgcrypt
How can I reset the linker flags to what they were?
Thanks in advance
well i presume you have checked the flags and removed the path for that lib in your target level of the project, and also have clean the build and removed the previouse builds from organizer and inside xcode, and also have reset your simulator, and also have checked the project folder on your computer and removed that lib from the library folder of the project. these are the necessary steps and if you have done all of these then i cant think of anything else other than port your code to a new project and try to compile again. good luck my friend.
I'm putting all my third party code in a /Vendor directory in my Xcode project. How can I suppress all compiler warnings in that directory?
I'm using Xcode 4 and LLVM 2.1.
You cannot set warning flags in Xcode by directory; directories have no meaning to Xcode, they don't form any form of "compile entity". You can set warning flags per Target, per Build Configuration, or on single files. This leaves you with two options:
Build all 3rd party code as an own target, e.g. make it a static library target, then build your code in another target and make it link against the static library of the first target. Each target can then have different warning flags.
Select all the 3rd party files in the list of files to build and override some of the warning flags (if a warning is turned on with -Wfoobar, then you can disable it with -Wno-foobar). Setting compile flags on single files is shown in the screenshot below; this can be done with multiple files at once.