Is it possible to create a .dylib file from a Objective-C or Swift coded-project, or must the code be written in C++?
I've seen several sources, but they're all written in C++.
see - Creating and Using a Simple .dylib
and
How do I create a dynamic library (dylib) with Xcode?
Is it even possible to create a .dylib file using any other language than c++?
As we discussed I have created an sample app for OS X. It uses dylib with single Foo Swift class. Foo has doSomething method, which logs kind of "hello world" message into the console.
Once you are built the project, you can find the dynamic library inside the application bundle in the Frameworks folder. It named libFoo.dylib.
Source code:
https://github.com/melifaro-/OSXDylibSample
Hope it helps.
Related
I've been running into this strange problem lately where in my Cocoa app project in Xcode I get the error that the file was not found when using "fopen" (errno 2), called from a C++ file. I made sure to copy these files into the project's directory, then I dragged them from the Finder directory into the Xcode project tree. And finally, in the scheme's options I checked "use custom directory" and entered the directory where I have the project and all the files. The programme builds fine, but during runtime I get a BAD ACCESS error and I can see that my FILE* variable is still NULL. The command that throws the exception is actually "fread" two lines later, but it's only because "fopen" didn't do its job.
This whole setup has worked fine before in pure C++ projects. But this is different because it started as a Cocoa app in Objective-C (because I intended to use C++ for the programme's main logic). At some point I also had to change the extensions of all the ".m" files to ".mm" or the compiler wouldn't even find the C++ standard library! (but this is probably beside the point)
So the question is.. what else do I need to check in order to have the programme find the files I'm trying to open?
NOTE: the backbone of the project is written in C++, and I'm only using Cocoa in order to be able to dram images on the screen, so if anyone has a better approach to including graphics in a C++ project I'm all ears.
Thanks for reading
EDIT: I'm using Xcode 12.4 and Catalina 10.15.7
Cocoa apps do not work with files the same way as command-line C++ apps. Cocoa apps create an app bundle, which is where the files you want to read should be. If you have files you want to read in a Cocoa app, add them to the project. When you add the files to the project, they will get copied to the app bundle. Make sure they are in the app target's Copy Bundle Resources build phase.
Use the methods in the Bundle class to locate the files instead of fopen. The following Swift code locates a file named "MyFile.txt" in the main app bundle:
let mainBundle = Bundle.main
let fileURL = mainBundle.url(forResource: "MyFile", withExtension: "txt")
I am looking for a way to include Webrtc in my iOS project. My project consists some C code which I am looking for a way to call the Webrtc apis from. I am able to do this in Android using a Makefile and linking the webrtc library. However, I haven't been able to do it on iOS. I tried to build a webrtc.framework but I am not sure how to link it to my C code. Any idea?
The WebRTC.framework that gets created by the build script has Objective-C header files. You cannot call Objective-C methods in a C source code (.c) file. You'll need to consume it in an Objective-C (.m) file or Objective C++ (.mm) file.
Google introduced and then quickly decided to drop static library target somewhere in Sep 2018. We usually build static library once a month for ios. I can share libs on github if you like.
I downloaded the library files (.dll) to make PocketSphinx work for Windows desktop. From the command prompt it is working. I want to use these dlls in a Java application so that I can create a .jar and use it as a whole.
You can not use pocketsphinx.dll in java. You have to compile JNI extension in a special way as explained in:
Getting Started with JNI and C under Windows
pocketsphinx already supports SWIG, so you can create the wrapper automatically from pocketsphinx.i interface description. However, you need to compile everything into dll file after that yourself. You can collect sources and just write another makefile.
I have created a project using QtApplication in netbeans and I need to call a function in that project from a different project which is a normal C/C++ project.Can any body tell me how to do???thanks
Have you tried QProcess? It's used to start external programs and communicate with t
Last few days I was trying to integrate ns3 with Qt but now I have successfully integrated them.I am providing the solution so that it can be helpful to save time:
In order to integrate ns3 and Qt, I;
1)-created the dynamic library of the code written in Qt using IDE netbeans.
2)-In order to link and use that library I place the header file in the build/project folder so that I can use it easily.After that to link the dynamic library in ns3, I added following lines in the script file:
module.ccflags=['-wall','-O3']
module.lib=['QDynLib']
module.libpath=['/home/a/Documents/ns-allinone-3.16/ns-3.16/src/propagation/QDynLib/dist/Debug/GNU-Linux-x86']
module.linkflag=['-g']
module.rpath=['/home/a/Documents/ns-allinone-3.16/ns-3.16/src/propagation/QDynLib/dist/Debug/GNU-Linux-x86']
Here,I used the absolute path to locate the dynamic library.
Location of the Dynamic library;
/home/a/Documents/ns-allinone-3.16/ns-3.16/src/propagation/QDynLib/dist/Debug/GNU-Linux-x86/
Name of the library File:
libQDynLib.so
to find the explanation and detail of these python commands please refer to the link:
http://docs.waf.googlecode.com/git/book_15/single.html#_c_and_c_projects
So basically, I am attempting to write my own GUI wrapper in Python (Using GTK+, but I don't think that's relevant) for an API that is written in C++ and compiled by the user into a shared object file (in linux [*nix? I'm not quite sure how it works on macs]) or a dll (in windows) that you should be able to reference to use the API yourself. After quite a while of trying with Cython, I am able to write my own extensions, as long as it is only a single file, but I can't find anything online about using multiple files (as this obviously is, since any real project would be) to compile into a single .so that can be imported into a Python project. Would I need to manually go through and use Cython and create .pyx files for each .cpp file (there are a lot of them), compile those into cpp files and then edit then use the make file to compile those into the .so file, or is there a more automated way? (p.s. I tried compiling each one separately with Cython, but it didn't seem to like the "#include < path/file >" notation and so couldn't compile most of the files)
Other info: I have been able to interface with the library using ctypes, but that felt extremely hackish and un-pythonic, and I want to get some more experience with Cython anyways, since it seems like it could be an extremely useful asset to have.
You could do a file named "yourmodule.pyx", rename all the others files to pxi, and do:
include "other1.pxi"
include "other2.pxi"
Then you'll have only one file to cythonize and compile: yourmodule.pyx.