Names for DLLImport when moving C# from Unity script to Mono DLL - mono

I have a working Unity C# script which calls into a native iOS static library. I would like to move the C# code from the Unity script attached to a scene object and into a new Mono DLL. I'll then rewrite the Unity C# script to call the Mono DLL. I'm unsure how to name the DLL representing the imported native iOS static library (the .a file)
In the C# script I have this external declaration:
[DllImport("__Internal")]
private static extern int square(int x);
What should the DLL name be when I copy those lines over to the Mono DLL?

Just to turn #Droppy's comments into an answer, the C# I have in the Unity script:
[DllImport("__Internal")]
private static extern int square(int x);
works without change as part of a Mono DLL imported as an asset into a Unity project. I did not need to search for a more specific name than the Unity magic "__Internal".
(N.B. Example code is available here.)

Related

QMake build static library using dlls

I have a Qt project which is a library.
Currently it works great but it is a dll and I want it to be a static library.
To do so I added "CONFIG += static" in my .pro file (I also tried "CONFIG += staticlib"). After doing so my library compiles well but it needs to be statically linked to libraries which were DLLs before.
Is there a way to compile a static library using dlls with QMake ? ?

How to resolve unresolved external symbol when linking against dll with static constructors?

I'm building a dll in D with some utils, tools, ect. I can successfully compile a basic dll and test program to use it in visual D without any issues. I am familiar with the process of creating and using dll's. Especially statically linking against them. But if a module in the dll has a static this(), or imports a module with a static this(), the dll will compile, but any program you build that uses it will fail with a foo.bar.__ModuleInfo being unresolved.
error LNK2001: unresolved external symbol "dtoolbox.dtoolboxdllmain.__ModuleInfo" (__D8dtoolbox15dtoolboxdllmain12__ModuleInfoZ)
In this case my dllmain module dtoolbox.dtoolboxdllmain imports core.runtime which has a static this() so i get this error. How do i resolve this? What are static module constructors doing to cause this? As long as there are no static constructors everything works fine.
[edit] Importing core.runtime wasn't the problem, it was the modules own static this(), not core.runtime's static this().
The solution is to refrain from importing a module with the dll's static this() && static ~this() into a module of a program which uses the dll. (In this case the dllmain module was being imported, for no reason at all, my mistake) Not to say that the dll can not have them though, they just need to be there in some file when compiling the dll. I found it convenient to write them in the same module as your dllmain as this file will never really need to be referenced/imported by a program using the dll.

Unable to access swift file from static library to application target

I have workspace contains subprojects and one of the subprojects generates static lib which contains both ObjC and swift which is linked to main application project. I am unable to access a swift class from a static library in ObjC file in application target.
How can I access a swift class from the static library in ObjC file in application target?
I figure it out.
The issue was module-swift.h of subproject static library is generated in derivedData intermediate DerviedSource folder which is not known to main application target.
The issue resolved :)
I think, it is not possible. Xcode doesn't support Swift static libraries. You can read about it here: https://forums.developer.apple.com/thread/73900

c++ static library import to XCode Cocoa project

I'm very new at Objective-C programming, I have a MacOSX project, with a simple UI code. It has a login function.
I have a .a extension c++11 static library, with two public headers. One includes . I d like to import the library with the headers to my project. It makes the login to my server.
I made a c++ static library target to the code, and imported the needed files, set the c++ flags (stdlib=libstdc++ and -std=c++11) and added gcc49 to search paths. But I get file not found exception to #include in my c++ header.
Have somebody a good tutorial how to solve my problem?

Xcode: automatic link static library dependency to Project

I've workspace with two project: static lib and cocoa application. Static library link some system frameworks(libcrypto.dylib) and include dynamic lib's .h files(openssl/bn.h openssl/rsa.h). My static library compiles successfully.
Cocoa application uses this static library and at compile time gives an error: "undefined symbols, symbols not found" (bn, new rsa etc).
But when I include libcrypto.dylib also into cocoa application project then there is no error.
Question: Xcode can do this automatically, by taking dependency from the static link library?
Thanks.
The answer is unfortunately no. It is common practice to include each single static library in the project that requires the code. That is just the way it is done.
There is an interesting article on how to handle multiple static libraries in an XCode project.