My project (Objective C, macOS, Xcode 11) does not use CocoaPods and I'd like to keep it that way.
I want to use libxlsxwriter to export data in Excel format. I cloned libxlsxwriter from GitHub and built it. Now I have libxlsxwriter.a and lbixlsxwriter.dylib.
What I tried so far: I followed the instructions on this site (thanks for the link) to include the dylib. In the "General" settings lbixlsxwriter.dylib is shown as "Embed & Sign", in "Build Phases" it is listed under "Link Binary With Libraries" and it has its own "Copy Files" section. Running from Xcode gives me
dyld: Library not loaded: /usr/lib/libxlsxwriter.dylib
Referenced from: /Users/XXX/Library/Developer/Xcode/DerivedData/XXXefxsacdsioejobcumpvsbklqguri/Build/Products/Debug/XXX.app/Contents/MacOS/XXX
Reason: image not found
What do I have to add to my project: The include folder with all the header files and both of these libs? How do I have to adjust the General settings and Build Phases?
If you have static library and only one loader, eg. main executable, (so you don't need to share it between your components), then you don't need dynamic library at all.
Just add your libxlsxwriter.a into Target > General > Frameworks and Libraries section, and it will be linked in into your executable and just work.
If you really need shared dynamic library then you need to use rpath + LD_RUNPATH_SEARCH_PATHS combination. (Let me know if you need more details on this).
Related
I'm trying to add libraries to "External Libraries". I've added them in Setting -> Javascript -> Libraries and they are highlighted now as "(library home)", but they are not added to external libraries which allows code inspection and TODO's to work for them.
What is the difference between "library home" and "External Libraries" and how do I make a library external?
In PhpStorm the stuff listed under External Libraries branch will include:
PHAR files
folders from Settings | PHP | Include paths (folders that are not part of the actual project but still referenced for code completion: e.g. libraries installed globally).
Quite likely it's the same here in WebStorm for JavaScript libraries: global npm modules or whatever. So I guess when you reference a library that is physically located outside of the project, it should be listed there.
I'm learning to build a llvm project, this is the reference: http://llvm.org/docs/Projects.html. I use the "llvm/projects/sample" directory as the primary project skeleton, and it works. Then I want to build tools from "llvm/examples" to my project, such as Fibonacci, it can't work. I do it this way: first copy the "llvm/examples/Fabonacci" directory to "MyProj/tools" ("MyProj" is top level of my project) and change Makefile to contain Fabonacci target, then configure & make. but the Fabonacci tool seems can't be built. It depends on some libs when linking. So what can I do if I want to build the source code from "llvm/projects/example" in my project?
You need to provide LLVM libraries to linker when building your own project. This means adding some flags, library directories and libraries themselves to link command. Build script probably needs some editing.
llvm-config tool can be used for providing necessary options to compiler/linker. Check documentation and examples.
I'm trying to use libmediainfo in an Xcode project but I'm unable to get it to work properly.
I've added the dylib to the Frameworks folder of my project and made sure it is added to the "Link Binary with Libraries" section in the build settings of the target.
Every time I try to build the app it says:
dyld: Library not loaded: /usr/lib/libmediainfo.0.dylib
Referenced from: ......
Checkout loader path: otool -L libmediainfo.dylib
If it has #loader_path, change it to #rpath with install_name_tool
install_name_tool -id #rpath/libmediainfo.dylib libmediainfo.dylib
Or, you can place the dylib in the MacOS folder and use #executable_path instead of #rpath.
I need to weak link some framework with my target.
But I can't find how to do it...
If I try to run my project on 3.2 iPad simulator i get the following error:
dyld: Library not loaded: /System/Library/Frameworks/iAd.framework/iAd
Reason : Image not found
Thanks !
Go to your project -> Targets -> Build Phases -> Link Binary with Libraries.
Then change the library you want to weak-link from "Required" to "Optional".
This doesn't work now. Please follow the link below:
https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html
Select the target you want to modify and reveal its build phases.
Expand the Link Binary With Libraries build phase to view the frameworks currently linked by the target.
If the framework you want to weakly link to is listed in the Link Binary With Libraries build phase, select it, and choose Edit > Delete to remove it.
Now you can tell the linker to use weak linking for that framework.
Select the target, open its Info window, and click Build.
To the Other Linker Flags build setting, add the following command-line option specification, where FRAMEWORK_NAME is the name of the framework you want to weakly link to:
-weak_framework FRAMEWORK_NAME
Build your product.
I'm currently busy on a project where I need to use an external accessory to read Mifare 1k tags.
The accessory was provided with an SDK, written in (Objective ?)C++ and I followed the instructions provided to set XCode to "Compile sources as: Objective-C++" and added "-Obj-C++" in "Other linkers flags.
The SDK compiles fine then, but trouble is I am already using several libraries in the project (such as ASIHTTPRequest, JSONKit, ...) and I get compilation problems because of those new settings in those libraries. If I switch back to the previous settings, I get compilation problems in the reader's SDK
The question is: is there a way to compile only the class from the SDK as C++ and the rest of the project as objective-c ?
Edit: the SDK files consists only of .h (and a linked library)
thanks for your help,
Mike
Select the file you want to compile as Objective C++ from the file navigator, and then select the File Type in the file inspector view. This is in Xcode 4, but there is a similar mechanism in Xcode 3.
Try renaming the files where you are including the library headers to myClass.h for interface and myClass.mm for implementation files. This forces the files to be compiled as objective-c++.
I have resolved this problem:
You should set "According to file type" to "Complile Sources As",
Set "-ObjC++" to the "Other Linker Flags"
The last,you should modify the files's suffix to .mm that reference
the library method
well, in Build phases tab, there is a section Compile sources. For file you want to use Objective-C++ compiler add flag: -xobjective-c++
tested in Xcode 12.5