Why can't I call this C function from my Swift code? - c

I am trying to call this C library from my Swift code. I dragged the source files into my project and created a module.map file and added the directory containing the module map to Build Settings->Search Paths->Import Paths.
It seems to work. I can import the library and the name even shows up in autocomplete:
And I can access functions from the library and again autocomplete knows they are there:
But when I build, I get this error:
This name, "_mtex2MML_parse", is the same as the name of C function I'm trying to call except prefixed with an underscore.
I've gotten this same error before in similar circumstances trying to get cmark to work, but fixed it there by making sure that the .c file was included in the Target Membership, and then everything was fine. When I fiddled with doing that in this project, I've not had any luck. And in that case, autocomplete didn't even know about the function.
I've tried cleaning, deleting derived data, quitting Xcode, restarting computer, etc. I've tried on Xcode 8.3.3 Swift 3.1 and on Xcode 9b4, Swift 4.0. I'm on macOS 10.12.6. There is no other thing in the project besides this.
Can anyone offer any advice on how to proceed? Thanks.

Related

Ufft example compilation

I want to run the example project which is available for free from this link. It is a simple FFT library and needs no compiler. In it, there is an example c file with its required header files and .c files.
When I try to run it in Vivado SDK I get errors of multiple definitions of fft and ifft. How can I run this example inside SDK?
What I had done is created an empty application project and then imported all these files inside src folder and then selected build the project option but didn't succeed in building and running the project.
I guess, looking at the ufft.zip archive, that you've tried to link files issued form the compilation of fft-dit.c and fft-dif.c.
Both files define ftt functions using differents method (see README).
You have to choose betwen using ftt-dif.c or ftt-dit.c, not both.
This is the same for itt-dif.c and itt-dit.c, choose one, not both.

Wrong WebStorm TypeScript Warning "unresolved variable or type angular"? [duplicate]

I started using Typescript with Webstorm today and I am getting real crazy understanding what's going on. Imagine a project using tsd loading definition types on typings/. For background, angular defines an angular module aliased to ng and then there is other d.ts files appending more modules into angular (and technically ng).
When I require for example the router I get:
In fact, if you go to angular-route.d.ts (from DefinitelyTyped) you can see the same:
The d.ts files are technically correct because tsc compiles them giving it those definition files.
On the other hand, Webstorm allows you to load libraries (typescript stubs from DefinitelyTyped). If I go there and I download the angular ones (which are 100% the same as the one I have on typings/) I get:
Same error but at least I don't get the red wiggle in the solution explorer. Still, it doesn't give me any intellisense when writing ng.route.<ctrl+space>, it just turn blue when I finish writing it (in fact, I can cmd+click and go to the definition).
Who's failing here? The typescript plugin? It is weird that it fails using typings/ and somehow work with Webstorm's libraries menu (using the same file).
Who's failing here? The typescript plugin?
Yes. You need to use the Webstorm beta channel to get support for TypeScript 1.4 union Types at the moment.

How to make eclipse work with C(not c++) code in android NDK?

I have very big issues with eclipse and NDK.
It completely do not recognize C code.
(*java_vm)->DetachCurrentThread (java_vm);
Throws semantic error by CDT, while it sees
java_vm->DetachCurrentThread ();
as a valid one (while it isn't for C).
File has a .c extension compiles well, despite that CDT just doesn't work on it. To add insult to injury it properly founds the method by ctrl+clicking on function.
Also I do not know if it is related, but it just not recognize anything from GLIB.
It includes #include <glib/glib.h> but does not traverse anymore: for example it does not recognize gboolean datatype from . Same with other includes (In some cases it works: #include <gst/gst.h> include gst/gstelement.h struct type GstElement is seen as valid and recognized). However Index->find unresolved includes helped to find few missing paths, so it understands what include are here. Also auto-complete shows proper headers, but it cant find anything from them. Some built-in libraries like <android/log> has similar issues.
Everything compiles well just CDT cannot traverse code. I am thinking about finding something to switch away from eclipse if these issues remain for NDK development, but couldn't find anything or solve any of problems.
I am using latest android development bundle with ADT 22, Eclipse 4.3.1, CDT 8.2.1.
How to configure Eclipse to properly recognize headers?

You must select a host application to "run" a library

I am working with Code::Blocks and trying to program with the C language. I have created a header file, an implementation file and the main. When I compile, I have no errors, but when I run it I get the following error.
You must select a host application to "run" a library...
The libraries are all in the same folder.
I also did include the header files in my main program.
I have tried on 2 different PCs, and it didn't work. i tried with a different piece of code and it worked flawlessly.
What should I do?
Thanks.
EDIT: Solved.
Go to Project -> Properties -> Build Targets
From the 'Type' drop down list select 'Console Application' (in my case).
Seems like you have created dll. Change to executable.
You may find details how to fix it/
Properties -> Build Target -> 'Type' -> Console application
https://stackoverflow.com/a/8506935/2648826
You have it set up to build a library, not an application.
In File->New Project, you need to choose 'console type'

How can I import compiled C++ libraries into an Objective-C++ project in Xcode 4?

I'm trying to use the SkypeKit SDK to create an Objective-C++ project using Xcode 4. I have two compiled libraries from SkypeKit, libskypekit_cyassl_lib.a and libskypekit_cppwrapper_2_lib.a, which I need to be able to use so as to access the Skype API.
I've added in both .a files under 'Linked Frameworks and Libraries' and added -all_load -ObjC -lstdc++ to the 'Other Linker Flags', and that builds okay, but as soon as I try to use any of the methods in those libraries, building fails.
Any help would be greatly appreciated, thank you!
You can call C++ code from Objective-C++, which means that your files should have the .mm extension instead of .m
I assume that this could be the issue, but since you did not specify the errors you get it is just a guess. Specifically, if you call C++ code from a .m file you get compilation errors.
Another possible cause is forgetting to import the header files of the library. For the import to be successful, you also have to add the directory where the headers are to your project "header search path".
If this does not help, please post the error message.

Resources